gamutMapRayTraceToLinearSRgb - multiple declarations
Function gamutMapRayTraceToLinearSRgb
Maps an OKLCH color into linear sRGB with the Ray Trace strategy.
Choose Ray Trace when you want the bounded-cost mapping strategy. Negative finite chroma is canonicalized before mapping. Lightness at or above 1 maps to white and lightness at or below 0 maps to black. Already-in-gamut colors take the identity path after explicit conversion.
Non-finite input is not repaired. This is per-color mathematical mapping and does not define image-wide rendering intent, encoding, or alpha compositing.
Parameters
| Name | Description |
|---|---|
| color | OKLCH color to map. |
Returns
A linear-sRGB color in gamut for finite mapped input.
Standards
Implements the Ray Trace SDR RGB gamut-mapping strategy described by W3C CSS Color Module Level 4.
Allocation
Does not allocate.
Complexity
O(1) per color using a fixed bounded ray-intersection refinement; cost is independent of image or collection size.
See Also
gamutMapLocalMindeToLinearSRgb, clip
Example
Ray Trace is the bounded-cost perceptual mapping choice.
import color .oklch :
OklabHued,
Oklchd;
const vivid =
Oklchd(
0.70,
0.30,
OklabHued .fromDegrees(40.0)
);
const mapped =
vivid .gamutMapRayTraceToLinearSRgb;
assert(mapped .inGamut);
Function gamutMapRayTraceToLinearSRgb
Maps a straight-alpha OKLCH color using Ray Trace.
Only the wrapped color is mapped. Alpha is copied unchanged and is not clamped, premultiplied, composited, or otherwise interpreted.
Parameters
| Name | Description |
|---|---|
| value | Straight-alpha OKLCH value to map. |
Returns
Straight-alpha linear sRGB with unchanged alpha.
Example
Straight alpha is carried through mapping unchanged.
import color .alpha :
Alpha;
import color .oklch :
OklabHued,
Oklchd;
const selected =
Alpha!Oklchd(
Oklchd(
0.70,
0.30,
OklabHued .fromDegrees(40.0)
),
0.40
);
const mapped =
selected .gamutMapRayTraceToLinearSRgb;
assert(mapped .alpha == 0.40);
assert(mapped .color .inGamut);