Skip to content

Easy way to manipulate individual hcl axes? #20

Closed
@hadley

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)

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions