#[repr(C)]pub struct LabHue<T = f32>(/* private fields */);
Expand description
A hue type for the CIE L*a*b* family of color spaces.
It’s measured in degrees and it’s based on the four physiological elementary colors red, yellow, green and blue. This makes it different from the hue of RGB based color spaces.
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§
source§impl<T> LabHue<T>
impl<T> LabHue<T>
sourcepub const fn new(angle: T) -> Self
pub const fn new(angle: T) -> Self
Create a new hue, specified in the default unit for the angle
type T
.
f32
, f64
and other real number types represent degrees,
while u8
simply represents the range [0, 360]
as [0, 256]
.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get the internal representation without normalizing or converting it.
f32
, f64
and other real number types represent degrees,
while u8
simply represents the range [0, 360]
as [0, 256]
.
sourcepub fn into_format<U>(self) -> LabHue<U>where
U: FromAngle<T>,
pub fn into_format<U>(self) -> LabHue<U>where
U: FromAngle<T>,
Convert into another angle type.
sourcepub fn from_format<U>(hue: LabHue<U>) -> Selfwhere
T: FromAngle<U>,
pub fn from_format<U>(hue: LabHue<U>) -> Selfwhere
T: FromAngle<U>,
Convert from another angle type.
source§impl<T: RealAngle> LabHue<T>
impl<T: RealAngle> LabHue<T>
sourcepub fn from_degrees(degrees: T) -> Self
pub fn from_degrees(degrees: T) -> Self
Create a new hue from degrees. This is an alias for new
.
sourcepub fn from_radians(radians: T) -> Self
pub fn from_radians(radians: T) -> Self
Create a new hue from radians, instead of degrees.
sourcepub fn into_raw_degrees(self) -> T
pub fn into_raw_degrees(self) -> T
Get the internal representation as degrees, without normalizing it.
sourcepub fn into_raw_radians(self) -> T
pub fn into_raw_radians(self) -> T
Get the internal representation as radians, without normalizing it.
source§impl<T: RealAngle + SignedAngle> LabHue<T>
impl<T: RealAngle + SignedAngle> LabHue<T>
sourcepub fn into_degrees(self) -> T
pub fn into_degrees(self) -> T
Get the hue as degrees, in the range (-180, 180]
.
sourcepub fn into_radians(self) -> T
pub fn into_radians(self) -> T
Convert the hue to radians, in the range (-π, π]
.
source§impl<T: RealAngle + UnsignedAngle> LabHue<T>
impl<T: RealAngle + UnsignedAngle> LabHue<T>
sourcepub fn into_positive_degrees(self) -> T
pub fn into_positive_degrees(self) -> T
Convert the hue to positive degrees, in the range [0, 360)
.
sourcepub fn into_positive_radians(self) -> T
pub fn into_positive_radians(self) -> T
Convert the hue to positive radians, in the range [0, 2π)
.
source§impl<T: RealAngle + Trigonometry> LabHue<T>
impl<T: RealAngle + Trigonometry> LabHue<T>
sourcepub fn from_cartesian(a: T, b: T) -> Self
pub fn from_cartesian(a: T, b: T) -> Self
Returns a hue from a
and b
, normalized to [0°, 360°)
.
If a
and b
are both 0
, returns 0
,
sourcepub fn into_cartesian(self) -> (T, T)
pub fn into_cartesian(self) -> (T, T)
Returns a
and b
values for this hue, normalized to [-1, 1]
.
They will have to be multiplied by a radius values, such as saturation, value, chroma, etc., to represent a specific color.
source§impl<C> LabHue<C>
impl<C> LabHue<C>
sourcepub fn iter<'a>(&'a self) -> <&'a Self as IntoIterator>::IntoIterwhere
&'a Self: IntoIterator,
pub fn iter<'a>(&'a self) -> <&'a Self as IntoIterator>::IntoIterwhere
&'a Self: IntoIterator,
Return an iterator over the hues in the wrapped collection.
sourcepub fn iter_mut<'a>(&'a mut self) -> <&'a mut Self as IntoIterator>::IntoIterwhere
&'a mut Self: IntoIterator,
pub fn iter_mut<'a>(&'a mut self) -> <&'a mut Self as IntoIterator>::IntoIterwhere
&'a mut Self: IntoIterator,
Return an iterator that allows modifying the hues in the wrapped collection.
sourcepub fn get<'a, I, T>(
&'a self,
index: I,
) -> Option<LabHue<&<I as SliceIndex<[T]>>::Output>>
pub fn get<'a, I, T>( &'a self, index: I, ) -> Option<LabHue<&<I as SliceIndex<[T]>>::Output>>
Get a hue, or slice of hues, with references to the values at index
. See slice::get
for details.
sourcepub fn get_mut<'a, I, T>(
&'a mut self,
index: I,
) -> Option<LabHue<&mut <I as SliceIndex<[T]>>::Output>>
pub fn get_mut<'a, I, T>( &'a mut self, index: I, ) -> Option<LabHue<&mut <I as SliceIndex<[T]>>::Output>>
Get a hue, or slice of hues, that allows modifying the values at index
. See slice::get_mut
for details.
source§impl<T> LabHue<Vec<T>>
impl<T> LabHue<Vec<T>>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a struct with a vector with a minimum capacity. See Vec::with_capacity
for details.
sourcepub fn push(&mut self, value: LabHue<T>)
pub fn push(&mut self, value: LabHue<T>)
Push an additional hue onto the hue vector. See Vec::push
for details.
sourcepub fn pop(&mut self) -> Option<LabHue<T>>
pub fn pop(&mut self) -> Option<LabHue<T>>
Pop a hue from the hue vector. See Vec::pop
for details.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the hue vector. See Vec::clear
for details.
sourcepub fn drain<R>(&mut self, range: R) -> LabHueIter<Drain<'_, T>> ⓘ
pub fn drain<R>(&mut self, range: R) -> LabHueIter<Drain<'_, T>> ⓘ
Return an iterator that moves hues out of the specified range.
Trait Implementations§
source§impl<T> AbsDiffEq for LabHue<T>
impl<T> AbsDiffEq for LabHue<T>
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
source§fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
source§fn abs_diff_ne(&self, other: &Self, epsilon: T::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Self, epsilon: T::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.source§impl<T: AddAssign> AddAssign<T> for LabHue<T>
impl<T: AddAssign> AddAssign<T> for LabHue<T>
source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read moresource§impl<T: AddAssign> AddAssign for LabHue<T>
impl<T: AddAssign> AddAssign for LabHue<T>
source§fn add_assign(&mut self, other: LabHue<T>)
fn add_assign(&mut self, other: LabHue<T>)
+=
operation. Read moresource§impl<'de, T> Deserialize<'de> for LabHue<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for LabHue<T>where
T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<C, T> Extend<T> for LabHue<C>where
C: Extend<T>,
impl<C, T> Extend<T> for LabHue<C>where
C: Extend<T>,
source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<'a, 'b, T> IntoIterator for &'a LabHue<&'b [T]>
impl<'a, 'b, T> IntoIterator for &'a LabHue<&'b [T]>
source§impl<'a, 'b, T> IntoIterator for &'a LabHue<&'b mut [T]>
impl<'a, 'b, T> IntoIterator for &'a LabHue<&'b mut [T]>
source§impl<'a, T> IntoIterator for &'a LabHue<Vec<T>>
impl<'a, T> IntoIterator for &'a LabHue<Vec<T>>
source§impl<'a, 'b, T> IntoIterator for &'a mut LabHue<&'b mut [T]>
impl<'a, 'b, T> IntoIterator for &'a mut LabHue<&'b mut [T]>
source§impl<'a, T> IntoIterator for &'a mut LabHue<Vec<T>>
impl<'a, T> IntoIterator for &'a mut LabHue<Vec<T>>
source§impl<'a, T> IntoIterator for LabHue<&'a [T]>
impl<'a, T> IntoIterator for LabHue<&'a [T]>
source§impl<'a, T> IntoIterator for LabHue<&'a mut [T]>
impl<'a, T> IntoIterator for LabHue<&'a mut [T]>
source§impl<T> IntoIterator for LabHue<Vec<T>>
impl<T> IntoIterator for LabHue<Vec<T>>
source§impl<T> RelativeEq for LabHue<T>where
T: RealAngle + SignedAngle + Zero + AngleEq<Mask = bool> + Sub<Output = T> + Clone + RelativeEq,
T::Epsilon: HalfRotation + Mul<Output = T::Epsilon>,
impl<T> RelativeEq for LabHue<T>where
T: RealAngle + SignedAngle + Zero + AngleEq<Mask = bool> + Sub<Output = T> + Clone + RelativeEq,
T::Epsilon: HalfRotation + Mul<Output = T::Epsilon>,
source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
source§fn relative_eq(
&self,
other: &Self,
epsilon: T::Epsilon,
max_relative: T::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: T::Epsilon, max_relative: T::Epsilon, ) -> bool
source§fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.source§impl<T: SaturatingAdd<Output = T>> SaturatingAdd<T> for LabHue<T>
impl<T: SaturatingAdd<Output = T>> SaturatingAdd<T> for LabHue<T>
source§impl<T: SaturatingAdd<Output = T>> SaturatingAdd for LabHue<T>
impl<T: SaturatingAdd<Output = T>> SaturatingAdd for LabHue<T>
source§impl<T: SaturatingSub<Output = T>> SaturatingSub<T> for LabHue<T>
impl<T: SaturatingSub<Output = T>> SaturatingSub<T> for LabHue<T>
source§impl<T: SaturatingSub<Output = T>> SaturatingSub for LabHue<T>
impl<T: SaturatingSub<Output = T>> SaturatingSub for LabHue<T>
source§impl<T: SubAssign> SubAssign<T> for LabHue<T>
impl<T: SubAssign> SubAssign<T> for LabHue<T>
source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moresource§impl<T: SubAssign> SubAssign for LabHue<T>
impl<T: SubAssign> SubAssign for LabHue<T>
source§fn sub_assign(&mut self, other: LabHue<T>)
fn sub_assign(&mut self, other: LabHue<T>)
-=
operation. Read moresource§impl<T> UlpsEq for LabHue<T>
impl<T> UlpsEq for LabHue<T>
impl<T: Copy> Copy for LabHue<T>
impl<T> Eq for LabHue<T>
Auto Trait Implementations§
impl<T> Freeze for LabHue<T>where
T: Freeze,
impl<T> RefUnwindSafe for LabHue<T>where
T: RefUnwindSafe,
impl<T> Send for LabHue<T>where
T: Send,
impl<T> Sync for LabHue<T>where
T: Sync,
impl<T> Unpin for LabHue<T>where
T: Unpin,
impl<T> UnwindSafe for LabHue<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more