mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 22:04:25 +00:00
more code cleanup
This commit is contained in:
@@ -45,7 +45,6 @@ CanvasImage.prototype.clear = function() {
|
||||
}
|
||||
|
||||
CanvasImage.prototype.update = function(imageData) {
|
||||
console.log('worked');
|
||||
this.context.putImageData(imageData, 0, 0);
|
||||
}
|
||||
|
||||
@@ -57,6 +56,10 @@ CanvasImage.prototype.getImageData = function() {
|
||||
return this.context.getImageData(0, 0, this.width, this.height);
|
||||
}
|
||||
|
||||
CanvasImage.prototype.removeCanvas = function() {
|
||||
$(this.canvas).remove();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* getDominantColor(sourceImage)
|
||||
@@ -89,6 +92,9 @@ function getDominantColor(sourceImage){
|
||||
var cmap = MMCQ.quantize(pixelArray, 5);
|
||||
var newPalette = cmap.palette();
|
||||
|
||||
// Clean up
|
||||
image.removeCanvas();
|
||||
|
||||
return {r: newPalette[0][0], g: newPalette[0][1], b: newPalette[0][2]};
|
||||
}
|
||||
|
||||
@@ -127,6 +133,9 @@ function createPalette(sourceImage, colorCount){
|
||||
var cmap = MMCQ.quantize(pixelArray, colorCount);
|
||||
var newPalette = cmap.palette();
|
||||
|
||||
// Clean up
|
||||
image.removeCanvas();
|
||||
|
||||
return newPalette;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user