Convert a character vector of HEX color codes to a data.frame with columns
hex, r, g, b, and alpha.
Value
A data.frame with hex (character) and integer r, g, b, and
alpha columns. Channels lie in [0, 255]. alpha is NA_integer_ for
a 6-digit input and the explicit alpha channel for an 8-digit input.
Examples
hex2rgb("#FF8000")
#> hex r g b alpha
#> 1 #FF8000 255 128 0 NA
hex2rgb(c("#FF8000", "#00FF00"))
#> hex r g b alpha
#> 1 #FF8000 255 128 0 NA
#> 2 #00FF00 0 255 0 NA
