Trait cosmic::cosmic_theme::palette::GetHue
source · pub trait GetHue {
type Hue;
// Required method
fn get_hue(&self) -> Self::Hue;
}
Expand description
A trait for colors where a hue may be calculated.
See also WithHue
, SetHue
, ShiftHue
and ShiftHueAssign
.
use approx::assert_relative_eq;
use palette::{GetHue, LinSrgb};
let red = LinSrgb::new(1.0f32, 0.0, 0.0);
let green = LinSrgb::new(0.0f32, 1.0, 0.0);
let blue = LinSrgb::new(0.0f32, 0.0, 1.0);
let gray = LinSrgb::new(0.5f32, 0.5, 0.5);
assert_relative_eq!(red.get_hue(), 0.0.into());
assert_relative_eq!(green.get_hue(), 120.0.into());
assert_relative_eq!(blue.get_hue(), 240.0.into());
assert_relative_eq!(gray.get_hue(), 0.0.into());