Struct LinearSRgb

Stores linear-light sRGB channel values.

struct LinearSRgb(T)
  
if (is(T == float) || is(T == double));

Use this type for calculations that require linear light, such as alpha compositing. T must be float or double. Construction stores components unchanged, including values outside [0, 1].

The natural .init value contains NaNs, so it does not represent black.

Fields

NameTypeDescription
b TBlue linear-light component.
g TGreen linear-light component.
r TRed linear-light component.

Aliases

NameDescription
Scalar Scalar component type.

Example

// Linear-light values are the correct domain for light mixing and
// compositing. Encode only when a consumer needs encoded sRGB.
const linear = LinearSRgbd(0.25, 0.50, 1.0);
const encoded = linear.toSRgb;

assert(encoded.r > linear.r);
assert(encoded.g > linear.g);
assert(encoded.b == 1.0);