Skip to content

Instantly share code, notes, and snippets.

@gu-mi
Forked from mages/add.alpha.R
Created April 30, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gu-mi/5489557 to your computer and use it in GitHub Desktop.
Save gu-mi/5489557 to your computer and use it in GitHub Desktop.
## Add an alpha value to a colour
add.alpha <- function(col, alpha=1){
if(missing(col))
stop("Please provide a vector of colours.")
apply(sapply(col, col2rgb)/255, 2,
function(x)
rgb(x[1], x[2], x[3], alpha=alpha))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment