Struct Alpha

Stores a computational color together with straight alpha.

struct Alpha(Color)
  
if (isSupportedAlphaColor!Color);

Use straight alpha when color coordinates and opacity should remain independent. Construction stores supplied values unchanged: alpha is not clamped and the color is not converted, clipped, or gamut-mapped.

Color must be one of the supported computational color value types. The natural .init state is detectably invalid because its floating components and alpha are NaN.

Fields

NameTypeDescription
alpha Alpha.ScalarRaw straight alpha value.
color ColorWrapped straight color value.

Properties

NameTypeDescription
isValidAlpha[get] boolReports whether alpha is a usable opacity from 0 through 1.

Aliases

NameDescription
Scalar Scalar component type shared with the wrapped color.

Example

const value = Alpha!SRgbf(
    SRgbf(0.2f, 0.4f, 0.8f),
    0.5f
);

assert(value.color == SRgbf(0.2f, 0.4f, 0.8f));
assert(value.alpha == 0.5f);
assert(value.isValidAlpha);