pub trait ColorMix<T, U>: Sized{
// 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:
- Premultiply each component by its alpha
- Linearly interpolate premultiplied values and alpha independently
- Un-premultiply by dividing by the interpolated alpha
Required Methods§
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.