😎 Give your xaringan slides some style
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

37 lines
1.1KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/color.R
  3. \name{choose_dark_or_light}
  4. \alias{choose_dark_or_light}
  5. \title{Choose dark or light color}
  6. \usage{
  7. choose_dark_or_light(x, black = "#000000", white = "#FFFFFF")
  8. }
  9. \arguments{
  10. \item{x}{The background color (hex)}
  11. \item{black}{Text or foreground color, e.g. "#222" or
  12. \code{substitute(darken_color(x, 0.8))}, if black text provides the best contrast.}
  13. \item{white}{Text or foreground color or expression, e.g. "#EEE" or
  14. \code{substitute(lighten_color(x, 0.8))}, if white text provides the best contrast.}
  15. }
  16. \description{
  17. Takes a color input as \code{x} and returns either the black or white color (or
  18. expression) if dark or light text should be used over the input color for
  19. best contrast. Follows W3C Recommendations.
  20. }
  21. \examples{
  22. light_green <- "#c4d6b0"
  23. contrast_green <- choose_dark_or_light(light_green)
  24. dark_purple <- "#381d2a"
  25. contrast_purple <- choose_dark_or_light(dark_purple)
  26. if (requireNamespace("scales", quietly = TRUE)) {
  27. scales::show_col(c(light_green, contrast_green, dark_purple, contrast_purple))
  28. }
  29. }
  30. \references{
  31. \url{https://stackoverflow.com/a/3943023/2022615}
  32. }