Function withChroma

Returns a copy of an OKLCH value with raw chroma replaced.

Oklch!T withChroma(T)(
  Oklch!T color,
  T chroma
) pure nothrow @nogc @safe;

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

NameDescription
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);