splot.colorcontrast {splot} | R Documentation |
Calculates the color contrast ratio between two sets of colors, as defined by the World Wide Web Consortium.
splot.colorcontrast(color, background = "#ffffff", plot = TRUE)
color , background |
A character vector of colors, or a matrix with RGB values across rows. |
plot |
Logical; if |
A list with entries for ratio
(contrast ratio),
AA
(ratios of at least 4.5), and AAA
(ratios of at least 7).
Each entry contains a matrix with colors in rows and backgrounds in columns.
# check colors against dark and light backgrounds
splot.colorcontrast(c("#FF0000", "#00FF00", "#0000FF"), c("black", "white"))
# check contrast between colors
splot.colorcontrast(c("red", "green", "blue"), c("red", "green", "blue"))
# see when shades of a color cross thresholds on a given background
splot.colorcontrast(splot.color(1:10, seed = "#a388b5"), "#101010")