Expand description
A hue type for the RGB family of color spaces.
It’s measured in degrees and uses the three additive primaries red, green and blue.
The hue is a circular type, where 0
and 360
is the same, and
it’s normalized to (-180, 180]
when it’s converted to a linear
number (like f32
). This makes many calculations easier, but may
also have some surprising effects if it’s expected to act as a
linear number.
Implementations
sourceimpl<T> RgbHue<T>where
T: Float,
impl<T> RgbHue<T>where
T: Float,
sourcepub fn from_degrees(degrees: T) -> RgbHue<T>
pub fn from_degrees(degrees: T) -> RgbHue<T>
Create a new hue from degrees.
sourcepub fn from_radians(radians: T) -> RgbHue<T>
pub fn from_radians(radians: T) -> RgbHue<T>
Create a new hue from radians, instead of degrees.
sourcepub fn to_degrees(self) -> T
pub fn to_degrees(self) -> T
Get the hue as degrees, in the range (-180, 180]
.
sourcepub fn to_radians(self) -> T
pub fn to_radians(self) -> T
Convert the hue to radians, in the range (-π, π]
.
sourcepub fn to_positive_degrees(self) -> T
pub fn to_positive_degrees(self) -> T
Convert the hue to positive degrees, in the range [0, 360)
.
sourcepub fn to_positive_radians(self) -> T
pub fn to_positive_radians(self) -> T
Convert the hue to positive radians, in the range [0, 2π)
.
sourcepub fn to_raw_degrees(self) -> T
pub fn to_raw_degrees(self) -> T
Get the internal representation, without normalizing it.
sourcepub fn to_raw_radians(self) -> T
pub fn to_raw_radians(self) -> T
Get the internal representation as radians, without normalizing it.
Trait Implementations
sourceimpl<T> ApproxEq for RgbHue<T>where
T: Float + ApproxEq,
<T as ApproxEq>::Epsilon: Float,
impl<T> ApproxEq for RgbHue<T>where
T: Float + ApproxEq,
<T as ApproxEq>::Epsilon: Float,
type Epsilon = <T as ApproxEq>::Epsilon
type Epsilon = <T as ApproxEq>::Epsilon
sourcefn default_epsilon() -> <RgbHue<T> as ApproxEq>::Epsilon
fn default_epsilon() -> <RgbHue<T> as ApproxEq>::Epsilon
sourcefn default_max_relative() -> <RgbHue<T> as ApproxEq>::Epsilon
fn default_max_relative() -> <RgbHue<T> as ApproxEq>::Epsilon
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
sourcefn relative_eq(
&self,
other: &RgbHue<T>,
epsilon: <RgbHue<T> as ApproxEq>::Epsilon,
max_relative: <RgbHue<T> as ApproxEq>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &RgbHue<T>,
epsilon: <RgbHue<T> as ApproxEq>::Epsilon,
max_relative: <RgbHue<T> as ApproxEq>::Epsilon
) -> bool
sourcefn ulps_eq(
&self,
other: &RgbHue<T>,
epsilon: <RgbHue<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
fn ulps_eq(
&self,
other: &RgbHue<T>,
epsilon: <RgbHue<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
sourceimpl<T> PartialEq<RgbHue<T>> for RgbHue<T>where
T: Float,
impl<T> PartialEq<RgbHue<T>> for RgbHue<T>where
T: Float,
impl<T> Copy for RgbHue<T>where
T: Copy + Float,
Auto Trait Implementations
impl<T> RefUnwindSafe for RgbHue<T>where
T: RefUnwindSafe,
impl<T> Send for RgbHue<T>where
T: Send,
impl<T> Sync for RgbHue<T>where
T: Sync,
impl<T> Unpin for RgbHue<T>where
T: Unpin,
impl<T> UnwindSafe for RgbHue<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Component + Float,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Component + Float,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
sourcefn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
sourcefn adapt_into(self) -> D
fn adapt_into(self) -> D
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.