pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
An sRGB color with 8-bit channels.
Fields§
§r: u8§g: u8§b: u8Implementations§
Source§impl Color
impl Color
Sourcepub const fn from_hex(hex: u32) -> Self
pub const fn from_hex(hex: u32) -> Self
Create a color from a 24-bit hex value (e.g., 0xFF8800).
Sourcepub fn to_css_hex(self) -> String
pub fn to_css_hex(self) -> String
Format the color as a CSS hex string (e.g., "#ff8800").
Sourcepub fn contrast_ratio(self, other: Color) -> f64
pub fn contrast_ratio(self, other: Color) -> f64
WCAG contrast ratio between two colors.
Trait Implementations§
impl Copy for Color
impl Eq 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