Learn R Programming

barsurf (version 0.6.1)

63_color_conversion: Color Conversion

Description

Convert color vectors between different color spaces.

Usage

map.color (colvs, string=FALSE, …, from="sRGB", to="HCL", correction=TRUE)
map.color.3 (x, y, z, alpha, string=FALSE, …, from="sRGB", to="HCL", correction=TRUE)

Arguments

colvs

A length-3 or length-4 numeric vector, or 3-column or 4-column numeric matrix. They give the color components for a particular color space, determined by the from argument.

x, y, z, alpha

Same as colvs, except separate vectors for each color component. If alpha is missing, it's equivalent to a 3-column matrix, and if alpha supplied, it's equivalent to a 4-column matrix.

string

Logical, if true, return (R color) strings, if false, return another colvs matrix.

from, to

Strings giving the name of the input and output color spaces. This includes "XYZ", "RGB", "LAB", "polarLAB", "HSV", "HLS", "LUV" and "polarLUV", in addition to "HCL". The to color space is ignored, if string is true.

correction

Logical, if true, apply a correction to sRGB values. Ignored, unless string is false and the to color space is sRGB.

Ignored.

Value

Either a character vector of R color strings, or a 3-column or 4-column matrix of color vectors.

Details

These functions are wrappers for functions in the colorspace package.

At the time of writing, there are problems converting HCL (and PolarLUV) to HSV and HLS.

Examples

Run this code
# NOT RUN {
map.color.3 (0, 0, c (0.25, 0.75) )
map.color.3 (0, 0, c (0.25, 0.75),, TRUE)
# }

Run the code above in your browser using DataLab