EVOLUTION-MANAGER
Edit File: desaturate.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: Desaturate Colors by Chroma Removal in HCL Space</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 desaturate {colorspace}"><tr><td>desaturate {colorspace}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Desaturate Colors by Chroma Removal in HCL Space</h2> <h3>Description</h3> <p>Transform a vector of given colors to the corresponding colors with chroma reduced (by a tunable amount) in HCL space. </p> <h3>Usage</h3> <pre> desaturate(col, amount = 1, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>col</code></td> <td> <p>vector of R colors. Can be any of the three kinds of R colors, i.e., either a color name (an element of <code><a href="../../grDevices/html/colors.html">colors</a></code>), a hexadecimal string of the form <code>"#rrggbb"</code> or <code>"#rrggbbaa"</code> (see <code><a href="../../grDevices/html/rgb.html">rgb</a></code>), or an integer <code>i</code> meaning <code>palette()[i]</code>. Input <code>col</code> can also be a matrix with three rows containing R/G/B (0-255) values, see details.</p> </td></tr> <tr valign="top"><td><code>amount</code></td> <td> <p>numeric specifying the amount of desaturation where <code>1</code> corresponds to complete desaturation, <code>0</code> to no desaturation, and values in between to partial desaturation.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>additional arguments. If <code>severity</code> is specified it will overrule the input argument <code>amount</code> (for convenience).</p> </td></tr> </table> <h3>Details</h3> <p>If input <code>col</code> is a vector given colors are first transformed to RGB (either using <code><a href="hex2RGB.html">hex2RGB</a></code> or <code><a href="../../grDevices/html/col2rgb.html">col2rgb</a></code>) and then to HCL (<code><a href="polarLUV.html">polarLUV</a></code>). In HCL, chroma is reduced and then the color is transformed back to a hexadecimal string. </p> <p>If input <code>col</code> is a matrix with three rows named <code>R</code>, <code>G</code>, and <code>B</code> (top down) they are interpreted as Red-Green-Blue values within the range <code>[0-255]</code>. The desaturation takes place in the HCL space as well. Instead of an (s)RGB color vector a matrix of the same size as the input <code>col</code> with desaturated Red-Green-Blue values will be returned. This can be handy to avoid too many conversions. </p> <h3>Value</h3> <p>A character vector with (s)RGB codings of the colors in the palette if input <code>col</code> is a vector. If input <code>col</code> is a matrix with R/G/B values a matrix of the same form and size will be returned. </p> <h3>References</h3> <p>Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2019). “ccolorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.” arXiv:1903.06490, arXiv.org E-Print Archive. <a href="http://arxiv.org/abs/1903.06490">http://arxiv.org/abs/1903.06490</a> </p> <h3>See Also</h3> <p><code><a href="polarLUV.html">polarLUV</a></code>, <code><a href="hex.html">hex</a></code>, <code><a href="lighten.html">lighten</a></code> </p> <h3>Examples</h3> <pre> ## rainbow of colors and their desaturated counterparts rainbow_hcl(12) desaturate(rainbow_hcl(12)) ## convenience demo function wheel <- function(col, radius = 1, ...) pie(rep(1, length(col)), col = col, radius = radius, ...) ## compare base and colorspace palettes ## (in color and desaturated) par(mar = rep(0, 4), mfrow = c(2, 2)) ## rainbow color wheel wheel(rainbow_hcl(12)) wheel(rainbow(12)) wheel(desaturate(rainbow_hcl(12))) wheel(desaturate(rainbow(12))) ## apply desaturation directly on RGB values RGB <- t(hex2RGB(rainbow(3))@coords * 255) desaturate(RGB) </pre> <hr /><div style="text-align: center;">[Package <em>colorspace</em> version 1.4-1 <a href="00Index.html">Index</a>]</div> </body></html>