Function withChroma
Returns a copy of an OKLCH value with raw chroma replaced.
Lightness and stored hue are preserved exactly. Negative chroma is not canonicalized, zero chroma does not erase powerless hue, and no clipping or gamut mapping is performed.
Parameters
| Name | Description |
|---|---|
| color | Source OKLCH value. |
| chroma | Raw replacement chroma. |
Returns
A copy of color with only chroma replaced.
See Also
withLightness, withHue
Example
enum color = Oklchd(
0.55,
0.12,
OklabHued .fromDegrees(250.0)
);
enum changed = color .withChroma(-0.10);
static assert(changed .l == color .l);
static assert(changed .c == -0.10);
static assert(changed .h .rawDegrees == color .h .rawDegrees);