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

cmocean color interpolators? #27

Open
Fil opened this issue Jun 14, 2020 · 4 comments
Open

cmocean color interpolators? #27

Fil opened this issue Jun 14, 2020 · 4 comments

Comments

@Fil
Copy link
Member

Fil commented Jun 14, 2020

Mike:

http://matplotlib.org/cmocean/
it would be nice to have some approximations using d3.interpolateRgbBasis as I did for ColorBrewer in d3-scale-chromatic.

(from d3/d3-scale#71)

@Fil
Copy link
Member Author

Fil commented Jun 14, 2020

One can retrieve the color schemes directly from https://github.com/mikeperrins/cmocean-LUT-ImageJ:

const lut = name => d3.tsv(
      `https://raw.githubusercontent.com/mikeperrins/cmocean-LUT-ImageJ/master/${name}.lut`,
      d => d3.rgb(d["Red"], d["Green"], d["Blue"])
    )
    .then(l => t => l[(t * 256) | 0]);

const l = await lut("Ice");

l(0.5).toString(); // "rgb(66, 122, 183)"

(see https://observablehq.com/@fil/cmocean )

the next step would be to extract key colors for the spline interpolation:
https://bl.ocks.org/mbostock/048d21cf747371b11884f75ad896e5a5

@Fil
Copy link
Member Author

Fil commented Jul 5, 2020

The monotone RGB interpolation on 11 evenly-spaced control points is almost perfect for: Algae, Amp, Delta, Dense, Gray, Ice, Matter, Solar, Speed, Tempo, Thermal, Turbid.

For Haline, Phase we might need a few more control points or adjustments.

For Balance, Curl, Deep, Oxy, however, the interpolation strategy can't reproduce the brutal transitions, and it will need a bit more work (cutting each of them in two or three parts interpolated separately then rejoined), or we could have them as a 256-color array, depending on which approach gives the smallest file size(?).

@Fil
Copy link
Member Author

Fil commented Jul 21, 2020

See also https://observablehq.com/@fil/cmasher for the CMasher collection (https://cmasher.readthedocs.io/)

@Fil
Copy link
Member Author

Fil commented Dec 1, 2021

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

1 participant