Struct smol_rgb::LinearRgb[][src]

pub struct LinearRgb {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

This is a Color in the linear space. This represents “linear sRGB”. You should use this color space when blending colors on the CPU or when sending uniforms to a linear card.

Colors on disc are EncodedRgb, but to blend them correctly, you need to move them into the linear color space with to_linear.

You can directly create this struct, but you probably don’t want to. You’d need already linear sRGB to correctly make this struct – that’s possible to have, but generally, textures, color pickers (like photoshop), and outputted surface (like if you use a Color Picker on a game) will all be in the encoded RGB space. Exceptions abound though, so it is possible to directly create this color.

Fields

r: f32

The red component of the color.

g: f32

The green component of the color.

b: f32

The blue component of the color.

a: f32

The alpha component of the color, normally the opacity in blending operations.

Implementations

impl LinearRgb[src]

pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self[src]

You probably don’t want to use this function. This creates a color in the LinearColor space directly. For this function to be valid, the colors given to this function must be in the linear space already.

pub fn to_encoded_space(self) -> EncodedRgb[src]

Transforms this color into the Encoded color space. Use this space to serialize colors.

pub fn to_array(self) -> [f32; 4][src]

Creates an array representation of the color. This is useful for sending the color to a uniform, but is the same memory representation as Self. LinearRgb also implements Into, but this function is often more convenient.

pub fn to_bits(self) -> [u8; 16][src]

Encodes the 4 floats as 16 u8s. This is useful for sending the color to a uniform, but is the same memory representation as Self – ie, the bits have just been reinterpreted as 16 u8s, but they’re still secret floats.

Trait Implementations

impl Clone for LinearRgb[src]

impl Copy for LinearRgb[src]

impl Debug for LinearRgb[src]

impl Default for LinearRgb[src]

impl Display for LinearRgb[src]

impl From<[f32; 4]> for LinearRgb[src]

impl From<(f32, f32, f32, f32)> for LinearRgb[src]

impl From<EncodedRgb> for LinearRgb[src]

impl From<LinearRgb> for EncodedRgb[src]

impl Into<[f32; 4]> for LinearRgb[src]

impl Into<(f32, f32, f32, f32)> for LinearRgb[src]

impl PartialEq<LinearRgb> for LinearRgb[src]

impl PartialOrd<LinearRgb> for LinearRgb[src]

impl StructuralPartialEq for LinearRgb[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.