Determine text color based on background color
text_color(
background,
threshold = 186,
w3c = FALSE,
dark = "black",
light = "white"
)
A vector of background colors; supports R color names and hexadecimal codes
Intensity threshold for light/dark cutoff; intensities
greater than theshold
yield dark
, others yield light
Use W3C formula for calculating
background text color; ignores threshold
Color for dark text
Color for light text
A named vector of either dark
or light
, depending on
background
; names of vector are background
Other color_theory:
blend_colors()
,
col2hex()
,
contrast-theory
text_color(background = c('black', 'white', '#E76BF3'))
#> black white #E76BF3
#> "white" "black" "white"