Permalink
Browse files

readme

  • Loading branch information...
1 parent 38b71f2 commit b3b39a8da28a8e1a662d989067008dbbad60015e @tj committed Dec 18, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 Readme.md
View
@@ -11,6 +11,26 @@
$ npm install palette
```
+## API
+
+ Palette's public API consists of a single function, the one returned by `require()`. This function accepts the `canvas` you wish to compute a color palette for, and an optional number of samples defaulting to `5`.
+
+ The following example is taken from the `./test` script, showing you how you may re-draw the palette onto the original canvas, however it is of course possible to save these values in a database etc.
+
+```js
+var colors = palette(canvas, 10);
+colors.forEach(function(color){
+ var r = color[0]
+ , g = color[1]
+ , b = color[2]
+ , val = r << 16 | g << 8 | b
+ , str = '#' + val.toString(16);
+
+ ctx.fillStyle = str;
+ ctx.fillRect(x += 31, canvas.height - 40, 30, 30);
+});
+```
+
### Running the examples
```

0 comments on commit b3b39a8

Please sign in to comment.