[−][src]Trait valora::prelude::ConvertInto
A trait for converting a color into another.
Required methods
fn convert_into(self) -> T
Convert into T with values clamped to the color defined bounds
use palette::ConvertInto; use palette::Limited; use palette::{Srgb, Lch}; let rgb: Srgb = Lch::new(50.0, 100.0, -175.0).convert_into(); assert!(rgb.is_valid());
fn convert_unclamped_into(self) -> T
Convert into T. The resulting color might be invalid in its color space
use palette::ConvertInto; use palette::Limited; use palette::{Srgb, Lch}; let rgb: Srgb = Lch::new(50.0, 100.0, -175.0).convert_unclamped_into(); assert!(!rgb.is_valid());
fn try_convert_into(self) -> Result<T, OutOfBounds<T>>
Convert into T, returning ok if the color is inside of its defined range,
otherwise an OutOfBounds
error is returned which contains the unclamped color.
use palette::ConvertInto; use palette::{Srgb, Hsl}; let rgb: Srgb = match Hsl::new(150.0, 1.0, 1.1).try_convert_into() { Ok(color) => color, Err(err) => { println!("Color is out of bounds"); err.color() }, };
Implementors
impl<T, U> ConvertInto<U> for T where
U: ConvertFrom<T>,
[src]
U: ConvertFrom<T>,