Skip to content

wcagRelativeLuminance

wcagRelativeLuminance(value): number

Defined in: packages/math-color/src/encoding/rgb8/accessibility/wcag-relative-luminance.ts:22

Computes the relative luminance of an sRGB color according to the WCAG 2.x definition. https://www.w3.org/WAI/GL/wiki/Relative_luminance

Note: This function intentionally replicates the WCAG 2.x erroneous definition:

  • Linearization threshold is 0.03928 (WCAG) instead of the correct sRGB value of 0.04045.
  • Y coefficients use 4 digits of precision (0.2126, 0.7152, 0.0722) instead of the more precise ICC values, with the R coefficient truncated rather than rounded.

This matches the WCAG 2.x test suite expectations. Use standard sRGB linearization for color science work unrelated to WCAG conformance.

Rgb8

An sRGB color with components in the range [0, 255].

number

The relative luminance of the color in the range [0, 1].