rgb.to.hex {plotrix}R Documentation

rgb.to.hex

Description

rgb.to.hex converts the first three values in rgb to a six digit hexadecimal string preceded by a hash character. If all three values are between 0 and 1, all are scaled up to a range of 0-255 unless scale.up is FALSE.

Usage

 rgb.to.hex(rgb,scale.up=TRUE)

Arguments

rgb A numeric vector of length at least 3 representing the relative red, green and blue values. Each value must be between 0 and 255.
scale.up A logical value indicating whether to scale up when all values are between 0 and 1.

Value

hexadecimal color

See Also

gradient.rect

Examples

 # a light purple color in a 0-1 format
 rgb.to.hex(c(0.9,0.5,0.9))
 # supressing the scaling gives almost pure black
 rgb.to.hex(c(0.9,0.5,0.9),FALSE)

[Package plotrix version 1.2-1 Index]