pub struct RGB(pub [u8; 3]);
Expand description
Create new rgb.
let rgb = RGB([0, 0, 0]);
Tuple Fields§
§0: [u8; 3]
Implementations§
Source§impl RGB
impl RGB
Sourcepub fn inverted(&mut self) -> &mut Self
pub fn inverted(&mut self) -> &mut Self
inverted rgb color.
let inverted_rgb = rgb.inverted();
assert_eq!([255, 255, 255], rgb.0);
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
convart rgb to hex.
let color_hex = rgb.to_hex();
assert_eq!("ffffff", color_hex);
Sourcepub fn contrast_ratio(&self, rgb: [u8; 3]) -> f64
pub fn contrast_ratio(&self, rgb: [u8; 3]) -> f64
Get contrast ratio.
let contrast = rgb.contrast_ratio([0, 0, 0]);
assert_eq!(21, contrast);
Auto Trait Implementations§
impl Freeze for RGB
impl RefUnwindSafe for RGB
impl Send for RGB
impl Sync for RGB
impl Unpin for RGB
impl UnwindSafe for RGB
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