😎 Give your xaringan slides some style
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

40 行
1.3KB

  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. \value{
  17. The \code{black} color or \code{white} color according to which color provides
  18. the greates contrast with the input color.
  19. }
  20. \description{
  21. Takes a color input as \code{x} and returns either the black or white color (or
  22. expression) if dark or light text should be used over the input color for
  23. best contrast. Follows W3C Recommendations.
  24. }
  25. \examples{
  26. light_green <- "#c4d6b0"
  27. contrast_green <- choose_dark_or_light(light_green)
  28. dark_purple <- "#381d2a"
  29. contrast_purple <- choose_dark_or_light(dark_purple)
  30. if (requireNamespace("scales", quietly = TRUE)) {
  31. scales::show_col(c(light_green, contrast_green, dark_purple, contrast_purple))
  32. }
  33. }
  34. \references{
  35. \url{https://stackoverflow.com/a/3943023/2022615}
  36. }