Skip to contents

col2hex() standardizes R color strings into a unique RGBA hex string. All fully transparent colors get standardized to "#FFFFFF00".

Usage

col2hex(x)

Arguments

x

Color value as supported by grDevices::col2rgb().

Value

A standardized RGBA hex string (as returned by grDevices::rgb()).

Examples

col2hex("red")
#> [1] "#FF0000FF"
col2hex("green")
#> [1] "#00FF00FF"
col2hex("blue")
#> [1] "#0000FFFF"
col2hex("transparent")
#> [1] "#FFFFFF00"
col2hex(NA_character_)
#> [1] "#FFFFFF00"
col2hex("#00000000")
#> [1] "#FFFFFF00"