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>
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: 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
impl<T: Copy + Float> Copy for GammaRgb<T>
[src]
impl<T: Debug + Float> Debug for GammaRgb<T>
[src]
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: Float + ApproxEq> ApproxEq for GammaRgb<T> where
T::Epsilon: Copy + Float,
[src]
T::Epsilon: Copy + Float,
type Epsilon = <T as ApproxEq>::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
A test for equality that uses units in the last place (ULP) if the values are far apart.
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
The inverse of ApproxEq::ulps_eq
.