Trait image2::Color

source ·
pub trait Color: Unpin + PartialEq + Eq + PartialOrd + Ord + Clone + Sync + Send + Debug {
    const NAME: &'static str;
    const CHANNELS: Channel;
    const ALPHA: Option<Channel> = None;

    // Required methods
    fn to_rgb(src: &Pixel<Self>, dest: &mut Pixel<Rgb>);
    fn from_rgb(pixel: &Pixel<Rgb>, dest: &mut Pixel<Self>);

    // Provided method
    fn convert<ToColor: Color>(src: &Pixel<Self>, dest: &mut Pixel<ToColor>) { ... }
}
Expand description

Color trait is used to define color spaces

Required Associated Constants§

source

const NAME: &'static str

Color name

source

const CHANNELS: Channel

Number of channels

Provided Associated Constants§

source

const ALPHA: Option<Channel> = None

Index of alpha channel

Required Methods§

source

fn to_rgb(src: &Pixel<Self>, dest: &mut Pixel<Rgb>)

Convert from Self -> Rgb

source

fn from_rgb(pixel: &Pixel<Rgb>, dest: &mut Pixel<Self>)

Convert from Rgb -> Self

Provided Methods§

source

fn convert<ToColor: Color>(src: &Pixel<Self>, dest: &mut Pixel<ToColor>)

Convert a single channel of a color to another color

Implementors§

source§

impl Color for Cmyk

source§

const NAME: &'static str = "cmyk"

source§

const CHANNELS: Channel = 4usize

source§

impl Color for Gray

source§

const NAME: &'static str = "gray"

source§

const CHANNELS: Channel = 1usize

source§

impl Color for Hsv

source§

const NAME: &'static str = "hsv"

source§

const CHANNELS: Channel = 3usize

source§

impl Color for Rgb

source§

const NAME: &'static str = "rgb"

source§

const CHANNELS: Channel = 3usize

source§

impl Color for Rgba

source§

const NAME: &'static str = "rgba"

source§

const CHANNELS: Channel = 4usize

source§

const ALPHA: Option<Channel> = _

source§

impl Color for Srgb

source§

const NAME: &'static str = "rgb"

source§

const CHANNELS: Channel = 3usize

source§

impl Color for Srgba

source§

const NAME: &'static str = "rgba"

source§

const CHANNELS: Channel = 4usize

source§

const ALPHA: Option<Channel> = _

source§

impl Color for Xyz

source§

const NAME: &'static str = "xyz"

source§

const CHANNELS: Channel = 3usize

source§

impl Color for Yuv

source§

const NAME: &'static str = "yuv"

source§

const CHANNELS: Channel = 3usize