Struct SRgb
Stores nonlinear sRGB channel values.
struct SRgb(T)
if (is(T == float) || is(T == double));
Use this type for encoded sRGB data. T must be float or double.
Construction stores components unchanged, including values outside [0, 1];
it does not clamp or gamut-map them.
The natural value contains NaNs, so it does not represent black.
Fields
| Name | Type | Description |
|---|---|---|
b
|
T | Blue encoded-sRGB component. |
g
|
T | Green encoded-sRGB component. |
r
|
T | Red encoded-sRGB component. |
Aliases
| Name | Description |
|---|---|
Scalar
|
Scalar component type. |
Example
// Encoded sRGB is the normal form for CSS/image-style channel values.
// Decode it before operations that require linear light.
const encoded = SRgbd(0.50, 0.25, 0.0);
const linear = encoded .toLinear;
assert(linear .r < encoded .r);
assert(linear .g < encoded .g);
assert(linear .b == 0.0);