Trait palette::ConvertFrom 
source · pub trait ConvertFrom<T>: From<T> {
    // Required methods
    fn convert_from(_: T) -> Self;
    fn try_convert_from(_: T) -> Result<Self, OutOfBounds<Self>>;
    // Provided method
    fn convert_unclamped_from(val: T) -> Self { ... }
}Expand description
A trait for converting one color from another.
convert_unclamped currently wraps the underlying From implementation.
Required Methods§
sourcefn convert_from(_: T) -> Self
 
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());sourcefn try_convert_from(_: T) -> Result<Self, OutOfBounds<Self>>
 
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§
sourcefn convert_unclamped_from(val: T) -> Self
 
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());Object Safety§
This trait is not object safe.