Trait rasterize::Color

source ·
pub trait Color: Copy {
    // Required methods
    fn blend_over(self, other: Self) -> Self;
    fn with_alpha(self, alpha: Scalar) -> Self;
    fn to_rgba(self) -> [u8; 4];
    fn lerp(self, other: Self, t: f32) -> Self;

    // Provided methods
    fn to_rgb(self) -> [u8; 3] { ... }
    fn luma(self) -> f32 { ... }
    fn best_contrast(self, c0: Self, c1: Self) -> Self { ... }
}
Expand description

Common interface to all color representations

Required Methods§

source

fn blend_over(self, other: Self) -> Self

Blend other color on top of this color

source

fn with_alpha(self, alpha: Scalar) -> Self

Override alpha component of the color

source

fn to_rgba(self) -> [u8; 4]

Convert color to sRGBA list

source

fn lerp(self, other: Self, t: f32) -> Self

Linear interpolation between self and other colors.

Provided Methods§

source

fn to_rgb(self) -> [u8; 3]

Convert color to sRGB list (alpha is discarded)

source

fn luma(self) -> f32

Calculate LUMA of the color.

source

fn best_contrast(self, c0: Self, c1: Self) -> Self

Pick color that produces the best contrast with self

Object Safety§

This trait is not object safe.

Implementors§