Enum palette::Color
[−]
[src]
pub enum Color<T: Float = f32> { Luma(Luma<T>), Rgb(Rgb<T>), Xyz(Xyz<T>), Lab(Lab<T>), Lch(Lch<T>), Hsv(Hsv<T>), Hsl(Hsl<T>), }
A generic color type.
The Color
may belong to any color space and it may change
depending on which operation is performed. That makes it immune to
the "without conversion" rule of the operations it supports. The
color spaces are selected as follows:
Mix
: RGB for no particular reason, except that it's intuitive.Shade
: CIE L*a*b* for its luminance component.Hue
andGetHue
: CIE L*C*h° for its hue component and how it preserves the apparent lightness.Saturate
: CIE L*C*h° for its chromaticity component and how it preserves the apparent lightness.
It's not recommended to use Color
when full control is necessary,
but it can easily be converted to a fixed color space in those
cases.
Variants
Luma(Luma<T>)
Linear luminance.
Rgb(Rgb<T>)
Linear RGB.
Xyz(Xyz<T>)
CIE 1931 XYZ.
Lab(Lab<T>)
CIE L*a*b* (CIELAB).
Lch(Lch<T>)
CIE L*C*h°, a polar version of CIE L*a*b*.
Hsv(Hsv<T>)
Linear HSV, a cylindrical version of RGB.
Hsl(Hsl<T>)
Linear HSL, a cylindrical version of RGB.
Methods
impl<T: Float> Color<T>
[src]
fn y(luma: T) -> Color<T>
Linear luminance.
fn y_u8(luma: u8) -> Color<T>
Linear luminance from an 8 bit value.
fn rgb(red: T, green: T, blue: T) -> Color<T>
Linear RGB.
fn rgb_u8(red: u8, green: u8, blue: u8) -> Color<T>
Linear RGB from 8 bit values.
fn xyz(x: T, y: T, z: T) -> Color<T>
CIE XYZ.
fn lab(l: T, a: T, b: T) -> Color<T>
CIE L*a*b*.
fn lch(l: T, chroma: T, hue: LabHue<T>) -> Color<T>
CIE L*C*h°.
fn hsv(hue: RgbHue<T>, saturation: T, value: T) -> Color<T>
Linear HSV.
fn hsl(hue: RgbHue<T>, saturation: T, lightness: T) -> Color<T>
Linear HSL.
Trait Implementations
impl<T: Debug + Float> Debug for Color<T>
[src]
impl<T: Copy + Float> Copy for Color<T>
[src]
impl<T: Clone + Float> Clone for Color<T>
[src]
fn clone(&self) -> Color<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Float> Mix for Color<T>
[src]
type Scalar = T
The type of the mixing factor.
fn mix(&self, other: &Color<T>, factor: T) -> Color<T>
Mix the color with an other color, by factor
. Read more
impl<T: Float> Shade for Color<T>
[src]
type Scalar = T
The type of the lighten/darken amount.
fn lighten(&self, amount: T) -> Color<T>
Lighten the color by amount
.
fn darken(&self, amount: Self::Scalar) -> Self
Darken the color by amount
.
impl<T: Float> GetHue for Color<T>
[src]
type Hue = LabHue<T>
The kind of hue unit this color space uses. Read more
fn get_hue(&self) -> Option<LabHue<T>>
Calculate a hue if possible. Read more
impl<T: Float> Hue for Color<T>
[src]
fn with_hue(&self, hue: LabHue<T>) -> Color<T>
Return a new copy of self
, but with a specific hue.
fn shift_hue(&self, amount: LabHue<T>) -> Color<T>
Return a new copy of self
, but with the hue shifted by amount
.
impl<T: Float> Saturate for Color<T>
[src]
type Scalar = T
The type of the (de)saturation factor.
fn saturate(&self, factor: T) -> Color<T>
Increase the saturation by factor
.
fn desaturate(&self, factor: Self::Scalar) -> Self
Decrease the saturation by factor
.