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

Incorrect conversion from HCL / LCH to hex or rgb #85

Closed
neil-oliver opened this issue Nov 9, 2020 · 2 comments
Closed

Incorrect conversion from HCL / LCH to hex or rgb #85

neil-oliver opened this issue Nov 9, 2020 · 2 comments

Comments

@neil-oliver
Copy link

neil-oliver commented Nov 9, 2020

Firstly, thank you @mbostock for all of your incredible work, every time i have no clue how i am going to achieve something, it seems that d3 has already created a solution.

One small issue i have spotted is that when creating a d3.hcl object (example used is d3.hcl(15,100,65)) and converting to either rgb or hex (using both .rgb or d3.rgb()), it provides the wrong values. Output from this conversion is #FF0077 and it should be #F8766D.

Tested with d3 5.9.2 & 6.2.0

Edit: The conversion seems to be the same as Chroma.js so maybe this isn't a d3 issue? The output varies massively to this http://hclwizard.org/hclcolorpicker/ which i think is using R to generate the colors / graphics

@danburzo
Copy link
Contributor

danburzo commented Nov 9, 2020

Hi @neil-oliver, it's just a confusion of terms. In the Color space R package, HCL refers to the polar form of the CIELUV color space, while in D3 (and Chroma) HCL refers to the the polar form of the CIELAB color space. See also #64.

@neil-oliver
Copy link
Author

Excellent, thanks for the clear explanation. I will wait for d3.luv to be implemented.

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

No branches or pull requests

2 participants