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 .init value contains NaNs, so it does not represent black.

Fields

NameTypeDescription
b TBlue encoded-sRGB component.
g TGreen encoded-sRGB component.
r TRed encoded-sRGB component.

Aliases

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