hex2rgb: Convert HEX color(s) to RGB numeric components

View source: R/hex2rgb.R

hex2rgbR Documentation

Convert HEX color(s) to RGB numeric components

Description

Convert a single HEX color string or a character vector of HEX strings to RGB numeric components. The function accepts values with or without a leading ⁠#⁠. Messaging uses cli if available and falls back to message().

Usage

hex2rgb(hex)

Arguments

hex

Character. A HEX color string (e.g. "#FF8000") or a character vector of HEX codes. No NA values allowed.

Value

If hex has length 1, a named numeric vector with elements c(r, g, b). If hex has length > 1, a named list where each element is a named numeric vector for the corresponding input.

Examples

hex2rgb("#FF8000")
hex2rgb(c("#FF8000", "#00FF00"))


evanverse documentation built on March 10, 2026, 5:07 p.m.