R/compute_transparent_color.R

Defines functions compute_transparent_color

compute_transparent_color <- function(color, percent = 50, name = NULL) {
  ## Get RGB values for named color
  rgb.val <- col2rgb(color)

  ## Make new color using input color as base and alpha set by transparency
  t.col <- rgb(rgb.val[1], rgb.val[2], rgb.val[3],
               maxColorValue = 255,
               alpha = (100 - percent) * 255 / 100,
               names = name)

  ## Save the color
  t.col
}

Try the idarps package in your browser

Any scripts or data that you put into this service are public.

idarps documentation built on June 8, 2025, 10:06 a.m.