Struct palette::pixel::GammaRgb [] [src]

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

A gamma encoded color.

Gamma encoding or gamma correction is used to transform the intensity values to either match a non-linear display, like CRT, or to prevent banding among the darker colors. GammaRgb represents a gamma corrected RGB color, where the intensities are encoded using the following power-law expression: V γ (where V is the intensity value an γ is the encoding gamma).

This particular implementation is based on the ITU-R BT.709 primaries (same as in sRGB, HDTV, etc.), so decoding it will basically result in decoded sRGB.

use palette::Rgb;
use palette::pixel::GammaRgb;

let c: Rgb = GammaRgb::new_u8(128, 64, 32, 2.2).into();
assert_eq!((128, 64, 32), GammaRgb::linear_to_pixel(c, 2.2));

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 decoding gamma value. Commonly 2.2.

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

Methods

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

Create a new opaque gamma encoded color.

Create a new gamma encoded color with transparency.

Create a new opaque gamma encoded color from u8 values.

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

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

Create a new opaque gamma encoded color.

Create a new gamma encoded color with transparency.

Create a new opaque gamma encoded color from u8 values.

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

Create a new gamma encoded color from a pixel value.

Transform this color into a pixel representation.

Convert linear color components to gamma encoding.

Decode this color to a linear representation.

Shortcut to convert a linear color to a gamma encoded pixel.

Trait Implementations

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

Formats the value using the given formatter.

impl<Wp: PartialEq, T: PartialEq> PartialEq for GammaRgb<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 GammaRgb<Wp, T> where
    T: Float,
    Wp: WhitePoint<T>, 
[src]

impl<Wp, T> Clone for GammaRgb<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> ApproxEq for GammaRgb<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.