Skip to contents

color class

Usage

class_color(
  color = class_missing,
  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
#> <class_color>
#> @ color: chr "#0000FFFF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#>              brightness, alpha, tex
# Display html hexcode
c(mycolor)
#> [1] "#0000FFFF"
# Set transparency
mycolor@transparentize(.5)
#> <class_color>
#> @ color: chr "#0000FF80"
#> Other props: transparentize, lighten, darken, saturation, hue,
#>              brightness, alpha, tex
# Lighten color
mycolor@lighten(.5)
#> <class_color>
#> @ color: chr "#8282FFFF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#>              brightness, alpha, tex
# Darken color
mycolor@darken(.5)
#> <class_color>
#> @ color: chr "#000082FF"
#> Other props: transparentize, lighten, darken, saturation, hue,
#>              brightness, alpha, tex