-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
UI Node Gradients #18139
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
UI Node Gradients #18139
Conversation
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 PR was created before we implemented the new release notes process, and so hasn't gotten the right pings by the bot. I'm re-adding the tags so that you'll get the new instructions.
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
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.
Release content looks good.
Minor nit that I was not aware of before reading the new content:
Colors are interpolated between the stops in SRGB space.
Srgb is almost certainly the wrong space to do any kind of color gradient or interpolation in, except in the case where you are trying to match another program (which also does it wrong). This should ideally be (a) configurable and (b) default to OkLab.
I consider this feedback non-blocking, but I did want it to be registered.
I went with SRGB, despite the transitions looking so dull and muddy, as it's the default for CSS which the api here is roughly based on. I'd definitely be on board with making Bevy default to OkLab though. I'm kind of fighting myself not to make more changes here and add multiple color space support etc but I've got so many PRs in review atm need to get some of them merged hehe. |
Yeah, totally fair let's look into this as follow up. |
Objective
Allowing drawing of UI nodes with a gradient instead of a flat color.
Solution
The are three gradient structs corresponding to the three types of gradients supported:
LinearGradient
,ConicGradient
andRadialGradient
. These are then wrapped in aGradient
enum discriminator which hasLinear
,Conic
andRadial
variants.Each gradient type consists of the geometric properties for that gradient and a list of color stops.
Color stops consist of a color, a position or angle and an optional hint. If no position is specified for a stop, it's evenly spaced between the previous and following stops. Color stop positions are absolute, if you specify a list of stops:
vec