View source: R/compute_contrast.R
contrast | R Documentation |
Compute the WCAG contrast ratio between two colors.
contrast(x, y)
x, y |
colors specified as hex strings or named R colors. |
A number giving the contrast ratio between x and y (or a vector thereof). A value of 1 means no contrast at all. A minimum contrast of 4.5 is recommended to ensure that text is still readable against a background color.
https://www.w3.org/TR/WCAG20-TECHS/G18.html
contrast("pink", "hotpink") contrast("pink", "blue") # The computation can be vectorised (if the arguments are compatible) contrast("pink", rainbow(10)) contrast(c("red","pink"), c("red","blue"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.