Struct palette::pixel::Srgb [] [src]

pub struct Srgb<Wp = D65, T = f32> where
    T: Float,
    Wp: WhitePoint<T>, 
{ pub red: T, pub green: T, pub blue: T, pub alpha: T, pub white_point: PhantomData<Wp>, }

An sRGB encoded color.

sRGB is a common kind of gamma encoding, but it doesn't exactly follow the power-law, as in GammaRgb. It's perhaps the most common color space for monitors and on the Internet, so it's usually safe to assume that an image or pixel with unknown gamma is sRGB encoded.

#[macro_use] extern crate approx;

 let c: Rgb = Srgb::new(0.5, 0.3, 0.1).into();
 let (r, g, b) = Srgb::from(c).to_pixel();
 assert_relative_eq!(0.5f32, r);
 assert_relative_eq!(0.3f32, g);
 assert_relative_eq!(0.1f32, b);

Fields

The red component, where 0.0 is no red light and 1.0 is the highest displayable amount.

The green component, where 0.0 is no red light and 1.0 is the highest displayable amount.

The blue component, where 0.0 is no red light and 1.0 is the highest displayable amount.

The transparency of the color. 0.0 is completely transparent and 1.0 is completely opaque.

The white point associated with the color's illuminant and observer. D65 for 2 degree observer is used by default.

Methods

impl<T> Srgb<D65, T> where
    T: Float
[src]

Create a new opaque sRGB encoded color.

Create a new sRGB encoded color with transparency.

Create a new opaque sRGB encoded color from u8 values.

Create a new sRGB encoded color, with transparency, from u8 values.

impl<Wp, T> Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Create a new opaque sRGB encoded color.

Create a new sRGB encoded color with transparency.

Create a new opaque sRGB encoded color from u8 values.

Create a new sRGB encoded color, with transparency, from u8 values.

Create a new sRGB encoded color from a pixel value.

Transform this color into a pixel representation.

Convert linear color components to sRGB encoding.

Decode this color to a linear representation.

Shortcut to convert a linear color to an sRGB encoded pixel.

Trait Implementations

impl<Wp: Debug, T: Debug> Debug for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Formats the value using the given formatter.

impl<Wp: PartialEq, T: PartialEq> PartialEq for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<Wp, T> Copy for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

impl<Wp, T> Clone for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<Wp, T> From<Rgb<Wp, T>> for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Performs the conversion.

impl<Wp, T> From<Rgba<Wp, T>> for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Performs the conversion.

impl<Wp, T> From<Color<Wp, T>> for Srgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

Performs the conversion.

impl<Wp, T> ApproxEq for Srgb<Wp, T> where
    T: Float + ApproxEq,
    T::Epsilon: Copy + Float,
    Wp: WhitePoint<T>, 
[src]

Used for specifying relative comparisons.

The default tolerance to use when testing values that are close together. Read more

The default relative tolerance for testing values that are far-apart. Read more

The default ULPs to tolerate when testing values that are far-apart. Read more

A test for equality that uses a relative comparison if the values are far apart.

A test for equality that uses units in the last place (ULP) if the values are far apart.

The inverse of ApproxEq::relative_eq.

The inverse of ApproxEq::ulps_eq.