Struct riddle_image::Color[][src]

#[repr(C)]pub struct Color<E> {
    pub r: E,
    pub g: E,
    pub b: E,
    pub a: E,
}

An RGBA color, parameterized over color channel type.

The two supported channel types are u8 and f32.

Example

let c = Color{ r: 1.0, g: 0.0, b: 0.0, a: 1.0 };

Fields

r: E

Red

g: E

Green

b: E

Blue

a: E

Alpha

Implementations

impl<E> Color<E> where
    E: ColorElement
[src]

pub const RED: Color<E>[src]

Opaque primary red

pub const GREEN: Color<E>[src]

Opaque primary green

pub const BLUE: Color<E>[src]

Opaque primary blue

pub const BLACK: Color<E>[src]

Opaque black

pub const WHITE: Color<E>[src]

Opaque white

pub const TRANSPARENT_BLACK: Color<E>[src]

Transparent black

pub const ZERO: Color<E>[src]

Transparent black

pub fn rgba(r: E, g: E, b: E, a: E) -> Color<E>[src]

Example

let c = Color::rgba(1.0, 0.0, 0.0, 1.0);

pub fn rgb(r: E, g: E, b: E) -> Color<E>[src]

Example

let c = Color::rgb(1.0, 0.0, 0.0);
assert_eq!(Color::rgba(1.0, 0.0, 0.0, 1.0), c);

Trait Implementations

impl<E> Clone for Color<E> where
    E: Clone
[src]

impl<T, F> ColorElementConversion<Color<T>> for Color<F> where
    T: ColorElement,
    F: ColorElementConversion<T>, 
[src]

Support converting colors between element types

Example

let a: Color<f32> = Color::RED;
let b: Color<u8> = Color::RED;
let a_converted: Color<u8> = a.convert();
assert_eq!(b, a_converted);

impl<E> Debug for Color<E> where
    E: Debug
[src]

impl<E> Eq for Color<E> where
    E: PartialEq<E>, 
[src]

impl<E> From<[E; 3]> for Color<E> where
    E: ColorElement
[src]

impl<E> From<[E; 4]> for Color<E> where
    E: ColorElement
[src]

impl<E> PartialEq<Color<E>> for Color<E> where
    E: PartialEq<E>, 
[src]

Auto Trait Implementations

impl<E> RefUnwindSafe for Color<E> where
    E: RefUnwindSafe

impl<E> Send for Color<E> where
    E: Send

impl<E> Sync for Color<E> where
    E: Sync

impl<E> Unpin for Color<E> where
    E: Unpin

impl<E> UnwindSafe for Color<E> where
    E: UnwindSafe

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> 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.