From 9cea24a6bfe0e9cbdaade9f3a6faac6824380089 Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Sun, 26 May 2019 20:28:38 -0700 Subject: [PATCH 1/3] refactor: Remove unused canvas methods --- src/color-thief.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/color-thief.js b/src/color-thief.js index d5bc5da..3092e5d 100644 --- a/src/color-thief.js +++ b/src/color-thief.js @@ -36,14 +36,6 @@ var CanvasImage = function (image) { this.context.drawImage(image, 0, 0, this.width, this.height); }; -CanvasImage.prototype.clear = function () { - this.context.clearRect(0, 0, this.width, this.height); -}; - -CanvasImage.prototype.update = function (imageData) { - this.context.putImageData(imageData, 0, 0); -}; - CanvasImage.prototype.getPixelCount = function () { return this.width * this.height; }; From b61e6406a1e8d8cbab59d8dceada1ca970fe5c3c Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Sun, 26 May 2019 20:30:33 -0700 Subject: [PATCH 2/3] refactor: Remove console log from demo js --- examples/js/demo.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/js/demo.js b/examples/js/demo.js index 1ddc64d..11f8acb 100644 --- a/examples/js/demo.js +++ b/examples/js/demo.js @@ -45,7 +45,6 @@ const showColorsForImage = function(image, section) { let start = Date.now(); let result = colorThief.getPalette(image, count); let elapsedTime = Date.now() - start; - console.log('palette()', count, result.length) paletteHTML += Mustache.to_html(document.getElementById('palette-tpl').innerHTML, { count, palette: result, From a921953d1ac28297e107f19f093d7f9765895658 Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Sun, 26 May 2019 20:31:37 -0700 Subject: [PATCH 3/3] refactor: Don't append canvas to DOM --- src/color-thief.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/color-thief.js b/src/color-thief.js index 3092e5d..77ddc28 100644 --- a/src/color-thief.js +++ b/src/color-thief.js @@ -28,8 +28,6 @@ var CanvasImage = function (image) { this.canvas = document.createElement('canvas'); this.context = this.canvas.getContext('2d'); - document.body.appendChild(this.canvas); - this.width = this.canvas.width = image.width; 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); }; -CanvasImage.prototype.removeCanvas = function () { - this.canvas.parentNode.removeChild(this.canvas); -}; - - var ColorThief = function () {}; /* @@ -124,9 +117,6 @@ ColorThief.prototype.getPalette = function(sourceImage, colorCount, quality) { var cmap = MMCQ.quantize(pixelArray, colorCount); var palette = cmap? cmap.palette() : null; - // Clean up - image.removeCanvas(); - return palette; };