Trait palette::Component

source ·
pub trait Component: Copy + Zero + PartialOrd + NumCast {
    const LIMITED: bool;

    // Required methods
    fn max_intensity() -> Self;
    fn convert<T: Component>(&self) -> T;
}
Expand description

Common trait for color components.

Required Associated Constants§

source

const LIMITED: bool

True if the max intensity is also the highest possible value of the type. Conversion to limited types requires clamping.

Required Methods§

source

fn max_intensity() -> Self

The highest displayable value this component type can reach. Higher values are allowed, but they may be lowered to this before converting to another format.

source

fn convert<T: Component>(&self) -> T

Convert into another color component type, including scaling.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Component for f32

source§

const LIMITED: bool = false

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

source§

impl Component for f64

source§

const LIMITED: bool = false

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

source§

impl Component for u8

source§

const LIMITED: bool = true

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

source§

impl Component for u16

source§

const LIMITED: bool = true

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

source§

impl Component for u32

source§

const LIMITED: bool = true

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

source§

impl Component for u64

source§

const LIMITED: bool = true

source§

fn max_intensity() -> Self

source§

fn convert<T: Component>(&self) -> T

Implementors§