a numeric vector of red intensity values between 0
and
maxColorValue.
Alternatively,
this can be a matrix or data frame whose first three columns
contain the
red, green and
blue values.
In that case, the
green and
blue
arguments should not be supplied.
green
a numeric vector of green intensity values between 0
and
maxColorValue.
blue
a numeric vector of blue intensity values between 0
and
maxColorValue.
OPTIONAL ARGUMENTS:
alpha
alpha intensity between 0 and maxColorValue.
When not specified, the fully opaque color is used,
e.g. alpha of 255 on the 0 to 255 scale.
names
names for the resulting vector.
maxColorValue
maximum color value. The default is 1, so RGB intensities are between 0 and 1.
The other commonly used value is 255, in which case the RGB values are
rounded to the closest integer between 0 and 255.
VALUE:
Character vector of RGB values in the form
"#FF0000" when the color is
fully opaque, and
"#FF000080" when it is semi-translucent.
If
names is not
NULL,
this will be a named vector with the specified names.
SIDE EFFECTS:
None.
SEE ALSO:
.
EXAMPLES:
# Generate a sequence of gray values
x <- seq(0, 1, length=100)
rgb(x, x, x)
# Generate the colors "lavender" {230, 230, 250}
# and "olive" {128, 128, 0} and return a named vector
rgb(red=c(230, 128), green=c(230, 128), blue=c(250, 0),
names=c("lavender", "olive"), max=255)
# Generate a sequence of semi-transparent reds
rgb(1, 0, 0, alpha=seq(0, 1, length=20))
# Generate 10 random color values
umat <- matrix(runif(30), ncol=3)
rgb(umat)