-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling hsl function with a hex code is slightly off #59
Comments
Hmm... Yeah converting between RGB and HSL is sort of fuzzy because there's some amount of As you say, the difference is tiny, probably nearing imperceptibility for all but the lucky people on $40k displays?
I imagine if I were to find a way for it to be lossless here, it would just end up being lossy for another color (i.e clamp up vs clamp down). I will leave this open until I can find time to check how much drift is in the conversion, maybe some colors have more. I imagine they are nearly all within a point of each other though. |
Sorry meant to post back on this. I did investigate further. The nature of converting between RGB and HSL often leads to fractional HSL values (i.e. 32.42% saturation), which end up getting munged. Even the HSLuv library, which at least gives the impression of being made by someone pretty "into colors" has the same effect. I don't think it's actually a problem in use though, here's a random set of colors pushed through
And a comparison of the first pair, I can't really spot the seam between the two, it will be monitor and eye dependent though. Maybe the bottom one is darker, maybe sort of? Maybe?: Pretty interestingly, if you convert both RGB colors to HSL, you get the same values, so they are identical in the HSL colorspace: They're actually equal in HSL, HSB and drift by 1 in LAB and CMYK. I think you're more likely to notice differences when swapping terminals or monitors than the slight drift in RGB. Going to close this as I think it's:
It is an annoying quirk though. If you (or anyone) finds a colour that is obviously incorrect, definitely reopen. |
I stumbled upon this while tweaking https://github.com/npxbr/gruvbox.nvim which is based on lush.nvim. Using
hsl('#aabbcc')
results in a slightly different color in the highlight.It was fairly easy to reproduce, I just ran
:LushRunQuickstart
, followed by:Lushify
and changed the highlight of the search, followed by running:hi Search
to see the difference:As you can see,
#cc241d
becomes#cd231d
in the highlight.Is this by design? I'm no color expert but I seem to recall converting between RGB and HSL can be lossy. To me the difference is not so big that I notice it, but I kind of expect that colors set by hex RGB stays the same since
:hi
takes hex RGB codes.The text was updated successfully, but these errors were encountered: