quantize
quantize copied to clipboard
Change how quantize counts colors.
The inner function used by quantize was counting the number of colors added to the palette, starting from 1. This only works when the PQueue passed contains only 1 VBox; but the iter function is called twice, and the second time, the VBox contains more than one color. This means that in some circumstances it was counting the number of colors added incorrectly, and so quantize.js would sometimes return the wrong number of colors . This commit changes iter to start counting at the actual number of colors in the PQueue, so that it always returns the number of colors requested.
Hej, @olivierlesnicki! Can we revive this zombie and merge to master? :)
I've created Mocha tests (in #10 ) that show this change is a significant improvement.
The quantize function will return the exact color count requested for all values of maximumColorCount.