[][src]Struct linfb::shape::Color

pub struct Color {
    pub red: u8,
    pub green: u8,
    pub blue: u8,
    pub alpha: u8,
}

RGBA color used in many places in the library. Alpha channel is [0-255], not [0-1].

Can be created from 4-tuple of u8, 3-tuple of u8 (assuming 255 in alpha channel) and hex string:

// All of these are equivalent:
let c1: Color = (128, 128, 128).into();
let c2: Color = (128, 128, 128, 255).into();
let c3: Color = "#808080".try_into().unwrap();
let c4: Color = "#808080ff".try_into().unwrap();

Can be multiplied to [0, 1] f32 coefficient, which affects every channel besides alpha:

let color: Color = (128, 128, 128, 128).into(); // All channels set to 128
assert_eq!(color * 0.5, (64, 64, 64, 128).into());

Fields

red: u8green: u8blue: u8alpha: u8

Methods

impl Color[src]

pub fn hex(color_string: &str) -> Result<Self>[src]

Create Color object from hex string. Equivalent to .try_into() on string slice:

let c1: Color = "#112233".try_into().unwrap();
let c2: Color = Color::hex("#112233").unwrap();
assert_eq!(c1, c2);
let c3: Color = "#11223344".try_into().unwrap();
let c3: Color = Color::hex("#11223344").unwrap();
assert_eq!(c1, c2);

Trait Implementations

impl From<(u8, u8, u8)> for Color[src]

impl From<(u8, u8, u8, u8)> for Color[src]

impl Clone for Color[src]

impl Copy for Color[src]

impl Eq for Color[src]

impl PartialEq<Color> for Color[src]

impl Debug for Color[src]

impl<'_> TryFrom<&'_ str> for Color[src]

type Error = Error

The type returned in the event of a conversion error.

impl Mul<f32> for Color[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<f32> for Color[src]

Auto Trait Implementations

impl Send for Color

impl Sync for Color

impl Unpin for Color

impl UnwindSafe for Color

impl RefUnwindSafe for Color

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<T> SetParameter for T

impl<T> Downcast for T where
    T: Any
[src]