mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-26 06:14:25 +00:00
Updated read me
This commit is contained in:
@@ -1,40 +1,46 @@
|
|||||||
#Color Thief
|
#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)
|
[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
|
```js
|
||||||
getDominantColor(sourceImage)
|
var colorThief = new ColorThief();
|
||||||
```
|
colorThief.getColor(sourceImage);
|
||||||
|
|
||||||
```js
|
|
||||||
returns [num, num, 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
|
|
||||||
```js
|
|
||||||
createPalette(sourceImage, colorCount)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
getColor(sourceImage[, quality])
|
||||||
|
returns {r: num, g: num, b: num}
|
||||||
|
```
|
||||||
|
|
||||||
|
###Build a color palette from an image
|
||||||
|
```js
|
||||||
|
var colorThief = new ColorThief();
|
||||||
|
colorThief.getPalette(sourceImage);
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
getPalette(sourceImage, colorCount[, quality])
|
||||||
returns [ [num, num, num], [num, num, num], ... ]
|
returns [ [num, num, num], [num, num, num], ... ]
|
||||||
```
|
```
|
||||||
|
|
||||||
Use the median cut algorithm provided by quantize.js to cluster similar
|
##Credits and license
|
||||||
colors.
|
|
||||||
|
|
||||||
##License
|
###Author
|
||||||
by Lokesh Dhakar | [lokeshdhakar.com](http://www.lokeshdhakar.com) | [twitter.com/lokeshdhakar](http://twitter.com/lokeshdhakar)
|
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/)
|
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.
|
* Free for use in both personal and commercial projects.
|
||||||
|
|||||||
Reference in New Issue
Block a user