interpolateCividis function Sequential schemes

String interpolateCividis(
  1. num t
)

Given a number t in the range [0,1], returns the corresponding color from the “cividis” color vision deficiency-optimized color scheme designed by Nuñez, Anderton, and Renslow, represented as an RGB string.

Implementation

String interpolateCividis(num t) {
  t = max(0, min(1, t));
  return "rgb(${max(0, min(255, (-4.54 - t * (35.34 - t * (2381.73 - t * (6402.7 - t * (7024.72 - t * 2710.57))))).round()))}, ${max(0, min(255, (32.49 + t * (170.73 + t * (52.82 - t * (131.46 - t * (176.58 - t * 67.37))))).round()))}, ${max(0, min(255, (81.24 + t * (442.36 - t * (2482.43 - t * (6167.24 - t * (6614.94 - t * 2475.67))))).round()))})";
}