col_to_rgb: Fast conversion of colors-as-strings to a matrix of RGBA...

View source: R/col_to_rgb.R

col_to_rgbR Documentation

Fast conversion of colors-as-strings to a matrix of RGBA integers

Description

This is a faster replacement for grDevices::col2rgb() which uses a hash lookup of R color names (rather than a linear search).

Usage

col_to_rgb(col)

Arguments

col

Character vector of color names. Supports all R color names (e.g. "red", "hotpink") and hex colors of the form: "#RRGGBBAA", "#RRGGBB", "#RGBA" and "#RGB".

Value

An integer matrix with four rows and number of columns the length of the input.

Examples

col_to_rgb(c("hotpink", "#abc", "#abcd", "#aabb99", "#aabb9980"))

colorfast documentation built on April 4, 2025, 1:03 a.m.