HSL quicky - not quite HSV

Here’s a quicky HSL function, with a minimal pattern to play with it.

export var hue,sat1,sat2,value,lightness
export function sliderSat(v){
  sat1 = v
}
export function sliderLightness(v){
  lightness = v
}

function hsl(h,s,l){
  value = s * min(l,1-l) + l 
  sat2 = value ? 2-(2*l/value) : 0
  hsv(h,sat2,value);
}

export function beforeRender(delta) {
  t1 = time(.1)
}

export function render(index) {
  hue = t1 + index/pixelCount
  hsl(hue, sat1, lightness)
}

Basically, if you play with slider, you’ll see that it basically adjusts S back up as Lightness increases, so it goes back to white.

HSL isn’t super useful, but I’m working on porting some code that uses HSL rather than HSV, so adding a simple hsl() makes the most sense.

2 Likes