more code cleanup

This commit is contained in:
Lokesh Dhakar
2011-11-03 17:54:22 -04:00
parent a32716930d
commit 8bf268e309
15 changed files with 383 additions and 319 deletions

View File

@@ -0,0 +1,28 @@
# Color Thief
by Lokesh Dhakar - [Blog](http://lokeshdhakar.com) - [Twitter](http://twitter.com/lokeshdhakar)
A script for grabbing the dominant color or a representative color palette from an image. Uses javascript and canvas.
## [Demo](http://lokeshdhakar.com/projects/color-thief)
##Requirements
* jQuery
* quantize.js
##Usage
###getDominantColor(sourceImage)
returns {r: num, g: num, b: num}
Use the median cut algorithm provided by quantize.js to cluster similar
colors and return the base color from the largest cluster.
###createPalette(sourceImage, colorCount)
returns array[ {r: num, g: num, b: num}, {r: num, g: num, b: num}, ...]
Use the median cut algorithm provided by quantize.js to cluster similar
colors.
BUGGY: Function does not always return the requested amount of colors. It can be +/- 2.
Licensed under the [Creative Commons Attribution 2.5 License](http://creativecommons.org/licenses/by/2.5/)