Use d50 white point instead of d65 in HCL/LAB color spaces #146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See: maplibre/maplibre-gl-js#2382
The RGB -> HCL code in https://github.com/maplibre/maplibre-gl-js/blob/main/src/style-spec/util/color_spaces.ts forked out of d3-color in 2016. It uses the D65 illuminant in all of its intermediate color spaces. In 2018 d3-color was modified to convert from D65 to D50 (see discussion at d3/d3-color#42). The CSS spec recommends using D50 to convert to LAB (which is the step before converting to HCL).
This PR updates the code using constants derived from the modern d3-color (:wave: thank you @mbostock!), with a link to the helpful explanation at https://observablehq.com/@mbostock/lab-and-rgb.
@kajkal put together a very helpful demo showing the effect of this change (along with many other recent changes they've been working on): https://kajkal.github.io/maplibre-gl-style-spec-color-demo/swipe.html. By swiping up and down, you can see the d65 vs d50. The difference is subtle, but if you look at the "blue->white" section of the "interpolate-hcl" line, you can see that with d65 the whole range of colors looks whiter than with d50.
This does change existing behavior, but in a pretty subtle way, and no APIs/documentation etc. need to change as far as I'm aware. As @kajkal points out, there were much bigger problems (and fixes) in color handling that will go into the 3.x maplibre-gl release, and I hope this will just be an extra bit of tidying up.
Launch Checklist
CHANGELOG.md
under the## main
section.