Permalink
Browse files

colors setting

  • Loading branch information...
1 parent af16808 commit 23e473c297ef47d1b84aefc741d6a0ee1d3c6fd8 @tj tj committed Dec 18, 2011
Showing with 4 additions and 3 deletions.
  1. +1 −0 app.js
  2. +3 −3 palette.js
View
1 app.js
@@ -15,6 +15,7 @@ app.configure(function(){
app.set('view engine', 'jade');
app.set('phantom', 'phantomjs');
app.set('screenshots', '/tmp');
+ app.set('colors', 3);
app.set('root', __dirname);
app.use(express.favicon());
app.use(express.logger('dev'));
View
@@ -12,7 +12,7 @@ var db = app.db;
app.on('screenshot', function(url, path, id){
console.log('palette - reading %s', path);
- colors(path, function(err, colors){
+ colors(path, app.get('colors'), function(err, colors){
if (err) return console.error(err.stack);
console.log('palette - colors computed');
@@ -27,7 +27,7 @@ app.on('screenshot', function(url, path, id){
* Get colors for `path` and invoke `fn(err, colors)`.
*/
-function colors(path, fn) {
+function colors(path, n, fn) {
fs.readFile(path, function(err, buf){
if (err) return fn(err);
@@ -39,7 +39,7 @@ function colors(path, fn) {
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
- var colors = palette(canvas, 8).map(rgb);
+ var colors = palette(canvas, n).map(rgb);
fn(null, colors);
});
}

0 comments on commit 23e473c

Please sign in to comment.