Learn R Programming

VFP (version 1.4.3)

as_rgb: Convert Color-Name or RGB-Code to Possibly Semi-Transparent RGB-code.

Description

Function takes the name of a color and converts it into the rgb space. Parameter "alpha" allows to specify the transparency within [0,1], 0 meaning completey transparent and 1 meaning completey opaque. If an RGB-code is provided and alpha != 1, the RGB-code of the transparency adapted color will be returned.

Usage

as_rgb(col = "black", alpha = 1)

Value

RGB-code

Arguments

col

(character) name of the color to be converted/transformed into RGB-space (code). Only those colors can be used which are part of the set returned by function colors(). Defaults to "black".

alpha

(numeric) value specifying the transparency to be used, 0 = completely transparent, 1 = opaque.

Author

Andre Schuetzenmeister andre.schuetzenmeister@roche.com

Examples

Run this code
# convert character string representing a color to RGB-code
# using alpha-channel of .25 (75\% transparent)
as_rgb("red", alpha=.25)

# same thing now using the RGB-code of red (alpha=1, i.e. as_rgb("red"))
as_rgb("#FF0000FF", alpha=.25)

Run the code above in your browser using DataLab