Combine colors to generate a new color
Arguments
- color
CHARACTER. color vector e.g see example
- type
NUMERIC. return type of the output
- alpha
NUMERIC. alpha or opacity of the resulting color
Examples
# color vector
colvec <- c("red", "blue", "violet", "green", "#ff0066")
# just one color
mix.color(colvec[1], type = 1, alpha = 1)
#> [1] "#FF0000FF"
# add two colors
mix.color(colvec[1:2], type = 1, alpha = 1)
#> [1] "#7F007FFF"
# add three colors
mix.color(colvec[1:3], type = 1, alpha = 1)
#> [1] "#A42BA4FF"
# return type = 2
# just one color
mix.color(colvec[1], type = 2, alpha = 1)
#> [1] "#FF0000FF"
# add two colors
mix.color(colvec[1:2], type = 2, alpha = 1)
#> [1] "#800080FF"
# add three colors
mix.color(colvec[1:3], type = 2, alpha = 1)
#> [1] "#A42BA4FF"
# opacity or alpha 0.5
# just one color
mix.color(colvec[1], type = 1, alpha = 0.5)
#> [1] "#FF00007F"
# add two colors
mix.color(colvec[1:2], type = 1, alpha = 0.5)
#> [1] "#7F007F7F"
# add three colors
mix.color(colvec[1:3], type = 1, alpha = 0.5)
#> [1] "#A42BA47F"
# add all colors
mix.color(colvec, type = 1, alpha = 0.5)
#> [1] "#954D777F"