bevy/crates/bevy_ui_render/src
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
..
box_shadow.rs Use RenderStartup in bevy_ui. (#19901) 2025-07-05 04:07:23 +00:00
box_shadow.wgsl
debug_overlay.rs
gradient.rs HSL and HSV interpolation for UI gradients (#19992) 2025-07-07 20:08:51 +00:00
gradient.wgsl UI gradients long hue paths fix (#20010) 2025-07-07 22:19:24 +00:00
lib.rs Use RenderStartup in bevy_ui. (#19901) 2025-07-05 04:07:23 +00:00
pipeline.rs Use RenderStartup in bevy_ui. (#19901) 2025-07-05 04:07:23 +00:00
render_pass.rs
ui_material_pipeline.rs Use RenderStartup in bevy_ui. (#19901) 2025-07-05 04:07:23 +00:00
ui_material.rs
ui_material.wgsl
ui_texture_slice_pipeline.rs Use RenderStartup in bevy_ui. (#19901) 2025-07-05 04:07:23 +00:00
ui_texture_slice.wgsl
ui_vertex_output.wgsl
ui.wgsl