Skip to content
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

hsluvToRgb returns negative values for saturation 100 #50

Open
vorg opened this issue Apr 12, 2018 · 1 comment
Open

hsluvToRgb returns negative values for saturation 100 #50

vorg opened this issue Apr 12, 2018 · 1 comment

Comments

@vorg
Copy link

vorg commented Apr 12, 2018

For saturation 100 quite often I get RGB results with one of the components slightly below zero:

hsluv.hsluvToRgb([171, 100, 55])
//[-3.261485526095953e-13, 0.5825533896631454, 0.5048262083306216]

I've noticed that while working on my HSLuv color picker. As i convert hsluv to float RGB and then back to hex using pex-color/index.js#L305. If I use your hsluv.hsluvToHex it works correctly.

Wrong:
screen shot 2018-04-12 at 08 51 04

Expected:
screen shot 2018-04-12 at 08 50 27

Test case on runkit https://runkit.com/embed/5s9atejnf98j

@boronine
Copy link
Member

Thank you for the report. The fix is really easy in code, but I have to look into floating point error first, not sure what's best practices are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants