ColorMix

Trait ColorMix 

Source
pub trait ColorMix<T, U>: Sized
where T: Into<Self>, U: Into<Self>,
{ // Required method fn mix(first: T, second: U, percentage: f64) -> Self; }
Expand description

Trait for calculating mixing two colors together.

This trait provides a static method which will receive two colours, and can output a Self which should be the result of both colours mixed by the given percentage (the percentage pertains to how much the second colour should apply to the first).

Per CSS Color (4 12.3 & 5 3.5), interpolation uses premultiplied alpha:

  1. Premultiply each component by its alpha
  2. Linearly interpolate premultiplied values and alpha independently
  3. Un-premultiply by dividing by the interpolated alpha

Required Methods§

Source

fn mix(first: T, second: U, percentage: f64) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, U> ColorMix<T, U> for A98Rgb
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for DisplayP3
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for Lab
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for LinearRgb
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for Oklab
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for ProphotoRgb
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for Rec2020
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for Srgb
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for XyzD50
where Self: From<T> + From<U>,

Source§

impl<T, U> ColorMix<T, U> for XyzD65
where Self: From<T> + From<U>,

Source§

impl<T, U, V> ColorMix<T, U> for V
where V: ColorMixPolar<T, U> + PolarColor + Sized, T: Into<V>, U: Into<V>,