Function withLightness
Returns a copy of an OKLCH value with raw lightness replaced.
Chroma and stored hue are preserved exactly. No range restriction, clipping, gamut mapping, canonicalization, or other policy is applied.
Parameters
| Name | Description |
|---|---|
| color | Source OKLCH value. |
| lightness | Raw replacement lightness. |
Returns
A copy of color with only lightness replaced.
See Also
withChroma, withHue
Example
enum color = Oklchd(
0.55,
0.12,
OklabHued .fromDegrees(250.0)
);
enum changed = color .withLightness(1.25);
static assert(changed .l == 1.25);
static assert(changed .c == color .c);
static assert(changed .h .rawDegrees == color .h .rawDegrees);