[−][src]Trait valora::prelude::ConvertFrom
A trait for converting one color from another.
convert_unclamped
currently wraps the underlying From
implementation.
Required methods
fn convert_from(T) -> Self
Convert from T with values clamped to the color defined bounds
use palette::ConvertFrom; use palette::Limited; use palette::{Srgb, Lch}; let rgb = Srgb::convert_from(Lch::new(50.0, 100.0, -175.0)); assert!(rgb.is_valid());
fn try_convert_from(T) -> Result<Self, OutOfBounds<Self>>
Convert from 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::ConvertFrom; use palette::{Srgb, Hsl}; let rgb = match Srgb::try_convert_from(Hsl::new(150.0, 1.0, 1.1)) { Ok(color) => color, Err(err) => { println!("Color is out of bounds"); err.color() }, };
Provided methods
fn convert_unclamped_from(val: T) -> Self
Convert from T. The resulting color might be invalid in its color space
use palette::ConvertFrom; use palette::Limited; use palette::{Srgb, Lch}; let rgb = Srgb::convert_unclamped_from(Lch::new(50.0, 100.0, -175.0)); assert!(!rgb.is_valid());
Implementors
impl<T, U> ConvertFrom<T> for U where
U: From<T> + Limited,
[src]
U: From<T> + Limited,