bevy/crates/bevy_ui_render
ickshonpe 5e3927ba48
UI gradients long hue paths fix (#20010)
# Objective

The false and true arguments for the select statement in `lerp_hue_long`
are misordered, resulting in it taking the wrong hue path:


![oklch-long-wrong-path](https://github.com/user-attachments/assets/68b733ab-be4b-4280-9346-4fdfccdb053a)

## Solution

Swap the arguments around.

Also fixed another case I found during testing. The hue was interpolated
even when it is undefined for one of the endpoints (for example in a
gradient from black to yellow). In those cases it shouldn't interpolate,
instead it should return the hue of the other end point.

## Testing

I added a `linear_gradient` module to the testbed `ui` example, run
with:
```
cargo run --example testbed_ui
```

In the linear gradients screen (press space to switch) it shows a column
of red to yellow linear gradients. The last gradient in the column uses
the OKLCH long path, which should look like this:


![okchlong-red-yellow](https://github.com/user-attachments/assets/23537ff4-f01a-4a03-8473-9df57b2bfaf1)

matching the same gradient in CSS:

https://jsfiddle.net/fevshkdy/14/

if the correct hue path is chosen.
2025-07-07 22:19:24 +00:00
..
src UI gradients long hue paths fix (#20010) 2025-07-07 22:19:24 +00:00
Cargo.toml remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
LICENSE-APACHE bevy_ui_render crate (#18703) 2025-07-03 23:36:35 +00:00
LICENSE-MIT bevy_ui_render crate (#18703) 2025-07-03 23:36:35 +00:00
README.md bevy_ui_render crate (#18703) 2025-07-03 23:36:35 +00:00

Bevy Render UI

License Crates.io Downloads Docs Discord