Given a user-supplied color, what's a good color to pair it with for maximum contrast? Compares provided color against all named R colors, as per colors. Contrast calculated as per cr_get_ratio.

cr_choose_color(col, n = 1, ex_bw = FALSE)

Arguments

col

A character value representing a color. Can be a six-digit hex value preceded by '#', or a named color from

n

Number of named colors to return. Color with highest contrast is returned first.

ex_bw

Exclude black and variants of white and gray variants?

Value

A character value that's a named R color.

Examples

cr_choose_color("lightyellow")
#> [1] "black"