saturate
saturate makes a color more vivid by increasing OKLCH chroma. It keeps lightness and hue, which lets you strengthen an accent without choosing a new color.
Example
import { colore } from 'colore-js';
import { saturate } from 'colore-js/fn';
colore('#64836a').saturate(20).css(); // '#5f8567'
saturate('#64836a', 20); // '#5f8567'
Syntax
colore(color).saturate(amount: number): Color
saturate(color: ColorInput, amount: number): string
Parameters
Returns
The method returns a new Color. The standalone function returns hex in sRGB, Display P3 for a wider result, or OKLCH when neither gamut fits.
Throws
A ColorError if the color is invalid or the amount is outside 0–100, nonfinite, or strictly between 0 and 1.
Make a wide-gamut accent more vivid
The CSS result can move past the range of hex or Display P3. Keep the returned OKLCH string if that fits your output target.
import { saturate } from 'colore-js/fn';
saturate('oklch(0.7 0.3 150)', 20); // 'oklch(0.70000 0.36000 150.00)'
Saturating a neutral gray leaves it neutral because its chroma is zero. To tint a gray, set both chroma and hue with setOklch.
Related
- desaturate to soften a color
- setOklch to give a gray a specific hue
- OKLCH in JavaScript for more edits in this color space