Learn R Programming

xaringanthemer (version 0.2.0)

choose_dark_or_light: Choose dark or light color

Description

Takes a color input as x and returns either the black or white color (or expression) if dark or light text should be used over the input color for best contrast. Follows W3C Recommendations.

Usage

choose_dark_or_light(x, black = "#000", white = "#FFF")

Arguments

x

The background color

black

Text or foreground color, e.g. "#222" or substitute(darken_color(x, 0.8)), if black text provides the best contrast.

white

Text or foreground color or expression, e.g. "#EEE" or substitute(lighten_color(x, 0.8)), if white text provides the best contrast.

References

https://stackoverflow.com/a/3943023/2022615