EVOLUTION-MANAGER
Edit File: col2rgb.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Color to RGB Conversion</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for col2rgb {grDevices}"><tr><td>col2rgb {grDevices}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Color to RGB Conversion</h2> <h3>Description</h3> <p><span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> color to RGB (red/green/blue) conversion. </p> <h3>Usage</h3> <pre> col2rgb(col, alpha = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>col</code></td> <td> <p>vector of any of the three kinds of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> color specifications, i.e., either a color name (as listed by <code><a href="colors.html">colors</a>()</code>), a hexadecimal string of the form <code>"#rrggbb"</code> or <code>"#rrggbbaa"</code> (see <code><a href="rgb.html">rgb</a></code>), or a positive integer <code>i</code> meaning <code><a href="palette.html">palette</a>()[i]</code>.</p> </td></tr> <tr valign="top"><td><code>alpha</code></td> <td> <p>logical value indicating whether the alpha channel (opacity) values should be returned.</p> </td></tr> </table> <h3>Details</h3> <p><code><a href="../../base/html/NA.html">NA</a></code> (as integer or character) and <code>"NA"</code> mean transparent. </p> <p>Values of <code>col</code> not of one of these types are coerced: real vectors are coerced to integer and other types to character. (factors are coerced to character: in all other cases the class is ignored when doing the coercion.) </p> <p>Zero and negative values of <code>col</code> are an error. </p> <h3>Value</h3> <p>An integer matrix with three or four (for <code>alpha = TRUE</code>) rows and number of columns the length of <code>col</code>. If <code>col</code> has names these are used as the column names of the return value. </p> <h3>Author(s)</h3> <p>Martin Maechler and the R core team. </p> <h3>See Also</h3> <p><code><a href="rgb.html">rgb</a></code>, <code><a href="colors.html">colors</a></code>, <code><a href="palette.html">palette</a></code>, etc. </p> <p>The newer, more flexible interface, <code><a href="convertColor.html">convertColor</a>()</code>. </p> <h3>Examples</h3> <pre> col2rgb("peachpuff") col2rgb(c(blu = "royalblue", reddish = "tomato")) # note: colnames col2rgb(1:8) # the ones from the palette() (if the default) col2rgb(paste0("gold", 1:4)) col2rgb("#08a0ff") ## all three kinds of color specifications: col2rgb(c(red = "red", hex = "#abcdef")) col2rgb(c(palette = 1:3)) ##-- NON-INTRODUCTORY examples -- grC <- col2rgb(paste0("gray", 0:100)) table(print(diff(grC["red",]))) # '2' or '3': almost equidistant ## The 'named' grays are in between {"slate gray" is not gray, strictly} col2rgb(c(g66 = "gray66", darkg = "dark gray", g67 = "gray67", g74 = "gray74", gray = "gray", g75 = "gray75", g82 = "gray82", light = "light gray", g83 = "gray83")) crgb <- col2rgb(cc <- colors()) colnames(crgb) <- cc t(crgb) # The whole table ccodes <- c(256^(2:0) %*% crgb) # = internal codes ## How many names are 'aliases' of each other: table(tcc <- table(ccodes)) length(uc <- unique(sort(ccodes))) # 502 ## All the multiply named colors: mult <- uc[tcc >= 2] cl <- lapply(mult, function(m) cc[ccodes == m]) names(cl) <- apply(col2rgb(sapply(cl, function(x)x[1])), 2, function(n)paste(n, collapse = ",")) utils::str(cl) ## Not run: if(require(xgobi)) { ## Look at the color cube dynamically : tc <- t(crgb[, !duplicated(ccodes)]) table(is.gray <- tc[,1] == tc[,2] & tc[,2] == tc[,3]) # (397, 105) xgobi(tc, color = c("gold", "gray")[1 + is.gray]) } ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>grDevices</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>