quantize icon indicating copy to clipboard operation
quantize copied to clipboard

Change how quantize counts colors.

Open AlfredJKwack opened this issue 7 years ago • 2 comments

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.

AlfredJKwack avatar Jul 22 '17 09:07 AlfredJKwack

Hej, @olivierlesnicki! Can we revive this zombie and merge to master? :)

henser avatar Jun 15 '19 13:06 henser

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.

image

image

ijambro avatar May 25 '20 05:05 ijambro