Expand description
WCAG 2.1 contrast primitives. Cases 1, 4, and 5 all measure against these — implement once, correctly.
relative_luminance works on linearized sRGB; the conversion
lives in color::linear_srgb_of so this file does not duplicate
the gamma curve.
Constants§
- AA_
LARGE_ TEXT - AA threshold for large text (>= 18pt regular / 14pt bold).
- AA_
NON_ TEXT - AA threshold for UI components, icons, borders.
- AA_TEXT
- AA threshold for normal-sized text.
- DARK_BG
- Page background for the future dark mode (§8 — emitted today even though the framework is light-only).
- LIGHT_
BG - Page background the engine measures the light-mode palette against.
- TEXT_
ON_ DARK - Default near-white text used on dark surfaces.
- TEXT_
ON_ LIGHT - Default near-black text used on light surfaces.
Functions§
- contrast_
ratio - WCAG 2.1 contrast ratio. Range
1.0..=21.0— identical colors give 1.0, black-on-white gives 21.0. - relative_
luminance - WCAG 2.1 relative luminance of an sRGB color, range
0.0..=1.0.