Expand description
Contrast checks: the token pairs that must stay legible, and the WCAG 2.x ratios they must reach.
Structs§
- Failure
- A pair under its required ratio, or with a token missing.
- Pair
- A foreground token over a background token.
- Separation
- Two slots of the categorical palette told apart too little.
Enums§
- Level
- The level a theme is checked at.
- Pair
Kind - What a pair is: text to read, or a user-interface part to see.
- Vision
- How a colour is seen, for telling the categorical palette’s slots apart.
Constants§
- CATEGORY_
ADJACENT - Between two slots next to each other in the categorical palette (series 1 and 2 of a chart), with full colour vision.
- CATEGORY_
ANY - Between any two slots of the categorical palette, with full colour vision: a scatter or a legend puts any two side by side.
- CATEGORY_
CVD_ ADJACENT - Between two slots next to each other, with protanopia or deuteranopia.
- OVER_
IMAGES - The pairs drawn over an image, whose background is translucent: the
background is painted over black and over white (an image’s darkest
and brightest pixels) and the foreground must read on both.
checkchecks them withPAIRS, reporting the poorer of the two ratios. - PAIRS
- Every pair checked, listed by hand: where text is drawn and where a
control must be seen. Decorative borders (
border.default) are not in it.
Functions§
- check
- Checks every pair of
PAIRSandOVER_IMAGESat a level; empty when all pass. - check_
category - Checks that the categorical palette’s slots are told apart: every two
at
CATEGORY_ANYand neighbours atCATEGORY_ADJACENTwith full colour vision, neighbours atCATEGORY_CVD_ADJACENTwith protanopia and deuteranopia. Empty when all pass. Their contrast with the surfaces is inPAIRS. - contrast_
ratio - The WCAG 2.x contrast ratio of a foreground over a background, from 1 to 21. A translucent foreground is first painted over the background; the background is taken as opaque.
- delta_e
- The perceptual distance between two colours, as seen with
vision: the Euclidean distance in OKLab, times 100 (ΔE OK). About 2 is the smallest difference seen side by side; categorical palettes aim for 15 and more between neighbours. - over_
image_ ratio - The ratio of a pair of
OVER_IMAGESin a theme, if both tokens are colours: its background painted over black and over white, the poorer of the two. - pair_
ratio - The ratio of one pair in a theme, if both tokens are colours.