[−][src]Struct nannou::color::pixel::GammaRgb
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]
T: Float,
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]
red: u8,
green: u8,
blue: u8,
alpha: u8,
gamma: T
) -> GammaRgb<T>
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]
P: RgbPixel<T>,
Create a new gamma encoded color from a pixel value.
pub fn to_pixel<P>(&self) -> P where
P: RgbPixel<T>,
[src]
P: RgbPixel<T>,
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]
C: Into<Alpha<Rgb<T>, T>>,
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]
C: Into<Alpha<Rgb<T>, T>>,
P: RgbPixel<T>,
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]
T: ApproxEq + Float,
<T as ApproxEq>::Epsilon: Copy,
<T as ApproxEq>::Epsilon: Float,
type Epsilon = <T as ApproxEq>::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> <GammaRgb<T> as ApproxEq>::Epsilon
[src]
fn default_max_relative() -> <GammaRgb<T> as ApproxEq>::Epsilon
[src]
fn default_max_ulps() -> u32
[src]
fn relative_eq(
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_relative: <GammaRgb<T> as ApproxEq>::Epsilon
) -> bool
[src]
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_relative: <GammaRgb<T> as ApproxEq>::Epsilon
) -> bool
fn ulps_eq(
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
fn relative_ne(
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_relative: <GammaRgb<T> as ApproxEq>::Epsilon
) -> bool
[src]
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_relative: <GammaRgb<T> as ApproxEq>::Epsilon
) -> bool
fn ulps_ne(
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &GammaRgb<T>,
epsilon: <GammaRgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
impl<T> From<GammaRgb<T>> for Alpha<Rgb<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<GammaRgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<GammaRgb<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> Debug for GammaRgb<T> where
T: Debug + Float,
[src]
T: Debug + Float,
impl<T> Copy for GammaRgb<T> where
T: Copy + Float,
[src]
T: Copy + Float,
impl<T> PartialEq<GammaRgb<T>> for GammaRgb<T> where
T: PartialEq<T> + Float,
[src]
T: PartialEq<T> + Float,
impl<T> Clone for GammaRgb<T> where
T: Clone + Float,
[src]
T: Clone + Float,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Style for T where
T: Any + Debug + PartialEq<T>,
[src]
T: Any + Debug + PartialEq<T>,
impl<T> Content for T
[src]
fn ref_from_ptr(ptr: *mut c_void, size: usize) -> Option<*mut T>
[src]
fn is_size_suitable(size: usize) -> bool
[src]
fn indiv_size() -> usize
[src]
impl<T> SafeBorrow<T> for T
[src]
impl<T> Erased for T
impl<S> FromSample<S> for S
[src]
fn from_sample_(s: S) -> S
[src]
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
[src]
U: FromSample<T>,
fn to_sample_(self) -> U
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
[src]
T: FromSample<S> + ToSample<S>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
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>,
T: Parameter<Self>,
Sets value
as a parameter of self
.