Degree-6 RGB polynomial (Matt Zucker's matplotlib fits), Horner-evaluated. viridis and plasma differ only by this coefficient table (c[0]..c[6]).
| 34 | // Degree-6 RGB polynomial (Matt Zucker's matplotlib fits), Horner-evaluated. |
| 35 | // viridis and plasma differ only by this coefficient table (c[0]..c[6]). |
| 36 | [[nodiscard]] ColormapRgb evalPoly(const ColormapRgb (&c)[7], float t) noexcept { |
| 37 | t = std::clamp(t, 0.0f, 1.0f); |
| 38 | ColormapRgb acc = c[6]; |
| 39 | for (int i = 5; i >= 0; --i) { |
| 40 | acc = {c[i].r + t * acc.r, c[i].g + t * acc.g, c[i].b + t * acc.b}; |
| 41 | } |
| 42 | return acc; |
| 43 | } |
| 44 | |
| 45 | [[nodiscard]] ColormapRgb viridis(float t) noexcept { |
| 46 | static constexpr ColormapRgb kCoeffs[7] = { |