wcag2RelativeLuminance - multiple declarations
Function wcag2RelativeLuminance
Computes WCAG 2 relative luminance from encoded sRGB.
Use this overload for ordinary encoded sRGB input. Components must be finite
and from 0 through 1 inclusive. Invalid input produces an
invalid Wcag2Measurement whose value is NaN. Alpha-bearing input is not
accepted and no clipping or gamut mapping is performed.
Parameters
| Name | Description |
|---|---|
| color | Normalized encoded sRGB color. |
Returns
A valid relative-luminance measurement, or an invalid measurement for input outside the WCAG 2 sRGB domain.
Standards
W3C WCAG 2.2 relative luminance for sRGB.
Example
Black and white define the endpoints of relative luminance.
import color .rgb :
SRgbd;
const black =
SRgbd(0, 0, 0) .wcag2RelativeLuminance;
const white =
SRgbd(1, 1, 1) .wcag2RelativeLuminance;
assert(black .valid);
assert(black .value == 0);
assert(white .valid);
assert(white .value == 1);
Function wcag2RelativeLuminance
Computes WCAG 2 relative luminance from linear-light sRGB.
Use this overload when transfer-function decoding has already been done. Components must be finite and from 0 through 1 inclusive. This represents the same WCAG sRGB measurement after transfer-function decoding has already been performed explicitly.
Parameters
| Name | Description |
|---|---|
| color | Normalized linear-light sRGB color. |
Returns
A valid relative-luminance measurement, or an invalid measurement for input outside the WCAG 2 domain.
Standards
W3C WCAG 2.2 relative luminance for sRGB.
Example
import color .rgb : LinearSRgbd;
const black = LinearSRgbd(0, 0, 0) .wcag2RelativeLuminance;
const white = LinearSRgbd(1, 1, 1) .wcag2RelativeLuminance;
assert(black .valid && black .value == 0);
assert(white .valid && white .value == 1);