Enum palette::Color
[−]
[src]
pub enum Color { Luma(Luma), Rgb(Rgb), Xyz(Xyz), Lab(Lab), Lch(Lch), Hsv(Hsv), Hsl(Hsl), }
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)
Linear luminance.
Rgb(Rgb)
Linear RGB.
Xyz(Xyz)
CIE 1931 XYZ.
Lab(Lab)
CIE L*a*b* (CIELAB).
Lch(Lch)
CIE L*C*h°, a polar version of CIE L*a*b*.
Hsv(Hsv)
Linear HSV, a cylindrical version of RGB.
Hsl(Hsl)
Linear HSL, a cylindrical version of RGB.
Methods
impl Color
[src]
fn y(luma: f32) -> Color
Linear luminance.
fn ya(luma: f32, alpha: f32) -> Color
Linear luminance with transparency.
fn y8(luma: u8) -> Color
Linear luminance from an 8 bit value.
fn ya8(luma: u8, alpha: u8) -> Color
Linear luminance and transparency from 8 bit values.
impl Color
[src]
fn linear_rgb(red: f32, green: f32, blue: f32) -> Color
Linear RGB.
fn linear_rgba(red: f32, green: f32, blue: f32, alpha: f32) -> Color
Linear RGB and transparency.
fn linear_rgb8(red: u8, green: u8, blue: u8) -> Color
Linear RGB from 8 bit values.
fn linear_rgba8(red: u8, green: u8, blue: u8, alpha: u8) -> Color
Linear RGB and transparency from 8 bit values.
fn linear_pixel<P: RgbPixel>(pixel: &P) -> Color
Linear RGB from a linear pixel value.
fn srgb(red: f32, green: f32, blue: f32) -> Color
Linear RGB from sRGB.
fn srgba(red: f32, green: f32, blue: f32, alpha: f32) -> Color
Linear RGB from sRGB with transparency.
fn srgb8(red: u8, green: u8, blue: u8) -> Color
Linear RGB from 8 bit sRGB.
fn srgba8(red: u8, green: u8, blue: u8, alpha: u8) -> Color
Linear RGB from 8 bit sRGB with transparency.
fn srgb_pixel<P: RgbPixel>(pixel: &P) -> Color
Linear RGB from an sRGB pixel value.
fn gamma_rgb(red: f32, green: f32, blue: f32, gamma: f32) -> Color
Linear RGB from gamma corrected RGB.
fn gamma_rgba(red: f32, green: f32, blue: f32, alpha: f32, gamma: f32) -> Color
Linear RGB from gamma corrected RGB with transparency.
fn gamma_rgb8(red: u8, green: u8, blue: u8, gamma: f32) -> Color
Linear RGB from 8 bit gamma corrected RGB.
fn gamma_rgba8(red: u8, green: u8, blue: u8, alpha: u8, gamma: f32) -> Color
Linear RGB from 8 bit gamma corrected RGB with transparency.
fn gamma_pixel<P: RgbPixel>(pixel: &P, gamma: f32) -> Color
Linear RGB from a gamma corrected pixel value.
impl Color
[src]
fn xyz(x: f32, y: f32, z: f32) -> Color
CIE XYZ.
fn xyza(x: f32, y: f32, z: f32, alpha: f32) -> Color
CIE XYZ and transparency.
impl Color
[src]
fn lab(l: f32, a: f32, b: f32) -> Color
CIE L*a*b*.
fn laba(l: f32, a: f32, b: f32, alpha: f32) -> Color
CIE L*a*b* and transparency.
impl Color
[src]
fn lch(l: f32, chroma: f32, hue: LabHue) -> Color
CIE L*C*h°.
fn lcha(l: f32, chroma: f32, hue: LabHue, alpha: f32) -> Color
CIE L*C*h° and transparency.
impl Color
[src]
fn hsv(hue: RgbHue, saturation: f32, value: f32) -> Color
Linear HSV.
fn hsva(hue: RgbHue, saturation: f32, value: f32, alpha: f32) -> Color
Linear HSV and transparency.
impl Color
[src]
fn hsl(hue: RgbHue, saturation: f32, lightness: f32) -> Color
Linear HSL.
fn hsla(hue: RgbHue, saturation: f32, lightness: f32, alpha: f32) -> Color
Linear HSL and transparency.
Trait Implementations
impl Debug for Color
[src]
impl Copy for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
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 Mix for Color
[src]
fn mix(&self, other: &Color, factor: f32) -> Color
Mix the color with an other color, by factor
. Read more
impl Shade for Color
[src]
fn lighten(&self, amount: f32) -> Color
Lighten the color by amount
.
fn darken(&self, amount: f32) -> Self
Darken the color by amount
.
impl GetHue for Color
[src]
type Hue = LabHue
The kind of hue unit this color space uses. Read more
fn get_hue(&self) -> Option<LabHue>
Calculate a hue if possible. Read more
impl Hue for Color
[src]
fn with_hue(&self, hue: LabHue) -> Color
Return a new copy of self
, but with a specific hue.
fn shift_hue(&self, amount: LabHue) -> Color
Return a new copy of self
, but with the hue shifted by amount
.
impl Saturate for Color
[src]
fn saturate(&self, factor: f32) -> Color
Increase the saturation by factor
.
fn desaturate(&self, factor: f32) -> Self
Decrease the saturation by factor
.