d3/d3-interpolate

cubehelixDefault and rainbow?

mbostock opened this issue · 2 comments

Perhaps these could be simple interpolators (taking an argument t in [0,1]) that returns the corresponding color, as is currently implemented in d3-scale.

Specifically:

var rainbow1 = cubehelixLong(color.cubehelix(-100, 0.75, 0.35), color.cubehelix(80, 1.50, 0.8)),
    rainbow2 = cubehelixLong(color.cubehelix(80, 1.50, 0.8), color.cubehelix(260, 0.75, 0.35));

// Maybe t % 1?
export function rainbow(t) {
  return t < 0.5 ? rainbow1(t * 2) : rainbow2((t - 0.5) * 2);
};

And:

export var cubehelixDefault = cubehelixLong(color.cubehelix(300, 0.5, 0.0), color.cubehelix(-240, 0.5, 1.0));

I don’t think this is a good fit for the d3-interpolate module because these interpolators are designed to interpolate between two arbitrary values, not two pre-determined values. So d3-scale seems like the right place for the above… Although, my opinion is not strong.