Convert Color Specified to RGB Integer Triplet

DESCRIPTION:

Get the RGB integer triplet describing a color from a string specifying a color name, a string specifying a color in RGB value format, or an integer color palette index.

USAGE:

col2rgb(col, alpha=F)

REQUIRED ARGUMENTS:

col
String specifying color name, RGB value, or integer. For example, "red", "#FF0000", "#FF000080", or 3. Can be a vector.

OPTIONAL ARGUMENTS:

alpha
Logical indicating whether to include alpha giving the degree of transparency for the color.

VALUE:

If alpha = F, returns a 3 row matrix, with rows containing integer values between 0 and 255 giving the red , green , and blue for each color. One column is present for each color. If alpha = T, returns a 4 row matrix with an additional row containing the alpha for each color.

SIDE EFFECTS:

None

SEE ALSO:

, .

EXAMPLES:

# Get RGB integers for all named colors
col2rgb(colors())

# Get RGB integers for specific named colors
col2rgb(c("red", "teal"))

# Get RGB integers from RGB values.  Include alpha.
col2rgb(c("#FF0000", "#FF000080"), alpha=T)

# Get RGB for the first 4 colors in the default palette
col2rgb(1:4)