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

red: T

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

green: T

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

blue: T

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

alpha: T

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

gamma: T

The decoding gamma value. Commonly 2.2.

Methods

impl<T: Float> GammaRgb<T>
[src]

fn new(red: T, green: T, blue: T, gamma: T) -> GammaRgb<T>

Create a new opaque gamma encoded color.

fn with_alpha(red: T, green: T, blue: T, alpha: T, gamma: T) -> GammaRgb<T>

Create a new gamma encoded color with transparency.

fn new_u8(red: u8, green: u8, blue: u8, gamma: T) -> GammaRgb<T>

Create a new opaque gamma encoded color from u8 values.

fn with_alpha_u8(red: u8, green: u8, blue: u8, alpha: u8, gamma: T) -> GammaRgb<T>

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

fn from_pixel<P: RgbPixel<T>>(pixel: &P, gamma: T) -> GammaRgb<T>

Create a new gamma encoded color from a pixel value.

fn to_pixel<P: RgbPixel<T>>(&self) -> P

Transform this color into a pixel representation.

fn from_linear<C: Into<Rgba<T>>>(color: C, gamma: T) -> GammaRgb<T>

Convert linear color components to gamma encoding.

fn to_linear(&self) -> Rgba<T>

Decode this color to a linear representation.

fn linear_to_pixel<C: Into<Rgba<T>>, P: RgbPixel<T>>(color: C, gamma: T) -> P

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

Trait Implementations

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

fn eq(&self, __arg_0: &GammaRgb<T>) -> bool

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

fn ne(&self, __arg_0: &GammaRgb<T>) -> bool

This method tests for !=.

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

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

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

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

fn clone(&self) -> GammaRgb<T>

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