MCPcopy Create free account
hub / github.com/csskit/csskit / ColorMix

Interface ColorMix

crates/chromashift/src/mix.rs:26–32  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

24/// 2. Linearly interpolate premultiplied values and alpha independently
25/// 3. Un-premultiply by dividing by the interpolated alpha
26pub trait ColorMix<T, U>: Sized
27where
28 T: Into<Self>,
29 U: Into<Self>,
30{
31 fn mix(first: T, second: U, percentage: f64) -> Self;
32}
33
34/// Trait for calculating mixing two colors together, with a hue direction for Polar colour spaces.
35///

Callers 1

parseMethod · 0.85

Implementers 1

mix.rscrates/chromashift/src/mix.rs

Calls

no outgoing calls

Tested by

no test coverage detected