Skip to contents

mix_col() simulates subtractive (pigment) color mixing by converting input colors to Munsell notation via aqp::col2Munsell(), mixing them with aqp::mixMunsell(), and converting the result back to an R color string via aqp::parseMunsell().

Usage

mix_col(..., w = NULL, mixingMethod = "adaptive")

Arguments

...

Colors to mix. Can be individual color strings or character vectors; all are combined into a single vector.

w

A numeric vector of weights or proportions the same length as the combined color vector. Defaults to equal weights.

mixingMethod

Mixing method passed to aqp::mixMunsell().

Value

A single R color string in hex notation.

See also

mean_col() for a simpler quadratic-mean RGB approach (no extra packages required).

Examples

should_run_ex <- requireNamespace("aqp", quietly = TRUE) &&
    (interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true"))
if (should_run_ex) {
  mix_col(c("red", "blue"))
}
#> [1] "#C2008FFF"
if (should_run_ex) {
  mix_col("red", "yellow", "blue", w = c(2, 1, 1))
}
#> [1] "#F46666FF"