Trait palette::Saturate

source ·
pub trait Saturate: Sized {
    type Scalar: Float;

    // Required method
    fn saturate(&self, factor: Self::Scalar) -> Self;

    // Provided method
    fn desaturate(&self, factor: Self::Scalar) -> Self { ... }
}
Expand description

A trait for colors where the saturation (or chroma) can be manipulated without conversion.

use palette::{Hsv, Saturate};

let a = Hsv::new(0.0, 0.25, 1.0);
let b = Hsv::new(0.0, 1.0, 1.0);

assert_eq!(a.saturate(1.0), b.desaturate(0.5));

Required Associated Types§

source

type Scalar: Float

The type of the (de)saturation factor.

Required Methods§

source

fn saturate(&self, factor: Self::Scalar) -> Self

Increase the saturation by factor.

Provided Methods§

source

fn desaturate(&self, factor: Self::Scalar) -> Self

Decrease the saturation by factor.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<C: Saturate> Saturate for Alpha<C, C::Scalar>

§

type Scalar = <C as Saturate>::Scalar

source§

impl<S, T> Saturate for Hsl<S, T>
where T: Component + Float, S: RgbSpace,

§

type Scalar = T

source§

impl<S, T> Saturate for Hsv<S, T>
where T: Component + Float, S: RgbSpace,

§

type Scalar = T

source§

impl<Wp, T> Saturate for Lch<Wp, T>
where T: Component + Float, Wp: WhitePoint,

§

type Scalar = T