desaturate
Decrease chroma by a relative amount: c * (1 - amount), clamped below at 0. There is no upper cap, so amount = 0 returns the input chroma unchanged even for wide-gamut colors above 0.4. Lightness, hue and alpha are unchanged.
import { desaturate } from '@pbroom/color-kit';index.ts:114function desaturate( color: Color, , amount: number,): Color;Parameters
- amount
number - Fraction of the chroma to remove (
0-1)
Returns
ColorA new Color
Example
import { desaturate, parse } from '@pbroom/color-kit';
desaturate(parse('oklch(0.7 0.2 250)'), 0.5); // → { l: 0.7, c: 0.1, h: 250, alpha: 1 }