Commit 35b2313b authored by Safia Saci's avatar Safia Saci
Browse files

Upload New File

parent 2302d566
#' mean_color
#'
#' @param mycolors vector of colors
#'
#' @return a color
#'
#' @examples
#' mean_color(c("#000000FF", "#FFFFFFFF", "#FFFF00FF", "#FF0000FF"))
#'
#'
mean_color <- function(mycolors) {
R <- strtoi(x = substr(mycolors,2,3), base = 16)
G <- strtoi(x = substr(mycolors,4,5), base = 16)
B <- strtoi(x = substr(mycolors,6,7), base = 16)
alpha <- strtoi(x = substr(mycolors,8,9), base = 16)
return(
grDevices::rgb(
red = round(mean(R)),
green = round(mean(G)),
blue = round(mean(B)),
alpha = round(mean(alpha)),
maxColorValue = 255
)
)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment