Skip to contents

The contrast ratio of two colours, as WCAG 2 measures it: from 1:1, for the same colour, to 21:1, for black on white.

Usage

contrast_ratio(a, b)

Arguments

a, b

The colours, as "#RRGGBB".

Value

The ratio, a number from 1 to 21.

Examples

rghcard:::contrast_ratio("#198CE7", "#0d1117")   # R on GitHub's dark mode
#> [1] 5.3588