Skip to content

ColorUtils: Handle cases where hue is -1 in linearInterpolate

Arjen Hiemstra requested to merge work/cherry-pick-9bde1cc9 into kf5

When a color has a saturation of 0 the hue is undefined. QColor expresses this by returning -1 for the hue of those colors. When that happens, just naively interpolating that results in incorrect colors. So instead account for this case by either using the other color's hue or if both are -1, just using 0.

Additionally, since we're using floats in the calculations here, use the various float-based getters/setters instead of relying on implicit conversions.

(cherry picked from commit 9bde1cc9)

Merge request reports

Loading