Closed feipigzi closed 10 years ago
Yes this is due to the fact that hex/rgb is less accurate than hsla.
What I could do is store the 'original' value of the color and give that a higher precedence over the converted value. Or I could keep track of the unrounded hsla values and use those in my calculations.
Yeah, this is a deal breaker for me. Please fix, I don't think enhancement
is the proper tag for this.
Wait, what do you mean HEX -> RGB conversion is less accurate?
In CSS, rgb(a) only supports integers, whereas hsl(a) supports fractions, this can lead to some minor rounding differences.
On 16 March 2014 13:19, Francisc Romano notifications@github.com wrote:
Wait, what do you mean HEX -> RGB conversion is less accurate?
Reply to this email directly or view it on GitHubhttps://github.com/TheDutchCoder/ColorConvert/issues/10#issuecomment-37763366 .
Yah. This is a deal breaker for myself as well. Could part of the solution be to simply round the HSL to the nearest integer? I've never seen anyone use fractional HSL before.
Also the fact that it takes an HSL and converts it to an HSLA is mighty odd, behaviour wise. Reasonably harmless, but not what I would expect.
I'm currently looking into this issue and it seems to have something to do with rounding numbers (RGB -> HSL can result in some major fractions).
E.g.: In the OP's example, the 94.9% is actually 94.901960784313715%.
I was preparing a system where all values were stored globally, so I'll pursue that in order to get everything accurate.
I seem to have fixed the issue in my latest merge, this should get rid of the inaccuracies!
f2f2f2 //from this one
V rgba(242, 242, 242, 1.0) V hsla(0.0, 0.0%, 94.9%, 1.0)
V
f1f1f1