mapOklch function
Gamut-maps OKLCH to linear sRGB by constant-L, constant-h chroma reduction (exact boundary via maxChroma), then clamps float noise. White for L ≥ 1, black for L ≤ 0. Luminance is non-decreasing in L along this map, which the contrast solver relies on.
Implementation
LinRgb mapOklch(double l, double c, double hDeg) {
if (l >= 1) return (1, 1, 1);
if (l <= 0) return (0, 0, 0);
var rgb = oklabToLin(oklchToOklab(l, c, hDeg));
if (!inGamut(rgb)) {
rgb = oklabToLin(oklchToOklab(l, maxChroma(l, hDeg), hDeg));
}
return (clamp01(rgb.$1), clamp01(rgb.$2), clamp01(rgb.$3));
}