Skip to content

Conversation

@AlfredJKwack
Copy link

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.

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.
@henser
Copy link

henser commented Jun 15, 2019

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

@ijambro
Copy link

ijambro commented May 25, 2020

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

gaymeowing added a commit to gaymeowing/quantize-luau that referenced this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants