interpolateRainbow function Cyclical schemes

String interpolateRainbow(
  1. num t
)

Given a number t in the range [0,1], returns the corresponding color from interpolateWarm scale from [0.0, 0.5] followed by the interpolateCool scale from [0.5, 1.0], thus implementing the cyclical less-angry rainbow color scheme.

Implementation

String interpolateRainbow(num t) {
  if (t < 0 || t > 1) t -= t.floor();
  var ts = (t - 0.5).abs();
  _c.h = 360 * t - 100;
  _c.s = 1.5 - 1.5 * ts;
  _c.l = 0.8 - 0.9 * ts;
  return _c.toString();
}