splot.colorcontrast: splot color contrast ratio

View source: R/splot.colorcontrast.R

splot.colorcontrastR Documentation

splot color contrast ratio

Description

Calculates the color contrast ratio between two sets of colors, as defined by the World Wide Web Consortium.

Usage

splot.colorcontrast(color, background = "#ffffff", plot = TRUE)

Arguments

color, background

A character vector of colors, or a matrix with RGB values across rows.

plot

Logical; if FALSE, will not plot the results.

Value

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.

Examples

# 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")

miserman/splot documentation built on Oct. 30, 2023, 2:24 a.m.