Create HSL Value from Numeric RGB Intensities

DESCRIPTION:

Computes the HSL value equivalent to a specific RGB triplet such as {255, 0, 0} .

USAGE:

rgb2hsl(r, g=NULL, b=NULL, gamma=1, maxColorValue=255)

REQUIRED ARGUMENTS:

r
Red intensity between 0 and maxColorValue. Can also be a three row matrix of RGB values in the form returned by col2rgb().
g
Green intensity between 0 and maxColorValue.
b
Blue intensity between 0 and maxColorValue.

OPTIONAL ARGUMENTS:

gamma
Gamma correction. Single value.
maxColorValue
Maximum color value. The default is 255, so the RGB values are between 0 and 255. The other commonly used value is 1, so the RGB intensities are between 0 and 1.

VALUE:

Returns a 3 row matrix with rows containing values between 0 and 1 giving the h , s , and l for each color.

SIDE EFFECTS:

None.

SEE ALSO:

, .

EXAMPLES:

# Create colors from HSL values, then convert back to HSL
a <- hsl(h=seq(0.1, 0.9, length=16), s=0.75, l=0.5)
rgb2hsl(col2rgb(a))