Struct picto::color::Srgb[][src]

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

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.

Implementations

Create a new opaque sRGB encoded color.

Create a new sRGB encoded color with transparency.

Create a new opaque sRGB encoded color from u8 values.

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

Create a new sRGB encoded color from a pixel value.

Transform this color into a pixel representation.

Convert linear color components to sRGB encoding.

Decode this color to a linear representation.

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

Trait Implementations

Used for specifying relative comparisons.

The default tolerance to use when testing values that are close together. Read more

The default relative tolerance for testing values that are far-apart. Read more

The default ULPs to tolerate when testing values that are far-apart. Read more

A test for equality that uses a relative comparison if the values are far apart.

A test for equality that uses units in the last place (ULP) if the values are far apart.

The inverse of ApproxEq::relative_eq.

The inverse of ApproxEq::ulps_eq.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

This method tests for !=.

The number of channels in the Pixel.

Read a Pixel from the slice.

Read a Pixel from the slice.

Read a Pixel from the slice.

Read a Pixel from the slice.

Read a Pixel from the slice.

Write the Pixel to the slice.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Sets value as a parameter of self.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.