Learn R Programming

plotwidgets (version 0.5.1)

colorConversions: Convert colors from and to RGB and HSL formats

Description

Convert colors from and to RGB and HSL formats

Usage

col2rgb.2(col)

col2hsl(col)

hsl2col(hsl)

rgb2col(rgb)

rgb2hsl(rgb)

hsl2rgb(hsl)

Arguments

col

a character vector with colors to convert (palette)

hsl

a numeric matrix with three or four rows (hue, saturation, luminosity and alpha)

rgb

a numeric matrix with three or four rows (red, green, blue and alpha)

Value

col2rgb.2 and col2hsl return a four-row matrix. rgb2col and hsl2col return a character vector.

Functions

  • col2rgb.2: Convert a character vector of color names (palette) to a matrix with RGB values

  • col2hsl: Convert a character vector of color names (palette) to a matrix with HSL values

  • hsl2col: Convert hsl matrix (3 or 4 row) to character vector of color names

  • rgb2col: Convert rgb matrix (3 or 4 row) to character vector of color names

  • rgb2hsl: Convert a 3- or 4-row matrix of RGB(A) values to a matrix of HSL(A) values

  • hsl2rgb: Convert a matrix of HSL values into a matrix of RGB values

Details

These functions convert between RGB and HSL color spaces, and character vectors which contain color names or hash-encoded RGB values ("#FFCC00").

All functions support an alpha channel. For example, unlike the grDevices::col2rgb, col2rgb.2 returns a matrix with four rows: three for R, G and B channels and one for the alpha channel.

See Also

modCol, modhueCol, darkenCol, saturateCol

Examples

Run this code
# NOT RUN {
haze <- plotPals("haze")
col2rgb(haze)
col2hsl(haze)
# }

Run the code above in your browser using DataLab