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: 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: Copy + Float> Copy for Srgb<T>
[src]
impl<T: Debug + Float> Debug for Srgb<T>
[src]
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: Float> From<Rgb<T>> for Srgb<T>
[src]
impl<T: Float> From<Rgba<T>> for Srgb<T>
[src]
impl<T: Float> From<Color<T>> for Srgb<T>
[src]
impl<T: Float + ApproxEq> ApproxEq for Srgb<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
.