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

Update chroma.js #16

Closed
devgru opened this issue Apr 27, 2016 · 6 comments
Closed

Update chroma.js #16

devgru opened this issue Apr 27, 2016 · 6 comments

Comments

@devgru
Copy link

devgru commented Apr 27, 2016

Newer versions of chroma.js changes HCL representation (called LCH somewhy), same as in D3.js.
Updating the library will make colors with C=0 true grayscale instead of yellowish.

Any version of chroma.js >=0.4.8 will do.
Check the commit with mentioned changes at chroma.js repo: gka/chroma.js@42dd32a

@jacomyma
Copy link
Member

jacomyma commented May 4, 2016

Yes that will fix a number of current issues! I'm in the process of updating the tool, but the change is bigger than I expected and impacts many aspects.

The biggest issue is that previous Chroma returned NaN when the conversion from Lab to RGB was impossible (out of bound coordinates). Now it always returns a color, which is a feature but prevents me from detecting when the coordinates are out of bound. Once this is fixed, I'll ship it!

@devgru
Copy link
Author

devgru commented May 4, 2016

For color validation I recommend using D3 v4 module called d3-color.

Mike Bostock created displayable() function so you just check it like

d3_color.rgb({r, g, b}).displayable()
d3_color.lab({l, a, b}).displayable()

See d3/d3-color#10 (comment)

@jacomyma
Copy link
Member

jacomyma commented May 4, 2016

Thanks for this advice :) !

@jacomyma
Copy link
Member

jacomyma commented May 4, 2016

I updated Chroma. I did not implement your suggestion and sticked to a tweak copied from Chroma source code. I think the next step would be to package the library into a d3 compatible module not requiring Chroma, but that's for another time! Thanks for your suggestions anyway.

@jacomyma jacomyma closed this as completed May 4, 2016
@devgru
Copy link
Author

devgru commented May 5, 2016

You're welcome!

BTW looks like colors at http://tools.medialab.sciences-po.fr/iwanthue/ are still yellowish with C=0.

@jacomyma
Copy link
Member

jacomyma commented May 5, 2016

The repo is up to date but not yet the online website. In a few days.

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