EVOLUTION-MANAGER
Edit File: encode_colour.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: Encode colours into RGB hex-strings</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 encode_colour {farver}"><tr><td>encode_colour {farver}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Encode colours into RGB hex-strings</h2> <h3>Description</h3> <p>This is a version of <code><a href="../../grDevices/html/rgb.html">grDevices::rgb()</a></code> that works with the standard colour format used in farver (matrix or data.frame with colours in rows). It further support taking input from any colour space. </p> <h3>Usage</h3> <pre> encode_colour(colour, alpha = NULL, from = "rgb", white = "D65") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>colour</code></td> <td> <p>A numeric matrix (or an object coercible to one) with colours encoded in the rows and the different colour space values in the columns. For all colourspaces except <code>'cmyk'</code> this will mean a matrix with three columns - for <code>'cmyk'</code> it means four columns.</p> </td></tr> <tr valign="top"><td><code>alpha</code></td> <td> <p>A numeric vector between 0 and 1. Will be recycled to the number of rows in <code>colour</code>. If <code>NULL</code> or a single <code>NA</code> it will be ignored.</p> </td></tr> <tr valign="top"><td><code>from</code></td> <td> <p>The input colour space. Allowed values are: <code>"cmy"</code>, <code>"cmyk"</code>, <code>"hsl"</code>, <code>"hsb"</code>, <code>"hsv"</code>, <code>"lab"</code> (CIE L*ab), <code>"hunterlab"</code> (Hunter Lab), <code>"lch"</code> (CIE Lch(ab) / polarLAB), <code>"luv"</code>, <code>"rgb"</code> (sRGB), <code>"xyz"</code>, <code>"yxy"</code> (CIE xyY), or <code>"hcl"</code> (CIE Lch(uv) / polarLuv)</p> </td></tr> <tr valign="top"><td><code>white</code></td> <td> <p>The white reference of the input colour space. Will only have an effect for relative colour spaces such as Lab and luv. Any value accepted by <code><a href="as_white_ref.html">as_white_ref()</a></code> allowed.</p> </td></tr> </table> <h3>Value</h3> <p>A character vector with colours encoded as <code style="white-space: pre;">#RRGGBB(AA)</code> </p> <h3>Handling of non-finite and out of bounds values</h3> <p><code>NA</code>, <code>NaN</code>, <code>-Inf</code>, and <code>Inf</code> are treated as invalid input and will result in <code>NA</code> values for the colour. If a given colourspace has finite bounds in some of their channels, the input will be capped before conversion, and the output will be capped before returning, so that both input and output colours are valid colours in their respective space. This means that converting back and forth between two colourspaces may result in a change in the colour if the gamut of one of the spaces is less than the other. </p> <h3>Note</h3> <p>The output may differ slightly from that of <code><a href="../../grDevices/html/rgb.html">grDevices::rgb()</a></code> since <code>rgb()</code> doesn't round numeric values correctly. </p> <h3>See Also</h3> <p>Other encoding and decoding functions: <code><a href="decode_colour.html">decode_colour</a>()</code>, <code><a href="manip_channel.html">manip_channel</a></code> </p> <h3>Examples</h3> <pre> spectrum <- decode_colour(rainbow(10)) encode_colour(spectrum) # Attach alpha values encode_colour(spectrum, alpha = c(0.5, 1)) # Encode from a different colour space spectrum_hcl <- convert_colour(spectrum, 'rgb', 'hcl') encode_colour(spectrum_hcl, from = 'hcl') </pre> <hr /><div style="text-align: center;">[Package <em>farver</em> version 2.0.3 <a href="00Index.html">Index</a>]</div> </body></html>