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:
@@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
|
||||||
<link href='http://fonts.googleapis.com/css?family=Varela+Round|Terminal+Dosis:400,700,600' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=Varela+Round|Terminal+Dosis:400,700,600' rel='stylesheet' type='text/css'>
|
||||||
|
|
||||||
<title>Color Thief</title>
|
<title>Color Thief</title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
@@ -66,4 +66,4 @@
|
|||||||
|
|
||||||
<script src="index.js"></script>
|
<script src="index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -224,4 +225,4 @@ function createAreaBasedPalette(sourceImage, colorCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user