refactor: Don't append canvas to DOM

This commit is contained in:
Lokesh Dhakar
2019-05-26 20:31:37 -07:00
parent b61e6406a1
commit a921953d1a

View File

@@ -28,8 +28,6 @@ var CanvasImage = function (image) {
this.canvas = document.createElement('canvas'); this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d'); this.context = this.canvas.getContext('2d');
document.body.appendChild(this.canvas);
this.width = this.canvas.width = image.width; this.width = this.canvas.width = image.width;
this.height = this.canvas.height = image.height; this.height = this.canvas.height = image.height;
@@ -44,11 +42,6 @@ CanvasImage.prototype.getImageData = function () {
return this.context.getImageData(0, 0, this.width, this.height); return this.context.getImageData(0, 0, this.width, this.height);
}; };
CanvasImage.prototype.removeCanvas = function () {
this.canvas.parentNode.removeChild(this.canvas);
};
var ColorThief = function () {}; var ColorThief = function () {};
/* /*
@@ -124,9 +117,6 @@ ColorThief.prototype.getPalette = function(sourceImage, colorCount, quality) {
var cmap = MMCQ.quantize(pixelArray, colorCount); var cmap = MMCQ.quantize(pixelArray, colorCount);
var palette = cmap? cmap.palette() : null; var palette = cmap? cmap.palette() : null;
// Clean up
image.removeCanvas();
return palette; return palette;
}; };