Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Bug in ColorFromPalette for CHSVPalette16 and CHSVPalette32 #602
I think there is a bug in ColorFromPalette when the hues decrease in value (go backwards)
uint8_t deltaHue = (uint8_t)(hue2 - hue1);
The first parameter to scale8 in the backwards case should be equal to the abs(deltaHue) but as coded is equal to abs(deltaHue) - 1. As a result, the value of hue2 + 1 is never returned.
For a concrete example, imagine the two cases
In 1), the forward case, the first parameter to scale8 will be 10, returning values in the range 0 to 9 as desired.
In 2), the backwards case, the first parameter to scale8 will be 9 (255-246), returning values in the range 0 to 8, one short of desired.