R/colors_cfeaR.R

#' Color Palettes for Cape Fear
#'
#' @param n The number of colors needed (max 10)
#' @return
#' @export
#'

group_col_cfeaR <- function (n, name = c("cfeaR.colors1")) {
  cfeaR.colors1 = rgb(
    c(102, 20, 178, 51, 251, 227, 253, 255, 202, 106),
    c(187, 64, 223, 160, 154, 26, 191, 127, 178, 61),
    c(183, 106, 138, 44, 153, 28, 111, 0, 214, 154),
    maxColorValue = 255)
  name = match.arg(name)
  orig = eval(parse(text = name))
  rgb = t(col2rgb(orig))
  temp = matrix(NA, ncol = 3, nrow = n)
  x = seq(0, 1, , length(orig))
  xg = seq(0, 1, , n)
  for (k in 1:3) {
    hold = spline(x, rgb[, k], n = n)$y
    hold[hold < 0] = 0
    hold[hold > 255] = 255
    temp[, k] = round(hold)
  }
  palette = rgb(temp[, 1], temp[, 2], temp[, 3], maxColorValue = 255)
  palette
}

# cfeaR.subset <- group_col_cfeaR(n = 10)
# library(scales)
# show_col(cfeaR.subset)
Cape-Fear-Collective/cfeaR documentation built on Sept. 3, 2020, 6:25 p.m.