Closed
Description
Something like this maybe:
modify_hcl <- function(x, h, c, l) {
hcl <- as.data.frame(farver::decode_colour(x, to = "hcl"))
if (!missing(h)) {
h <- eval(substitute(h), envir = hcl)
} else {
h <- hcl$h
}
if (!missing(c)) {
c <- eval(substitute(c), envir = hcl)
} else {
c <- hcl$c
}
if (!missing(l)) {
l <- eval(substitute(l), envir = hcl)
} else {
l <- hcl$l
}
farver::encode_colour(cbind(h, c, l), from = "hcl")
}
Idea is to make it easy to do (e.g.) modify_hcl(x, h = 25)
or modify_hcl(x, h = h + 10)