[][src]Trait riddle_common::ColorElementConversion

pub trait ColorElementConversion<T> {
    fn convert(&self) -> T;
}

Define the mapping between two ColorElement types.

Implemented by both individual color channel types, and compound types like Color.

Required methods

fn convert(&self) -> T

Given a value that implements this trait, produce an equivalent color element of the destination type.

Example

// Convert a float color channel value in to a byte color channel value.
let byte_val: u8 = 255;
let float_val: f32 = 1.0;
assert_eq!(byte_val, float_val.convert());
Loading content...

Implementations on Foreign Types

impl ColorElementConversion<f32> for u8[src]

impl ColorElementConversion<u8> for u8[src]

impl ColorElementConversion<u8> for f32[src]

impl ColorElementConversion<f32> for f32[src]

Loading content...

Implementors

impl<T: ColorElement, F: ColorElementConversion<T>> ColorElementConversion<Color<T>> for Color<F>[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);
Loading content...