Trait colstodian::ColorInto[][src]

pub trait ColorInto<T> {
    fn into(self) -> T;
}
Expand description

A trait meant to be used as a replacement for Into in situations where you want to bound a type as being able to be converted into a specific type of color. Because of how colstodian works and how From/Into are implemented, we can’t use them directly for this purpose.

Example

use colstodian::*;

fn tint_color(input_color: impl ColorInto<Color<AcesCg, Display>>) -> Color<AcesCg, Display> {
    let color = input_color.into();
    let tint: Color<AcesCg, Display> = Color::new(0.5, 0.8, 0.4);
    color * tint
}

let color = color::srgb_u8(225, 200, 86);
let tinted: Color<EncodedSrgb, Display> = tint_color(color).convert();

println!("Pre-tint: {}, Post-tint: {}", color, tinted);

Required methods

Implementors