Struct smol_rgb::LinearRgb [−][src]
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]
fn from(o: EncodedRgb) -> Self
[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]
fn partial_cmp(&self, other: &LinearRgb) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralPartialEq for LinearRgb
[src]
Auto Trait Implementations
impl RefUnwindSafe for LinearRgb
impl Send for LinearRgb
impl Sync for LinearRgb
impl Unpin for LinearRgb
impl UnwindSafe for LinearRgb
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,