Friday, October 30, 2015

Techniques: Generating colors with HSL and HSV/HSB

Some definitions first:

HSL: Hue Saturation Lightness
HSV: Hue Saturation Value
HSB: Hue Saturation Brightness

HSL != HSV
HSV = HSB (so forget all about the name HSB)

The difference between the two is how the represent the black and white, but they have in common how the represent the actual color referred as hue.

So the colors HSL(h, s1, l) and HSV(h, s2, v) have the same base color in a amount defined by the s1 and s2 and some amount of black or white defined by the l and v.

The point is that these representations can be used in scenarios where classic RGB can't do the work.
  • Imagine a layout (for a site, an application or even a poster) where all elements are darker and brighter versions of the base color.

    All these colors will be HS?(h, a, b) where h shared constant and a, b some values.

    So if h is a variable of some kind, we can change the whole color scheme by adjusting a single value.

  • Imagine a need for a array of colors which have the same saturation - lightness - brightness and change smoothly (for animations, transitions or fractal coloring).

    We can gererate these colors using the formula HS?(i*step, a, b) where i the index of the items in the array and step, a, b some values.


done_