Struct palette::pixel::Srgb [] [src]

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

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

Create a new opaque sRGB encoded color.

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

Create a new sRGB encoded color with transparency.

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

Create a new opaque sRGB encoded color from u8 values.

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

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

fn from_pixel<P: RgbPixel<T>>(pixel: &P) -> Srgb<T>

Create a new sRGB 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) -> Srgb<T>

Convert linear color components to sRGB 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) -> P

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

Trait Implementations

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

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

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

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

This method tests for !=.

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

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

Formats the value using the given formatter.

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

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

fn clone(&self) -> Srgb<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: Float> From<Rgb<T>> for Srgb<T>
[src]

fn from(rgb: Rgb<T>) -> Srgb<T>

Performs the conversion.

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

fn from(rgba: Rgba<T>) -> Srgb<T>

Performs the conversion.

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

fn from(color: Color<T>) -> Srgb<T>

Performs the conversion.