Struct cosmic::cosmic_theme::palette::LabHue
source · #[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) -> LabHue<T>
pub const fn new(angle: T) -> LabHue<T>
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>) -> LabHue<T>where
T: FromAngle<U>,
pub fn from_format<U>(hue: LabHue<U>) -> LabHue<T>where
T: FromAngle<U>,
Convert from another angle type.
source§impl<T> LabHue<T>where
T: RealAngle,
impl<T> LabHue<T>where
T: RealAngle,
sourcepub fn from_degrees(degrees: T) -> LabHue<T>
pub fn from_degrees(degrees: T) -> LabHue<T>
Create a new hue from degrees. This is an alias for new
.
sourcepub fn from_radians(radians: T) -> LabHue<T>
pub fn from_radians(radians: T) -> LabHue<T>
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> LabHue<T>where
T: RealAngle + SignedAngle,
impl<T> LabHue<T>where
T: RealAngle + SignedAngle,
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> LabHue<T>where
T: RealAngle + UnsignedAngle,
impl<T> LabHue<T>where
T: RealAngle + UnsignedAngle,
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> LabHue<T>where
T: RealAngle + Trigonometry,
impl<T> LabHue<T>where
T: RealAngle + Trigonometry,
sourcepub fn from_cartesian(a: T, b: T) -> LabHue<T>
pub fn from_cartesian(a: T, b: T) -> LabHue<T>
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 LabHue<C> as IntoIterator>::IntoIterwhere
&'a LabHue<C>: IntoIterator,
pub fn iter<'a>(&'a self) -> <&'a LabHue<C> as IntoIterator>::IntoIterwhere
&'a LabHue<C>: IntoIterator,
Return an iterator over the hues in the wrapped collection.
sourcepub fn iter_mut<'a>(
&'a mut self,
) -> <&'a mut LabHue<C> as IntoIterator>::IntoIterwhere
&'a mut LabHue<C>: IntoIterator,
pub fn iter_mut<'a>(
&'a mut self,
) -> <&'a mut LabHue<C> as IntoIterator>::IntoIterwhere
&'a mut LabHue<C>: 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<&'a <I as SliceIndex<[T]>>::Output>>
pub fn get<'a, I, T>( &'a self, index: I, ) -> Option<LabHue<&'a <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<&'a mut <I as SliceIndex<[T]>>::Output>>
pub fn get_mut<'a, I, T>( &'a mut self, index: I, ) -> Option<LabHue<&'a 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) -> LabHue<Vec<T>>
pub fn with_capacity(capacity: usize) -> LabHue<Vec<T>>
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() -> <LabHue<T> as AbsDiffEq>::Epsilon
fn default_epsilon() -> <LabHue<T> as AbsDiffEq>::Epsilon
source§fn abs_diff_eq(
&self,
other: &LabHue<T>,
epsilon: <T as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &LabHue<T>, epsilon: <T as AbsDiffEq>::Epsilon, ) -> bool
source§fn abs_diff_ne(
&self,
other: &LabHue<T>,
epsilon: <T as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_ne( &self, other: &LabHue<T>, epsilon: <T as AbsDiffEq>::Epsilon, ) -> bool
AbsDiffEq::abs_diff_eq
.source§impl<T> AddAssign<T> for LabHue<T>where
T: AddAssign,
impl<T> AddAssign<T> for LabHue<T>where
T: AddAssign,
source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read moresource§impl<T> AddAssign for LabHue<T>where
T: AddAssign,
impl<T> AddAssign for LabHue<T>where
T: AddAssign,
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<LabHue<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LabHue<T>, <__D as Deserializer<'de>>::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>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
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§type IntoIter = LabHueIter<IterMut<'a, T>>
type IntoIter = LabHueIter<IterMut<'a, T>>
source§impl<'a, T, const N: usize> IntoIterator for &'a mut LabHue<[T; N]>
impl<'a, T, const N: usize> IntoIterator for &'a mut LabHue<[T; N]>
source§type IntoIter = LabHueIter<IterMut<'a, T>>
type IntoIter = LabHueIter<IterMut<'a, T>>
source§impl<'a, T> IntoIterator for &'a mut LabHue<Box<[T]>>
impl<'a, T> IntoIterator for &'a mut LabHue<Box<[T]>>
source§type IntoIter = LabHueIter<IterMut<'a, T>>
type IntoIter = LabHueIter<IterMut<'a, T>>
source§impl<'a, T> IntoIterator for &'a mut LabHue<Vec<T>>
impl<'a, T> IntoIterator for &'a mut LabHue<Vec<T>>
source§type IntoIter = LabHueIter<IterMut<'a, T>>
type IntoIter = LabHueIter<IterMut<'a, 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: Zero + AngleEq<Mask = bool> + Sub<Output = T> + RealAngle + Clone + RelativeEq + SignedAngle,
<T as AbsDiffEq>::Epsilon: HalfRotation + Mul<Output = <T as AbsDiffEq>::Epsilon>,
impl<T> RelativeEq for LabHue<T>where
T: Zero + AngleEq<Mask = bool> + Sub<Output = T> + RealAngle + Clone + RelativeEq + SignedAngle,
<T as AbsDiffEq>::Epsilon: HalfRotation + Mul<Output = <T as AbsDiffEq>::Epsilon>,
source§fn default_max_relative() -> <LabHue<T> as AbsDiffEq>::Epsilon
fn default_max_relative() -> <LabHue<T> as AbsDiffEq>::Epsilon
source§impl<T> SaturatingAdd<T> for LabHue<T>where
T: SaturatingAdd<Output = T>,
impl<T> SaturatingAdd<T> for LabHue<T>where
T: SaturatingAdd<Output = T>,
source§impl<T> SaturatingAdd for LabHue<T>where
T: SaturatingAdd<Output = T>,
impl<T> SaturatingAdd for LabHue<T>where
T: SaturatingAdd<Output = T>,
source§impl<T> SaturatingSub<T> for LabHue<T>where
T: SaturatingSub<Output = T>,
impl<T> SaturatingSub<T> for LabHue<T>where
T: SaturatingSub<Output = T>,
source§impl<T> SaturatingSub for LabHue<T>where
T: SaturatingSub<Output = T>,
impl<T> SaturatingSub for LabHue<T>where
T: SaturatingSub<Output = T>,
source§impl<T> Serialize for LabHue<T>where
T: Serialize,
impl<T> Serialize for LabHue<T>where
T: Serialize,
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl<T> SubAssign<T> for LabHue<T>where
T: SubAssign,
impl<T> SubAssign<T> for LabHue<T>where
T: SubAssign,
source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moresource§impl<T> SubAssign for LabHue<T>where
T: SubAssign,
impl<T> SubAssign for LabHue<T>where
T: SubAssign,
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>
source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
impl<T> Copy for LabHue<T>where
T: Copy,
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, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§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> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.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