Skip to contents

Return the alpha transparency per R color

Usage

col2alpha(x, maxValue = 1, ...)

Arguments

x

character R compatible color, either a color name, hex value, or a mixture of the two. Any value compatible with grDevices::col2rgb().

maxValue

numeric maximum value to return, useful when the downstream alpha range should be 255. By default maxValue=1 is returned.

...

Additional arguments are ignored.

Value

numeric vector of alpha values

Examples

col2alpha(c("red", "#99004499", "beige", "transparent", "#FFFFFF00"))
#> [1] 1.0 0.6 1.0 0.0 0.0