2

Given hue and saturation of a color (H & S of HSL), how to generate colors in evenly spaced relative luminance level? E.g.

Linear by Luminance screencap Source: http://www.workwithcolor.com/hsl-color-schemer-01.htm

If I give it a pure Red @ 50 relative luminance, how can I mathematically generate RED at different relative luminance in 5 - 10 stops?

Henry
  • 32,689
  • 19
  • 120
  • 221
  • 1
    Well, it's no exactly an algorithm, [but this pretty much explains what it's doing](http://www.workwithcolor.com/color-luminance-2233.htm), with those percentages you can probably work something out. Also [see this related question](http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color). – Wrikken Oct 29 '13 at 21:19
  • @Wrikken actually I cannot figure out the Luminance %. I asked here: http://stackoverflow.com/questions/19689952/how-to-determine-luminance-from-rgb – Henry Oct 30 '13 at 17:36

2 Answers2

1

What I ended up doing is a dumb linear search from 0 to 100 in L of HSL and stop when it reaches one of the Lum stops.

Henry
  • 32,689
  • 19
  • 120
  • 221
0

A lot of interesting things may be found in sources of LESS, which has some built-in color-calculating functions, listed here (search for 'rgb', that will be the first one).

Going to implementation, take a look for their one-liner for luma function, which should return luminance of a color.

Michał Rybak
  • 8,648
  • 3
  • 42
  • 54
  • Thanks, I read the code but it's pretty simplistic because it only manipulates the `L` value in HSL space which does not scale linearly with relative luminance. It does the same thing as "Linear by Lightness" in workwithcolor.com – Henry Oct 30 '13 at 01:03
  • But it also contains calculation formula for luminance. What more do you need? – Michał Rybak Oct 30 '13 at 01:25
  • I need a way to figure out how to generate a number of shades of the same hue & saturation by evenly spaced relative luminance. – Henry Oct 30 '13 at 05:02