R color to RGB (red/green/blue) conversion.

ColToRgb(col, alpha = FALSE)

Arguments

col

vector of any of the three kind of R colors, i.e., either a color name (an element of colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa", or an integer i meaning palette()[i]. Non-string values are coerced to integer.

alpha

logical value indicating whether alpha channel (opacity) values should be returned.

Details

This is merely a wrapper to col2rgb, defined in order to follow this package's naming conventions.

Value

A matrix with a column for each color. The three rows of the matrix indicate red, green and blue value and are named "red", "green", and "blue" accordingly. The matrix might have a 4th row if an alpha channel is requested.

Author

Andri Signorell <andri@signorell.net>

See also

Examples

ColToRgb("peachpuff")
#>       [,1]
#> red    255
#> green  218
#> blue   185
ColToRgb(c(blu = "royalblue", reddish = "tomato")) # names kept
#>       blu reddish
#> red    65     255
#> green 105      99
#> blue  225      71

ColToRgb(1:8)
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> red      0  223   97   34   40  205  245  158
#> green    0   83  208  151  226   11  199  158
#> blue     0  107   79  230  229  188   16  158