😎 Give your xaringan slides some style
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
773B

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/color.R
  3. \name{apply_alpha}
  4. \alias{apply_alpha}
  5. \title{Add alpha to hex color}
  6. \usage{
  7. apply_alpha(color_hex, opacity = 0.5)
  8. }
  9. \arguments{
  10. \item{color_hex}{A character string representing a hex color}
  11. \item{opacity}{Desired opacity of the output color}
  12. }
  13. \value{
  14. A character string with added opacity level as hexadecimal characters.
  15. }
  16. \description{
  17. Applies alpha (or opacity) to a color in hexadecimal form by
  18. converting opacity in the \verb{[0, 1]} range to hex in the \verb{[0, 255]} range
  19. and appending to the hex color.
  20. }
  21. \examples{
  22. blue <- "#0e6ba8"
  23. blue_transparent <- apply_alpha(blue)
  24. if (requireNamespace("scales", quietly = TRUE)) {
  25. scales::show_col(c(blue, blue_transparent))
  26. }
  27. }