HSL and HSV interpolation for UI gradients#19992
HSL and HSV interpolation for UI gradients#19992alice-i-cecile merged 9 commits intobevyengine:mainfrom
Conversation
|
@lynn-lumen, you attempted something very similar in #12939. Would you be open to reviewing this? |
lynn-lumen
left a comment
There was a problem hiding this comment.
This looks good to me. There are just two functions that I believe should be named differently.
Oh yep good catch, the select cases are the wrong way around, it should be Should be fixed by #20010 |
Actually, I noticed this problem too and forgot to mention it. I ended up breaking the hue rotation into multiple steps, each less than 180 degrees, to work around it. For the hue slider, I need to go from 0 to 360 (or zero to zero I suppose). To get consistent results, however, I ended up having to go from 0.00001 to 359.9999. This doesn't affect the range of values that the slider can edit, only the background gradient, and the difference is imperceptible. |
|
OK I patched this in to my color sliders PR and can verify that it is working. One thing I would really like is to be able to import these color functions into a custom shader, but that can be left for a follow-up PR. |


Objective
Add interpolation in HSL and HSV colour spaces for UI gradients.
Solution
Added new variants to
InterpolationColorSpace:Hsl,HslLong,Hsv, andHsvLong, along with mix functions to thegradientsshader for each of them.Limitations
Didn't include increasing and decreasing path support, it's not essential and can be done in a follow up if someone feels like it.
The colour conversions should really be performed before the colours are sent to the shader but it would need more changes and performance is good enough for now.
Testing
cargo run --example gradients