ColorFmt

Trait ColorFmt 

Source
pub trait ColorFmt:
    ColorFmt
    + Debug
    + Copy
    + Hash
    + Eq
    + Ord
    + Display
    + Sized {
    type Raw: Copy + Hash + Eq + Ord + Default + Debug + Display + Send + Sync + Sized;
    type Component: Copy + Hash + Eq + Ord + Default + Debug + Display + Send + Sync + Sized;

    const RGB_BIT_WIDTH: u8;
    const ALPHA_BIT_WIDTH: u8;

    // Required methods
    fn decode(
        &self,
    ) -> (Self::Component, Self::Component, Self::Component, Self::Component);
    fn encode(
        red: Self::Component,
        green: Self::Component,
        blue: Self::Component,
        alpha: Self::Component,
    ) -> Self;
    fn invert_alpha(&mut self);
}
Expand description

Common interface for all suitable color formats within libplum.

This trait is sealed, so that it cannot be implemented on types other than those provided by this crate. It is provided as a convenience, for applications that wish to handle images of various formats.

Required Associated Constants§

Source

const RGB_BIT_WIDTH: u8

Number of bits allocated to red, green, and blue channels.

Source

const ALPHA_BIT_WIDTH: u8

Number of bits allocated to the alpha channel.

Required Associated Types§

Source

type Raw: Copy + Hash + Eq + Ord + Default + Debug + Display + Send + Sync + Sized

Type suitable for storing the whole colour.

Source

type Component: Copy + Hash + Eq + Ord + Default + Debug + Display + Send + Sync + Sized

Type suitable for storing each individual channel.

Required Methods§

Source

fn decode( &self, ) -> (Self::Component, Self::Component, Self::Component, Self::Component)

Breaks self down into its individual components.

Source

fn encode( red: Self::Component, green: Self::Component, blue: Self::Component, alpha: Self::Component, ) -> Self

Gathers individual components into Self.

Source

fn invert_alpha(&mut self)

Inverts the alpha channel.

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.

Implementors§