cosmic::cosmic_theme::palette

Trait 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());

Required Associated Types§

source

type Hue

The kind of hue unit this color space uses.

The hue is most commonly calculated as an angle around a color circle and may not always be uniform between color spaces. It’s therefore not recommended to take one type of hue and apply it to a color space that expects an other.

Required Methods§

source

fn get_hue(&self) -> Self::Hue

Calculate a hue if possible.

Colors in the gray scale has no well defined hue and should preferably return 0.

Implementors§

source§

impl<C, T> GetHue for Alpha<C, T>
where C: GetHue,

source§

type Hue = <C as GetHue>::Hue

source§

impl<S, T> GetHue for Rgb<S, T>

source§

impl<S, T> GetHue for Hsl<S, T>
where T: Clone,

source§

impl<S, T> GetHue for Hsv<S, T>
where T: Clone,

source§

impl<S, T> GetHue for Hwb<S, T>
where T: Clone,

source§

impl<T> GetHue for Cam16Jch<T>
where T: Clone,

source§

impl<T> GetHue for Cam16Jmh<T>
where T: Clone,

source§

impl<T> GetHue for Cam16Jsh<T>
where T: Clone,

source§

impl<T> GetHue for Cam16Qch<T>
where T: Clone,

source§

impl<T> GetHue for Cam16Qmh<T>
where T: Clone,

source§

impl<T> GetHue for Cam16Qsh<T>
where T: Clone,

source§

impl<T> GetHue for Cam16<T>
where T: Clone,

source§

impl<T> GetHue for Cam16UcsJmh<T>
where T: Clone,

source§

impl<T> GetHue for Okhsl<T>
where T: Clone,

source§

impl<T> GetHue for Okhsv<T>
where T: Clone,

source§

impl<T> GetHue for Okhwb<T>
where T: Clone,

source§

impl<T> GetHue for Oklab<T>
where T: Trigonometry + Add<Output = T> + Neg<Output = T> + RealAngle + Clone,

source§

impl<T> GetHue for Oklch<T>
where T: Clone,

source§

impl<Wp, T> GetHue for Hsluv<Wp, T>
where T: Clone,

source§

impl<Wp, T> GetHue for Lab<Wp, T>
where T: RealAngle + Trigonometry + Add<Output = T> + Neg<Output = T> + Clone,

source§

impl<Wp, T> GetHue for Lch<Wp, T>
where T: Clone,

source§

impl<Wp, T> GetHue for Lchuv<Wp, T>
where T: Clone,

source§

impl<Wp, T> GetHue for Luv<Wp, T>
where T: RealAngle + Trigonometry + Add<Output = T> + Neg<Output = T> + Clone,