![]() # 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> |
||
---|---|---|
.. | ||
crates/gen_tests | ||
docs | ||
src | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |