Learn R Programming

colorfast (version 1.0.1)

col_to_rgb: 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)

Value

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

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".

Examples

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

Run the code above in your browser using DataLab