pub enum Color {
Rgb(u8, u8, u8),
Rgba(u8, u8, u8, u8),
RgbFloat(f32, f32, f32),
RgbaFloat(f32, f32, f32, f32),
Hex(String),
}Expand description
Unified color representation supporting multiple formats. Conversion happens lazily when accessing a specific format.
Variants§
Rgb(u8, u8, u8)
RGB as bytes [0-255]
Rgba(u8, u8, u8, u8)
RGBA as bytes [0-255]
RgbFloat(f32, f32, f32)
RGB as normalized floats [0.0-1.0]
RgbaFloat(f32, f32, f32, f32)
RGBA as normalized floats [0.0-1.0]
Hex(String)
Hex color string (with or without #)
Implementations§
Source§impl Color
impl Color
Sourcepub const fn rgba_float(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn rgba_float(r: f32, g: f32, b: f32, a: f32) -> Self
Create from RGBA floats [0.0-1.0]
Sourcepub fn as_rgb_float(&self) -> [f32; 3]
pub fn as_rgb_float(&self) -> [f32; 3]
Get as RGB float array [0.0-1.0]
Sourcepub fn as_rgba_float(&self) -> [f32; 4]
pub fn as_rgba_float(&self) -> [f32; 4]
Get as RGBA float array [0.0-1.0]
Sourcepub fn with_alpha(&self, alpha: f32) -> Self
pub fn with_alpha(&self, alpha: f32) -> Self
Create new color with specified alpha
Trait Implementations§
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 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