mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
Merge commit 'v1.0' into dev
This commit is contained in:
@@ -4,12 +4,13 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
|
* Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
|
||||||
*
|
*
|
||||||
* The median cut palette function uses quantize.js which is written by Nick Rabinowitz
|
* # Thanks
|
||||||
* and licensed under the MIT license. Big props to Nick as this is where the magic happens.
|
* Nick Rabinowitz: Created quantize.js which is used by the median cut palette function. This handles all the hard clustering math.
|
||||||
|
* John Schulz: All around mad genius who helped clean and optimize the code. @JFSIII
|
||||||
*
|
*
|
||||||
* == Classes
|
* ## Classes
|
||||||
* CanvasImage
|
* CanvasImage
|
||||||
* == Functions
|
* ## Functions
|
||||||
* getDominantColor()
|
* getDominantColor()
|
||||||
* createPalette()
|
* createPalette()
|
||||||
* getAverageRGB()
|
* getAverageRGB()
|
||||||
@@ -66,8 +67,7 @@ CanvasImage.prototype.removeCanvas = function () {
|
|||||||
* returns {r: num, g: num, b: num}
|
* returns {r: num, g: num, b: num}
|
||||||
*
|
*
|
||||||
* Use the median cut algorithm provided by quantize.js to cluster similar
|
* Use the median cut algorithm provided by quantize.js to cluster similar
|
||||||
* colors and return the base color from the largest cluster.
|
* colors and return the base color from the largest cluster. */
|
||||||
*/
|
|
||||||
function getDominantColor(sourceImage) {
|
function getDominantColor(sourceImage) {
|
||||||
|
|
||||||
var palette = createPalette(sourceImage, 5);
|
var palette = createPalette(sourceImage, 5);
|
||||||
@@ -120,6 +120,7 @@ function createPalette(sourceImage, colorCount) {
|
|||||||
image.removeCanvas();
|
image.removeCanvas();
|
||||||
|
|
||||||
return palette;
|
return palette;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user