R/add_alpha_.R

Defines functions add_alpha_

Documented in add_alpha_

# TODO:
# this function is from http://www.magesblog.com/2013/04/how-to-change-alpha-value-of-colours-in.html
# so may need a rewrite
# old name: add.alpha
#' Add transparency to a color value
#' 
#' @param col Input color string.
#' @param alpha Transparency level, a numeric from 0 to 1 inclusive.
#' @export
add_alpha_ <- function(col, alpha = 1){
  if(missing(col))
    stop("Please provide a vector of colours.")
  if(length(col) == 0) {
    return(col)
  }
  apply(sapply(col, col2rgb)/255, 2, 
    function(x) 
      rgb(x[1], x[2], x[3], alpha=alpha))  
}
bahlolab/exSTRa documentation built on Sept. 17, 2022, 5:08 p.m.