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

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

An sRGB encoded color.

sRGB is a common kind of gamma encoding, but it doesn't exactly follow the power-law, as in GammaRgb. It's perhaps the most common color space for monitors and on the Internet, so it's usually safe to assume that an image or pixel with unknown gamma is sRGB encoded.

use palette::Rgb;
use palette::pixel::Srgb;

let c: Rgb = Srgb::new(0.5, 0.3, 0.1).into();
assert_eq!((0.5f32, 0.3, 0.1), Srgb::from(c).to_pixel());

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.

Methods

impl<T> Srgb<T> where
    T: Float
[src]

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

Create a new opaque sRGB encoded color.

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

Create a new sRGB encoded color with transparency.

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

Create a new opaque sRGB encoded color from u8 values.

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

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

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

Create a new sRGB 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) -> Srgb<T> where
    C: Into<Alpha<Rgb<T>, T>>, 
[src]

Convert linear color components to sRGB 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) -> P where
    C: Into<Alpha<Rgb<T>, T>>,
    P: RgbPixel<T>, 
[src]

Shortcut to convert a linear color to an sRGB encoded pixel.

Trait Implementations

impl<T> ApproxEq for Srgb<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<Srgb<T>> for Color<T> where
    T: Float
[src]

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

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

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

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

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

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

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

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

impl<T> Clone for Srgb<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 Srgb<T> where
    T: Send

impl<T> Sync for Srgb<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.