pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
Color represented as RGB values
Fields§
§r: u8Red component (0-255)
g: u8Green component (0-255)
b: u8Blue component (0-255)
Implementations§
Source§impl Color
impl Color
Sourcepub fn relative_luminance(&self) -> f32
pub fn relative_luminance(&self) -> f32
Get the relative luminance (per WCAG 2.1)
Sourcepub fn contrast_ratio(&self, other: &Self) -> f32
pub fn contrast_ratio(&self, other: &Self) -> f32
Calculate contrast ratio with another color
Sourcepub fn meets_wcag_aa_normal(&self, other: &Self) -> bool
pub fn meets_wcag_aa_normal(&self, other: &Self) -> bool
Check if contrast meets WCAG AA for normal text
Sourcepub fn meets_wcag_aa_large(&self, other: &Self) -> bool
pub fn meets_wcag_aa_large(&self, other: &Self) -> bool
Check if contrast meets WCAG AA for large text
Sourcepub fn meets_wcag_aa_ui(&self, other: &Self) -> bool
pub fn meets_wcag_aa_ui(&self, other: &Self) -> bool
Check if contrast meets WCAG AA for UI components
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.