[Hsv | Hsl]ToRrb returning incorrect values
Hello, I am currently using the version that is on NuGet and I stubbled across this issue by accident. Something in the calculations is incorrect for this method. For example when I pass a HSV or HSL value of {0,0,23} I should be getting back an RGB of {58,58,58}. But instead I'm getting an RGB value of {255,255,255}.
You can replicate the issue by using the following code to test var rgb = new RGB(58, 58, 58); var hsv = ColorConverter.RgbToHsv(rgb); var hsl = ColorConverter.RgbToHsl(rgb); var vrgb = ColorConverter.HsvToRgb(hsv); var lrgb = ColorConverter.HslToRgb(hsl);
Same issue, what is necessary to resolve this? I don't mind putting in the work if the effort is relatively minimal
I had the same issue, but after reading through methods in ColorConverter it seems that the expected ranges are:
HSV.H -> 0 to 360
HSV.S -> 0 to 100
HSV.V -> 0 to 100
With those ranges i get correct results from ColorConverter.HsvToRgb. The range for HSV.H is reasonable, but HSV.S and HSV.V it is just wasted precision. In my opinion all data types of HSV should be float or double and range from 0.0 to 1.0.
The HSL to RGB routine should have this: else { r = modifiedL; g = modifiedL; b = modifiedL; } before the return statement. I don't know if that will help with the HSV problems.
I can confirm that on 1.6.2 grays (so colors like #RRGGBB) convert back to white as described. Fix from @theodoredmason solves this.