color class
Usage
class_color(
color = character(0),
hue = NULL,
saturation = NULL,
brightness = NULL,
alpha = NULL
)
Arguments
- color
character (R color or hex code)
- hue
get or set the hue of a color (i.e., the h in the hsv model)
- saturation
get or set the saturation of a color (i.e., the s in the hsv model)
- brightness
get or set the brightness of a color (i.e., the v in the hsv model)
- alpha
get or set the transparency of a color
Slots
transparentize
function to return the color with a new transparency (i.e., alpha)
lighten
function to return a lighter color
darken
function to return a darker color
Examples
mycolor <- class_color("blue")
mycolor
#> <ggdiagram::class_color>
#> @ color: chr "#0000FFFF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#> brightness, alpha, red, green, blue, mean, tex
# Display html hexcode
c(mycolor)
#> [1] "#0000FFFF"
# Set transparency
mycolor@transparentize(.5)
#> <ggdiagram::class_color>
#> @ color: chr "#0000FF80"
#> Other props: transparentize, lighten, darken, saturation, hue,
#> brightness, alpha, red, green, blue, mean, tex
# Lighten color
mycolor@lighten(.5)
#> <ggdiagram::class_color>
#> @ color: chr "#8282FFFF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#> brightness, alpha, red, green, blue, mean, tex
# Darken color
mycolor@darken(.5)
#> <ggdiagram::class_color>
#> @ color: chr "#000082FF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#> brightness, alpha, red, green, blue, mean, tex