Trait ColorComponent

Source
pub trait ColorComponent: Copy {
    const ZERO: Self;
    const HALF: Self;
    const MAX: Self;

    // Required methods
    fn as_f32(self) -> f32;
    fn from_f32(value: f32) -> Self;

    // Provided method
    fn convert<U>(self) -> U
       where U: ColorComponent { ... }
}

Required Associated Constants§

Source

const ZERO: Self

Source

const HALF: Self

Source

const MAX: Self

Required Methods§

Source

fn as_f32(self) -> f32

Source

fn from_f32(value: f32) -> Self

Provided Methods§

Source

fn convert<U>(self) -> U
where U: ColorComponent,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ColorComponent for f32

Source§

const ZERO: f32 = 0f32

Source§

const HALF: f32 = 0.5f32

Source§

const MAX: f32 = 1f32

Source§

fn as_f32(self) -> f32

Source§

fn from_f32(x: f32) -> f32

Source§

impl ColorComponent for f64

Source§

const ZERO: f64 = 0f64

Source§

const HALF: f64 = 0.5f64

Source§

const MAX: f64 = 1f64

Source§

fn as_f32(self) -> f32

Source§

fn from_f32(x: f32) -> f64

Source§

impl ColorComponent for u8

Source§

const ZERO: u8 = 0u8

Source§

const HALF: u8 = 127u8

Source§

const MAX: u8 = 255u8

Source§

fn as_f32(self) -> f32

Source§

fn from_f32(x: f32) -> u8

Implementors§