Trait palette::Mix

source ·
pub trait Mix {
    type Scalar;

    // Required method
    fn mix(self, other: Self, factor: Self::Scalar) -> Self;
}
Expand description

Linear color interpolation of two colors.

See also MixAssign.

use approx::assert_relative_eq;
use palette::{LinSrgb, Mix};

let a = LinSrgb::new(0.0, 0.5, 1.0);
let b = LinSrgb::new(1.0, 0.5, 0.0);

assert_relative_eq!(a.mix(b, 0.0), a);
assert_relative_eq!(a.mix(b, 0.5), LinSrgb::new(0.5, 0.5, 0.5));
assert_relative_eq!(a.mix(b, 1.0), b);

Required Associated Types§

source

type Scalar

The type of the mixing factor.

Required Methods§

source

fn mix(self, other: Self, factor: Self::Scalar) -> Self

Mix the color with an other color, by factor.

factor should be between 0.0 and 1.0, where 0.0 will result in the same color as self and 1.0 will result in the same color as other.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<C> Mix for Alpha<C, C::Scalar>
where C: Mix, C::Scalar: Zero + One + Clamp + Arithmetics + Clone,

§

type Scalar = <C as Mix>::Scalar

source§

impl<C, T> Mix for PreAlpha<C>
where C: Mix<Scalar = T> + Premultiply<Scalar = T>, T: Real + Zero + One + Clamp + Arithmetics + Clone,

§

type Scalar = T

source§

impl<S, T> Mix for Luma<S, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<S, T> Mix for Rgb<S, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<S, T> Mix for Hsl<S, T>

§

type Scalar = T

source§

impl<S, T> Mix for Hsv<S, T>

§

type Scalar = T

source§

impl<S, T> Mix for Hwb<S, T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Jch<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Jmh<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Jsh<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Qch<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Qmh<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16Qsh<T>

§

type Scalar = T

source§

impl<T> Mix for Cam16UcsJab<T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<T> Mix for Cam16UcsJmh<T>

§

type Scalar = T

source§

impl<T> Mix for Okhsl<T>

§

type Scalar = T

source§

impl<T> Mix for Okhsv<T>

§

type Scalar = T

source§

impl<T> Mix for Okhwb<T>

§

type Scalar = T

source§

impl<T> Mix for Oklab<T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<T> Mix for Oklch<T>

§

type Scalar = T

source§

impl<Wp, T> Mix for Hsluv<Wp, T>

§

type Scalar = T

source§

impl<Wp, T> Mix for Lab<Wp, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<Wp, T> Mix for Lch<Wp, T>

§

type Scalar = T

source§

impl<Wp, T> Mix for Lchuv<Wp, T>

§

type Scalar = T

source§

impl<Wp, T> Mix for Luv<Wp, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<Wp, T> Mix for Xyz<Wp, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T

source§

impl<Wp, T> Mix for Yxy<Wp, T>
where T: Real + Zero + One + Arithmetics + Clamp + Clone,

§

type Scalar = T