Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 18, 2011
1 parent 38b71f2 commit b3b39a8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Readme.md
Expand Up @@ -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

```
Expand Down

0 comments on commit b3b39a8

Please sign in to comment.