desaturate: Desaturate Colors by Chroma Removal in HCL Space

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/desaturate.R

Description

Transform a vector of given colors to the corresponding colors with chroma removed (collapsed to zero) in HCL space.

Usage

1

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" (see rgb), or an integer i meaning palette()[i].

Details

Given colors are first transformed to RGB (either using hex2RGB or col2rgb) and then to HCL (polarLUV). In HCL, chroma is removed (i.e., collapsed to zero) and then the color is transformed back to a hexadecimal string.

Value

A character vector with (s)RGB codings of the colors in the palette.

Author(s)

Achim Zeileis

See Also

polarLUV, hex

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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)))

colorspace documentation built on May 29, 2017, 8:45 p.m.

Search within the colorspace package
Search all R packages, documentation and source code