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

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

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.

Methods

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

Formats the value using the given formatter.

impl<T: PartialEq + Float> PartialEq for GammaRgb<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 + ApproxEq> ApproxEq for GammaRgb<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.