bevy/crates
Matt Thompson 4e2dc4b15f
Add Saturation trait to bevy_color (#18202)
# Objective

- Allow for convenient access and mutation of color saturation providing
following the `Hue`, `Luminance` traits.

- `with_saturation()` builder method
- `saturation()` to get the saturation of a `Color`
- `set_saturation()` to set the saturation of a mutable `Color`

## Solution

- Defined `Saturation` trait in `color_ops.rs`
- Implemented `Saturation` on `Hsla` and `Hsva`
- Implemented `Saturation` on `Color` which proxies to other color space
impls.
- In the case of colorspaces which don't have native saturation
components
  the color is converted to 'Hsla` internally

## Testing

- Empirically tested
---

## Showcase

```rust
fn next_golden(&mut self) -> Color {
    self.current
        .rotate_hue((1.0 / GOLDEN_RATIO) * 360.0)
        .with_saturation(self.rand_saturation())
        .with_luminance(self.rand_luminance())
        .into()
}
```

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-03-10 21:52:04 +00:00
..
bevy_a11y Automatically enable portable-atomic when required (#17570) 2025-02-24 20:52:46 +00:00
bevy_animation Update petgraph requirement from 0.6 to 0.7 (#18224) 2025-03-10 07:12:27 +00:00
bevy_app Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_asset Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_audio Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_color Add Saturation trait to bevy_color (#18202) 2025-03-10 21:52:04 +00:00
bevy_core_pipeline Partially fix panics when setting WGPU_SETTINGS_PRIO=webgl2 (#18113) 2025-03-09 20:14:27 +00:00
bevy_derive allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
bevy_dev_tools Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
bevy_diagnostic Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
bevy_dylib Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
bevy_ecs Address Entities::len inconsistency (#18190) 2025-03-10 21:51:01 +00:00
bevy_encase_derive Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
bevy_gilrs Replace some !Send resources with thread_local! (#17730) 2025-03-04 07:48:02 +00:00
bevy_gizmos don't use bevy_pbr for base bevy_gizmos plugin (#17581) 2025-03-10 21:16:52 +00:00
bevy_gltf Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
bevy_image Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
bevy_input Fix Component require() IDE integration (#18165) 2025-03-06 02:44:47 +00:00
bevy_input_focus Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
bevy_internal don't use bevy_pbr for base bevy_gizmos plugin (#17581) 2025-03-10 21:16:52 +00:00
bevy_log Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_macro_utils Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
bevy_math Improve Segment2d/Segment3d API and docs (#18206) 2025-03-09 20:21:31 +00:00
bevy_mesh Fix mesh tangent attribute matching in mesh transform operations (#17992) 2025-03-07 17:39:42 +00:00
bevy_mikktspace Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
bevy_pbr Reimplement bindless storage buffers. (#17994) 2025-03-10 21:32:19 +00:00
bevy_picking Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_platform_support Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_ptr moved Debug from derive to impl_ptr in bevy_ptr (#18042) 2025-02-28 02:54:46 +00:00
bevy_reflect Update petgraph requirement from 0.6 to 0.7 (#18224) 2025-03-10 07:12:27 +00:00
bevy_remote BRP resource methods (#17423) 2025-02-26 20:29:47 +00:00
bevy_render Make buffer binding arrays emit bind group layout entries and bindless resource descriptors again. (#18125) 2025-03-10 21:40:24 +00:00
bevy_scene Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_sprite Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
bevy_state Automatically enable portable-atomic when required (#17570) 2025-02-24 20:52:46 +00:00
bevy_tasks Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
bevy_text Add byte information to PositionedGlyph (#17900) 2025-03-08 16:35:01 +00:00
bevy_time Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
bevy_transform Transform Propagation Optimization: Static Subtree Marking (#18093) 2025-03-09 19:29:01 +00:00
bevy_ui extract_text_shadows camera query fix (#17930) 2025-03-10 21:22:14 +00:00
bevy_utils Automatically enable portable-atomic when required (#17570) 2025-02-24 20:52:46 +00:00
bevy_window Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
bevy_winit Replace winit's synthetic events by our own key tracking (#14379) 2025-03-10 21:11:29 +00:00