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

interpolateHcl and achromatic colors #50

Closed
danburzo opened this issue Apr 4, 2018 · 2 comments
Closed

interpolateHcl and achromatic colors #50

danburzo opened this issue Apr 4, 2018 · 2 comments

Comments

@danburzo
Copy link

danburzo commented Apr 4, 2018

Interpolating red and white in Lab and HCL:

screen shot 2018-04-04 at 15 29 10

Due to the particular HCL hue of achromatic colors (~ 158.2° in the current implementation of d3-color), when interpolating a chromatic and achromatic color, the non-zero Chroma of the interpolated color will pick up various hues.

In comparison, chroma.js will not interpolate the hue in this case, with a more predictable (and analogous to Lab) outcome:

screen shot 2018-04-04 at 15 35 12

Should interpolateHcl behave the same?

@mbostock
Copy link
Member

mbostock commented Apr 4, 2018

The bug here (if there is one, and I think there is) is that the hue for white (or another achromatic color) is a number rather than NaN. If the hue is NaN then the interpolator will do the right thing.

Previously I thought that the non-NaN (NNaN) hue for white was an artifact of the D65 referent but it seems I was mistaken. We should fix this as part of your work to make d3.lab and d3.lch consistent with other implementations.

(Also would be great to implement chroma clamping…)

@mbostock
Copy link
Member

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