-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
168 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,41 @@ | ||
# Color Thief | ||
A script for grabbing the dominant color or a representative color palette from an image. Uses javascript and canvas. | ||
#Color Thief | ||
|
||
###[See a Demo](http://lokeshdhakar.com/projects/color-thief) | ||
A script for grabbing the dominant color or color palette from an image. Uses javascript and canvas. | ||
|
||
###Usage | ||
[See a Demo](http://lokeshdhakar.com/projects/color-thief) | [Read more on my blog](http://lokeshdhakar.com/color-thief) | ||
|
||
####Get Dominant Color | ||
##Usage | ||
|
||
###Get Dominant Color | ||
```js | ||
getDominantColor(sourceImage) | ||
``` | ||
returns {r: num, g: num, b: num} | ||
|
||
```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 | ||
###Create Palette | ||
```js | ||
createPalette(sourceImage, colorCount) | ||
``` | ||
|
||
```js | ||
returns [ [num, num, num], [num, num, num], ... ] | ||
``` | ||
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. | ||
##License | ||
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 other for submitting issues and fixes. | ||
|
||
Licensed under the [Creative Commons Attribution 2.5 License](http://creativecommons.org/licenses/by/2.5/) | ||
|
||
###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. | ||
* Attribution requires leaving author name, author homepage link, and the license info intact. |
Oops, something went wrong.