Updated read me

This commit is contained in:
Lokesh Dhakar
2013-06-23 22:27:41 -07:00
parent b088790b8d
commit 0f590b91ee

View File

@@ -1,40 +1,46 @@
#Color Thief
A script for grabbing the dominant color or color palette from an image. Uses javascript and canvas.
A script for grabbing the color palette from an image. Uses Javascript and the canvas tag to make it happen.
[See a Demo](http://lokeshdhakar.com/projects/color-thief) | [Read more on my blog](http://lokeshdhakar.com/color-thief)
##Usage
##How to use
###Get Dominant Color
###Get the dominant color from an image
```js
getDominantColor(sourceImage)
var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
```
```js
returns [num, num, num]
getColor(sourceImage[, quality])
returns {r: num, g: num, b: num}
```
Uses the median cut algorithm provided by quantize.js to cluster similar
colors and return the base color from the largest cluster.
###Create Palette
###Build a color palette from an image
```js
createPalette(sourceImage, colorCount)
var colorThief = new ColorThief();
colorThief.getPalette(sourceImage);
```
```js
getPalette(sourceImage, colorCount[, quality])
returns [ [num, num, num], [num, num, num], ... ]
```
Use the median cut algorithm provided by quantize.js to cluster similar
colors.
##Credits and license
##License
by Lokesh Dhakar | [lokeshdhakar.com](http://www.lokeshdhakar.com) | [twitter.com/lokeshdhakar](http://twitter.com/lokeshdhakar)
###Author
by Lokesh Dhakar
[lokeshdhakar.com](http://www.lokeshdhakar.com)
[twitter.com/lokeshdhakar](http://twitter.com/lokeshdhakar)
Thanks to [jfsiii](https://github.com/jfsiii) for a large number of code improvements and others for submitting issues and fixes.
###Thanks
* Nick Rabinowitz - For creating quantize.js.
* John Schulz - For clean up and optimization. @JFSIII
* Nathan Spady - For adding drag and drop support to the demo page.
###License
Licensed under the [Creative Commons Attribution 2.5 License](http://creativecommons.org/licenses/by/2.5/)
* Free for use in both personal and commercial projects.