Skip to contents

Converts a single HEX string or a character vector of HEX strings to RGB numeric values.

Usage

hex2rgb(hex)

Arguments

hex

A HEX color string (e.g., "#FF8000") or a character vector of HEX codes.

Value

A numeric vector of length 3 for a single HEX input, or a named list of RGB vectors for multiple inputs.

Examples

hex2rgb("#FF8000")
#> ✔ #FF8000 -> RGB: c(255, 128, 0)
#> [1] 255 128   0
hex2rgb(c("#FF8000", "#00FF00"))
#> ✔ Converted 2 HEX values to RGB:
#> ℹ #FF8000 -> RGB: c(255, 128, 0)
#> ℹ #00FF00 -> RGB: c(0, 255, 0)
#> $`#FF8000`
#> [1] 255 128   0
#> 
#> $`#00FF00`
#> [1]   0 255   0
#>