Comment 23 for bug 166622

Revision history for this message
In , Philippe (philippe-redhat-bugs) wrote :

I said I first though Inkscape used HSV and then HSL, but after looking at the code I am not sure they themselves know what they are using. Indeed, there seems to be confusion between HSV and HSL all over the place:
 - #define values all talk about HSV
 - functions all talk about hsl
as in:

<snip>
347 case SP_COLOR_SCALES_MODE_HSV:
348 sp_color_hsl_to_rgb_floatv (rgb, getScaled(_a[0]), getScaled(_a[1]), getScaled(_a[2]));
<snip>

If the goal is to confuse code readers, they couldn't do a better job.

As you mentioned, one needs to look at how the function
 sp_color_rgb_to_hsl_floatv()
does the conversion in order to know:
 - what really they are using: HSV or HSL
 - if values between 1 and 255 for color components are correctly used.

What remains clear is that:
 1. There is a problem in setting colors in HSL sliders (bug that should be fixed).
 2. The interface is _very_ confusing in setting all sliders in [0,255] for HSL. Nobody does this, it does not make sense (undesirable feature that should be changed to avid confusing users).
 3. The code is also confusing as whether it is using HSL or HSV (a problem for developpers, but a true one that calls for more documentation).

Note finally that restricting (H,S,V) to integers in ([0,360],[0,100],[0,100]) respectively, while being much better that it is now (and conforming to what gimp does), still has one drawback: not all 24-bit RGB values are accessible from other color spaces.

The REALLY NICE answer to this, if RGB values are used internally and they are restricted to 24bit, would actually be to set:
 - R,G and B components to 8-bit unsigned integers (in [0,255])
 - H, S and L components to FLOAT numbers (decimal to be exact):
 - H in [0,360]
 - S and V/L in either [0,1] (absolute) or [0,100] (percent)
  and each time a value is set, convert it to the nearest (R,G,B) valid color.
This way, all possible (valid) RGB values would be accessible through HSL and CMYK also.
But this may be too much to ask, in addition to being different from (but this time better than) what gimp does.

Cheers.