Liking cljdoc? Tell your friends :D

dk.simongray.colour-coded.contrast

The contrast of two colours by WCAG 2.2, and the text colour that reads best on one.

WCAG 2.2 asks for these contrast ratios:

  • 4.5 for text, and 3 for large text, i.e. 18 points, or 14 points bold (success criterion 1.4.3)
  • 3 for the parts of a control and for graphics (1.4.11)
  • 7 and 4.5 at level AAA (1.4.6)

The ratio overstates the contrast of dark colours, which APCA addresses. APCA's licence forbids changing it and using it commercially, so it isn't here, but any function of two colours can stand in for ratio where an app wants its own measure.

https://www.w3.org/TR/WCAG22/#dfn-contrast-ratio

The contrast of two colours by WCAG 2.2, and the text colour that reads
best on one.

WCAG 2.2 asks for these contrast ratios:

- 4.5 for text, and 3 for large text, i.e. 18 points, or 14 points bold
  (success criterion 1.4.3)
- 3 for the parts of a control and for graphics (1.4.11)
- 7 and 4.5 at level AAA (1.4.6)

The ratio overstates the contrast of dark colours, which APCA addresses.
APCA's licence forbids changing it and using it commercially, so it isn't
here, but any function of two colours can stand in for ratio where an app
wants its own measure.

https://www.w3.org/TR/WCAG22/#dfn-contrast-ratio
raw docstring

blackclj/s

Black, in sRGB.

Black, in sRGB.
sourceraw docstring

black-or-whiteclj/s

(black-or-white x)

Black or white, whichever contrasts more with the colour x by WCAG 2.2, and white on a tie. contrast-color() of CSS Color 5 may choose otherwise, since its measure is the browser's.

Black or white, whichever contrasts more with the colour `x` by WCAG
2.2, and white on a tie. contrast-color() of CSS Color 5 may choose
otherwise, since its measure is the browser's.
sourceraw docstring

levelclj/s

(level a b)

The level of WCAG 2.2 that the contrast of the colours a and b meets: :aaa for 7 or more, :aa for 4.5, :large for 3, which is enough for large text and for controls, or nil.

The level of WCAG 2.2 that the contrast of the colours `a` and `b`
meets: :aaa for 7 or more, :aa for 4.5, :large for 3, which is enough
for large text and for controls, or nil.
sourceraw docstring

luminanceclj/s

(luminance x)

The relative luminance of the colour x, from 0 for black to 1 for white, by WCAG 2.2, from its sRGB channels.

The relative luminance of the colour `x`, from 0 for black to 1 for
white, by WCAG 2.2, from its sRGB channels.
sourceraw docstring

ratioclj/s

(ratio a b)

The contrast ratio of the colours a and b, from 1 to 21. Text wants 4.5, and a control 3.

The contrast ratio of the colours `a` and `b`, from 1 to 21. Text wants
4.5, and a control 3.
sourceraw docstring

whiteclj/s

White, in sRGB.

White, in sRGB.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close