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

pub struct Srgb<T: Float = f32> {
    pub red: T,
    pub green: T,
    pub blue: T,
    pub alpha: T,
}

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.

use palette::Rgb;
use palette::pixel::Srgb;

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

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.

Methods

impl<T: Float> Srgb<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<T: Clone + Float> Clone for Srgb<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Copy + Float> Copy for Srgb<T>
[src]

impl<T: Debug + Float> Debug for Srgb<T>
[src]

Formats the value using the given formatter.

impl<T: PartialEq + Float> PartialEq for Srgb<T>
[src]

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

This method tests for !=.

impl<T: Float> From<Rgb<T>> for Srgb<T>
[src]

Performs the conversion.

impl<T: Float> From<Rgba<T>> for Srgb<T>
[src]

Performs the conversion.

impl<T: Float> From<Color<T>> for Srgb<T>
[src]

Performs the conversion.

impl<T: Float + ApproxEq> ApproxEq for Srgb<T> where
    T::Epsilon: Copy + Float
[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.