Author Topic: HSL to RGB conversion  (Read 6426 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
HSL to RGB conversion
« on: January 14, 2019, 08:36:12 AM »
Just google it, right? Wrong. I can't find a C++ code for HSL-RGB and back conversion that actually works. I think I can get RGB to HSL work, because the values seem to be ok, but back to RGB fails.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: HSL to RGB conversion
« Reply #1 on: January 14, 2019, 10:59:40 AM »
Never mind, it did work, I was just using too large increments for saturation and lightness. Also, my Range class wasn't working so it didn't clamp values to 1.0, but went slightly over it. Great stuff. And even if it does work my HSV selector routine still needs to figure out what to do when saturation or lightness are zero (there is no hue information). In HSV colorspace case I'm picking the top right color of the selector which is the "pure" hue of the color, but it doesn't work with HSL, because the way lightness works compared to "value" of HSV.