EVOLUTION-MANAGER
Edit File: decode_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: Decode RGB hex-strings into colour values</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 decode_colour {farver}"><tr><td>decode_colour {farver}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Decode RGB hex-strings into colour values</h2> <h3>Description</h3> <p>This is a version of <code><a href="../../grDevices/html/col2rgb.html">grDevices::col2rgb()</a></code> that returns the colour values in the standard form expected by farver (matrix with a row per colour). As with <code><a href="encode_colour.html">encode_colour()</a></code> it can do colour conversion on the fly, meaning that you can decode a hex string directly into any of the supported colour spaces. </p> <h3>Usage</h3> <pre> decode_colour(colour, alpha = FALSE, to = "rgb", white = "D65", na_value = NA) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>colour</code></td> <td> <p>A character vector of hex-encoded values or a valid colour name as given in <code><a href="../../grDevices/html/colours.html">grDevices::colours()</a></code>.</p> </td></tr> <tr valign="top"><td><code>alpha</code></td> <td> <p>If <code>TRUE</code> the alpha channel will be returned as well (scaled between 0 and 1). If no alpha channel exists in the colour it will be assumed 1. If <code>FALSE</code> any alpha channel is ignored.</p> </td></tr> <tr valign="top"><td><code>to</code></td> <td> <p>The output 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 output 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> <tr valign="top"><td><code>na_value</code></td> <td> <p>A valid colour string or <code>NA</code> to use when <code>colour</code> contains <code>NA</code> elements. The general approach in farver is to carry <code>NA</code> values over, but if you want to mimick <code><a href="../../grDevices/html/col2rgb.html">col2rgb()</a></code> you should set <code>na_value = 'transparent'</code>, i.e. treat <code>NA</code> as transparent white.</p> </td></tr> </table> <h3>Value</h3> <p>A numeric matrix with a row for each element in <code>colour</code> and either 3, 4, or 5 columns depending on the value of <code>alpha</code> and <code>to</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>See Also</h3> <p>Other encoding and decoding functions: <code><a href="encode_colour.html">encode_colour</a>()</code>, <code><a href="manip_channel.html">manip_channel</a></code> </p> <h3>Examples</h3> <pre> # basic use decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4')) # Return alpha as well (no alpha value is interpreted as 1) decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4'), alpha = TRUE) # Decode directly into specific colour space decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4'), to = 'lch') </pre> <hr /><div style="text-align: center;">[Package <em>farver</em> version 2.0.3 <a href="00Index.html">Index</a>]</div> </body></html>