clip - multiple declarations

Function clip

Forces finite encoded sRGB components into the representable sRGB range.

SRgb!T clip(T)(
  SRgb!T color
) pure nothrow @nogc @safe;

Use hard clipping when saturation at the nearest component boundary is the intended policy. Finite values below zero become zero and values above one become one. NaN and infinities remain visible rather than being silently repaired.

Parameters

NameDescription
color Encoded sRGB value to clip.

Returns

The component-wise hard-clipped encoded sRGB value.

Example

const clipped = SRgbd(-0.25, 0.50, 1.25).clip;

assert(clipped == SRgbd(0.0, 0.50, 1.0));

Function clip

Forces finite linear-light sRGB components into the representable range.

LinearSRgb!T clip(T)(
  LinearSRgb!T color
) pure nothrow @nogc @safe;

Use hard clipping when component saturation is preferable to perceptual gamut mapping. Finite values below zero become zero and values above one become one. NaN and infinities remain visible rather than being silently repaired.

Parameters

NameDescription
color Linear-light sRGB value to clip.

Returns

The component-wise hard-clipped linear-light sRGB value.

Example

const clipped = LinearSRgbd(-0.25, 0.50, 1.25).clip;

assert(clipped == LinearSRgbd(0.0, 0.50, 1.0));