R/color-palette-ust.R

Defines functions ust_pal ust_cols

Documented in ust_pal

ust_colors <- c(
  `dark purple` = "#510c76",
  `purple` = "#8348ad",
  `light purple` = "#a97cca",
  `bright purple` = "#9e28b5",
  `gray` = "#98999b",
  `lime green` = "#94d600",
  `light blue` = "#6cc5e9",
  `orange` = "#ff6c00",
  `magenta` = "#cf009f",
  `teal` = "#0099a9"
)

ust_cols <- function(...) {
  cols <- c(...)

  if (is.null(cols))
    return (ust_colors)

  ust_colors[cols]
}

ust_palettes <- list(
  `main`  = ust_cols("purple", "gray", "teal", "magenta", "orange", "lime green", "light blue"),

  `purples`  = ust_cols("bright purple", "dark purple", "purple", "light purple", "gray"),

  `tropical` = ust_cols("teal", "magenta", "orange", "lime green"),

  `cool` = ust_cols("magenta", "bright purple", "light blue", "teal")
)

#' Return function to interpolate a ust color palette
#'
#' @param palette Character name of palette in ust_palettes
#' @param reverse Boolean indicating whether the palette should be reversed
#' @param ... Additional arguments to pass to colorRampPalette()
#'
ust_pal <- function(palette = "main", reverse = FALSE, ...) {
  pal <- ust_palettes[[palette]]

  if (reverse) pal <- rev(pal)

  colorRampPalette(pal, ...)
}
UniversityOfSaintThomas/ustr documentation built on April 23, 2020, 12:44 a.m.