-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
HSL and HSV interpolation for UI gradients #19992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HSL and HSV interpolation for UI gradients #19992
Conversation
@lynn-lumen, you attempted something very similar in #12939. Would you be open to reviewing this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 thegradients
shader 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