Nothing
#' Merges multiple colors
#'
#' Uses the [`colorRampPalette()`][grDevices::colorRamp] for merging colors.
#' *Note:* When merging more than 2 colors the order in the color
#' presentation matters. Each color is merged with its neigbors before
#' merging with next. If there is an uneven number of colors the middle
#' color is mixed with both left and right side.
#'
#' @param clrs The colors
#' @return `character` A hexadecimal color
#' @import magrittr
#' @keywords internal
#' @importFrom grDevices colorRampPalette
#' @importFrom utils head
prMergeClr <- function(clrs) {
if (length(clrs) == 1) {
return(clrs)
}
if (length(clrs) == 2) {
return(colorRampPalette(clrs)(3)[2])
}
split_lngth <- floor(length(clrs) / 2)
left <- head(clrs, split_lngth)
right <- tail(clrs, split_lngth)
if (length(clrs) %% 2 == 1) {
left %<>%
c(clrs[split_lngth + 1])
right %<>%
c(clrs[split_lngth + 1], .)
}
left <- prMergeClr(left)
right <- prMergeClr(right)
return(prMergeClr(c(left, right)))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.