[][src]Struct nannou::color::pixel::GammaRgb

pub struct GammaRgb<T = f32> where
    T: Float
{ 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> GammaRgb<T> where
    T: Float
[src]

pub fn new(red: T, green: T, blue: T, gamma: T) -> GammaRgb<T>[src]

Create a new opaque gamma encoded color.

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

Create a new gamma encoded color with transparency.

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

Create a new opaque gamma encoded color from u8 values.

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

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

pub fn from_pixel<P>(pixel: &P, gamma: T) -> GammaRgb<T> where
    P: RgbPixel<T>, 
[src]

Create a new gamma encoded color from a pixel value.

pub fn to_pixel<P>(&self) -> P where
    P: RgbPixel<T>, 
[src]

Transform this color into a pixel representation.

pub fn from_linear<C>(color: C, gamma: T) -> GammaRgb<T> where
    C: Into<Alpha<Rgb<T>, T>>, 
[src]

Convert linear color components to gamma encoding.

pub fn to_linear(&self) -> Alpha<Rgb<T>, T>[src]

Decode this color to a linear representation.

pub fn linear_to_pixel<C, P>(color: C, gamma: T) -> P where
    C: Into<Alpha<Rgb<T>, T>>,
    P: RgbPixel<T>, 
[src]

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

Trait Implementations

impl<T> ApproxEq for GammaRgb<T> where
    T: ApproxEq + Float,
    <T as ApproxEq>::Epsilon: Copy,
    <T as ApproxEq>::Epsilon: Float
[src]

type Epsilon = <T as ApproxEq>::Epsilon

Used for specifying relative comparisons.

impl<T> From<GammaRgb<T>> for Alpha<Rgb<T>, T> where
    T: Float
[src]

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

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

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

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

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

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

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<T> Send for GammaRgb<T> where
    T: Send

impl<T> Sync for GammaRgb<T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Style for T where
    T: Any + Debug + PartialEq<T>, 
[src]

impl<T> Content for T[src]

impl<T> SafeBorrow<T> for T[src]

impl<T> Erased for T

impl<S> FromSample<S> for S[src]

impl<T, U> ToSample<U> for T where
    U: FromSample<T>, 
[src]

impl<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.