Function gamut_map

Source
pub fn gamut_map<Source, Target, T>(source: Source) -> Target
where Source: Copy, Oklch<T>: FromColorUnclamped<Source>, Target: Copy + Default + FromColorUnclamped<Oklch<T>> + Clamp + IsWithinBounds<Mask = bool> + Lighten<Scalar = T> + Darken<Scalar = T>, Oklab<T>: FromColorUnclamped<Target> + FromColorUnclamped<Oklch<T>>, T: Copy + From<f32> + Arithmetics + Sqrt + Real + Zero + One + PartialCmp<Mask = bool>,
Expand description

Map a color from a source color space to a target color space by performing a perceptual gamut mapping. This follows the CSS Color Module Level 4 binary search specification.

The mapping proceeds by first mapping the target to the perceptual Oklch color space. Then the chromacity is reduced until the color (almost) fits in the target color space. The gamut is reduced only as much as is necessary for the clipped target to be perceptually indistinguishable from the true color (as measured in Oklab space).

See: https://web.archive.org/web/20230714163953/https://drafts.csswg.org/css-color/#binsearch