This functions add (or set) transparency to a vector of colors.
Usage
add_transparency(x, alpha = 0, maxColorValue = 255)
Arguments
- x
vector of original color.
- alpha
numeric between O and 1, desired transparency.
- maxColorValue
integer, same as in rgb.
Value
vector of colors with alpha.
Details
Both 'x' and 'alpha' may be vectors. In case their length are not compatible,
a vector of the maximum length will be generated without any warning.
Examples
add_transparency("black", .5)
#> [1] "#00000080"
add_transparency(c("red", "black"), .5)
#> [1] "#FF000080" "#00000080"
# No warnings when length differs
add_transparency(c("#000000FF", "black", "red", "blue"), c(0, .5, 1))
#> [1] "#00000000" "#00000080" "#FF0000FF" "#0000FF00"