Function toSRgb
Encodes a linear-light value as nonlinear sRGB.
Use this when a linear-light result must be returned to an sRGB-facing consumer. Components outside the nominal [0, 1] range remain extended values rather than being clipped. Negative values use a sign-preserving extension of the sRGB transfer function.
Parameters
| Name | Description |
|---|---|
| color | Linear-light sRGB value to encode. |
Returns
The corresponding encoded sRGB value.
Standards
The nominal transfer follows the sRGB transfer model used by W3C CSS Color Module Level 4; color-d extends it sign-preservingly outside the nominal display range.
See Also
toLinear
Example
const linear = LinearSRgbd(1.0, 0.0, -1.0);
const encoded = linear .toSRgb;
assert(encoded .r > 1.0 - 1e-12 && encoded .r <= 1.0);
assert(encoded .g == 0.0);
assert(encoded .b < -1.0 + 1e-12 && encoded .b >= -1.0);