ijlyttle / colorpath

Build Color Paths
https://ijlyttle.github.io/colorpath
Other
0 stars 0 forks source link

defining hue as function of luminance #29

Closed ijlyttle closed 4 years ago

ijlyttle commented 4 years ago

One thing coming into focus for me is that continuous palettes are driven by luminance.

Let's say that we can define a surface in HCL space as the collection of points where

hue <- function(lum) {

  h <- hue_0 + (lum / 100) (hue_1 - hue_0) 

  h %% 360
}

Let's postulate that a family of palettes, lets say "blues", can be defined as being drawn along such a surface defined using hue_0 and hue_1.

To specify a palette function, we need would only specify control points using luminance and chroma.

To get the entire set of control points, we would need to calculate the hue, given the luminance, for the family.

ijlyttle commented 4 years ago

Given hue_0 and hue_1, return a function that takes luminance, returns hue.

Given a collection of LC (lumanance-chroma) control points, and a hue-luminance function, return an hcl data-frame.

Maybe something like:

hl_surface <- function(range_hue) {

  # validation for range_hue

  function(lum) {

    hue <- range_hue[1] + lum / 100 * (range_hue[2] - range_hue[1])

    hue %% 360 
  }
}
df_hcl <- function(df_cl, hl_surface) {

  tibble::tibble(
    h = hl_surface(df_cl[["l"]]),
    c = df_cl[["c"]],
    l = df_cl[["l"]]
  )
}