[][src]Struct Color::RGB

pub struct RGB(pub [u8; 3]);

Create new rgb.

    let rgb = RGB([0, 0, 0]);

Implementations

impl RGB[src]

pub fn value(&self) -> [u8; 3][src]

pub fn inverted(&mut self) -> &mut Self[src]

inverted rgb color.

    let inverted_rgb = rgb.inverted();
    assert_eq!([255, 255, 255], rgb.0);

pub fn to_hex(&self) -> String[src]

convart rgb to hex.

    let color_hex = rgb.to_hex();
    assert_eq!("ffffff", color_hex);

pub fn contrast_ratio(&self, rgb: [u8; 3]) -> f64[src]

Get contrast ratio.

    let contrast = rgb.contrast_ratio([0, 0, 0]);
    assert_eq!(21, contrast);

pub fn from_hex(hex_value: &str) -> Result<Self, &str>[src]

Create RGB from hex.

    let rgb2 = RGB::from_hex("#00ff00");
    assert_eq!([0, 255, 00], rgb2.0);

Trait Implementations

impl Debug for RGB[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.