Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "quantize", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A node.js module for color quantization, based on Leptonica.", | ||
@@ -30,3 +30,3 @@ "homepage": "https://github.com/olivierlesnicki/quantize", | ||
"engines": { | ||
"node": ">=0.6.0" | ||
"node": ">=0.10.21" | ||
}, | ||
@@ -33,0 +33,0 @@ "dependencies": {}, |
@@ -182,3 +182,3 @@ /* | ||
} else { | ||
console.log('empty box'); | ||
//console.log('empty box'); | ||
vbox._avg = [~~(mult * (vbox.r1 + vbox.r2 + 1) / 2), ~~ (mult * (vbox.g1 + vbox.g2 + 1) / 2), ~~ (mult * (vbox.b1 + vbox.b2 + 1) / 2)]; | ||
@@ -387,3 +387,3 @@ } | ||
vbox2[dim1] = vbox1[dim2] + 1; | ||
console.log('vbox counts:', vbox.count(), vbox1.count(), vbox2.count()); | ||
// console.log('vbox counts:', vbox.count(), vbox1.count(), vbox2.count()); | ||
return [vbox1, vbox2]; | ||
@@ -403,3 +403,3 @@ } | ||
if (!pixels.length || maxcolors < 2 || maxcolors > 256) { | ||
console.log('wrong number of maxcolors'); | ||
// console.log('wrong number of maxcolors'); | ||
return false; | ||
@@ -448,3 +448,3 @@ } | ||
if (!vbox1) { | ||
console.log("vbox1 not defined; shouldn't happen!"); | ||
// console.log("vbox1 not defined; shouldn't happen!"); | ||
return; | ||
@@ -459,3 +459,3 @@ } | ||
if (niters++ > maxIterations) { | ||
console.log("infinite loop; perhaps too few pixels!"); | ||
// console.log("infinite loop; perhaps too few pixels!"); | ||
return; | ||
@@ -462,0 +462,0 @@ } |
quantize | ||
======== | ||
Node.js module for color quantization, based on Leptonica | ||
Node.js module for color quantization, based on Leptonica. | ||
Install | ||
------- | ||
npm install quantize | ||
Quick Overview | ||
-------------- | ||
###Usage | ||
`````javascript | ||
var quantize = require('quantize'); | ||
var arrayOfPixels = [[190,197,190], [202,204,200], [207,214,210], [211,214,211], [205,207,207]]; | ||
var maximumColorCount = 4; | ||
var colorMap = quantize(arrayOfPixels, maximumColorCount); | ||
````` | ||
* `arrayOfPixels` - An array of pixels (represented as [R,G,B arrays]) to quantize | ||
* `maxiumColorCount` - The maximum number of colours allowed in the reduced palette | ||
#####Reduced Palette | ||
The `.palette()` method returns an array that contains the reduced color palette. | ||
`````javascript | ||
// Returns the reduced palette | ||
colorMap.palette(); | ||
// [[204, 204, 204], [208,212,212], [188,196,188], [212,204,196]] | ||
````` | ||
#####Reduced pixel | ||
The `.map(pixel)` method maps an individual pixel to the reduced color palette. | ||
`````javascript | ||
// Returns the reduced pixel | ||
colorMap.map(arrayOfPixels[0]); | ||
// [188,196,188] | ||
````` | ||
Author | ||
------ | ||
* [Olivier Lesnicki](https://github.com/olivierlesnicki) | ||
Contributors | ||
------------ | ||
* [Nick Rabinowitz](https://github.com/nrabinowitz) | ||
* [Mike Bostock] (https://github.com/mbostock) | ||
License | ||
------- | ||
Licensed under the MIT License. |
19622
62