pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
sRGB color with straight (non-premultiplied) alpha, components in 0..=1.
Interpolation (Lerp) happens in OKLab.
Fields§
§r: f32Red, 0..=1 (sRGB-encoded).
g: f32Green, 0..=1.
b: f32Blue, 0..=1.
a: f32Alpha (straight, not premultiplied), 0..=1.
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Color
pub const TRANSPARENT: Color
Fully transparent black.
Sourcepub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
Color from 0..=1 components with alpha.
Sourcepub const fn from_hex(hex: &str) -> Option<Self>
pub const fn from_hex(hex: &str) -> Option<Self>
Parses #rgb, #rgba, #rrggbb or #rrggbbaa (the # is optional).
Sourcepub fn with_alpha(self, a: f32) -> Self
pub fn with_alpha(self, a: f32) -> Self
The same color with another alpha.
Sourcepub fn to_oklab(self) -> [f32; 3]
pub fn to_oklab(self) -> [f32; 3]
Converts to OKLab [L, a, b], the space colors are interpolated in.
Sourcepub fn from_oklab([ll, a, b]: [f32; 3], alpha: f32) -> Self
pub fn from_oklab([ll, a, b]: [f32; 3], alpha: f32) -> Self
Converts from OKLab [L, a, b].
Trait Implementations§
impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more