#[repr(C)]pub struct Hsl<T, A = Deg<T>> { /* private fields */ }Expand description
The HSL device-dependent polar color model

HSL is defined by a hue (base color), saturation (color richness) and value (whiteness).
Like HSV, HSL is modeled as a cylinder, however the underlying space is two cones
stacked bottom-to-bottom. /// This causes some level of
distortion and a degeneracy at S=0 or L={0,1}. Thus, while easy to reason about, it is not good for
perceptual uniformity. It does an okay job with averaging colors or doing other math, but prefer
the CIE spaces for uniform gradients.
Hsl takes two type parameters: the cartesian channel scalar, and an angular channel scalar.
Hsl is in the same color space and encoding as the parent RGB space, it is merely a geometric transformation and distortion.
For an undistorted device-dependent polar color model, look at Hsi.
Implementations§
Source§impl<T, A> Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Sourcepub fn new(hue: A, saturation: T, lightness: T) -> Self
pub fn new(hue: A, saturation: T, lightness: T) -> Self
Construct an Hsl instance from hue, saturation and lightness
Sourcepub fn color_cast<TOut, AOut>(&self) -> Hsl<TOut, AOut>where
T: ChannelFormatCast<TOut>,
A: ChannelFormatCast<AOut>,
AOut: AngularChannelScalar,
TOut: PosNormalChannelScalar,
pub fn color_cast<TOut, AOut>(&self) -> Hsl<TOut, AOut>where
T: ChannelFormatCast<TOut>,
A: ChannelFormatCast<AOut>,
AOut: AngularChannelScalar,
TOut: PosNormalChannelScalar,
Convert the internal channel scalar format
Sourcepub fn saturation(&self) -> T
pub fn saturation(&self) -> T
Returns the saturation scalar
Sourcepub fn saturation_mut(&mut self) -> &mut T
pub fn saturation_mut(&mut self) -> &mut T
Returns a mutable reference to the saturation scalar
Sourcepub fn lightness_mut(&mut self) -> &mut T
pub fn lightness_mut(&mut self) -> &mut T
Returns a mutable reference to the lightness scalar
Sourcepub fn set_saturation(&mut self, val: T)
pub fn set_saturation(&mut self, val: T)
Set the saturation channel value
Sourcepub fn set_lightness(&mut self, val: T)
pub fn set_lightness(&mut self, val: T)
Set the lightness channel value
Trait Implementations§
Source§impl<T, A> AbsDiffEq for Hsl<T, A>where
T: PosNormalChannelScalar + AbsDiffEq<Epsilon = A::Epsilon>,
A: AngularChannelScalar + AbsDiffEq,
A::Epsilon: Clone + Float,
impl<T, A> AbsDiffEq for Hsl<T, A>where
T: PosNormalChannelScalar + AbsDiffEq<Epsilon = A::Epsilon>,
A: AngularChannelScalar + AbsDiffEq,
A::Epsilon: Clone + Float,
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§impl<T, A> Bounded for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Bounded for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§impl<T, A> Color for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Color for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§type ChannelsTuple = (A, T, T)
type ChannelsTuple = (A, T, T)
Source§fn num_channels() -> u32
fn num_channels() -> u32
Source§fn to_tuple(self) -> Self::ChannelsTuple
fn to_tuple(self) -> Self::ChannelsTuple
Source§impl<T, A> EncodableColor for Hsl<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Turns<T>>,
impl<T, A> EncodableColor for Hsl<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Turns<T>>,
Source§fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
Source§fn linear(self) -> EncodedColor<Self, LinearEncoding>
fn linear(self) -> EncodedColor<Self, LinearEncoding>
Source§fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
Source§fn gamma_encoded<T: Float>(
self,
gamma: T,
) -> EncodedColor<Self, GammaEncoding<T>>
fn gamma_encoded<T: Float>( self, gamma: T, ) -> EncodedColor<Self, GammaEncoding<T>>
Source§impl<T, A> FromColor<Hsl<T, A>> for Rgb<T>
impl<T, A> FromColor<Hsl<T, A>> for Rgb<T>
Source§fn from_color(from: &Hsl<T, A>) -> Self
fn from_color(from: &Hsl<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hsl<T, A>
impl<T, A> FromColor<Rgb<T>> for Hsl<T, A>
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, A> FromTuple for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> FromTuple for Hsl<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§fn from_tuple(values: Self::ChannelsTuple) -> Self
fn from_tuple(values: Self::ChannelsTuple) -> Self
Self from a tuple of channel values