code: public static Color[] jet(int n, float alpha) {
          int m = (int) Math.ceil(n / 4);
  
          float[] u = new float[3 * m];
          for (int i = 0; i < u.length; i++) {
              if (i == 0) {
                  u[i] = 0.0f;
              } else if (i <= m) {
                  u[i] = i / (float) m;
              } else if (i <= 2 * m - 1) {
                  u[i] = 1.0f;
              } else {
                  u[i] = (3 * m - i) / (float) m;
              }
  
          }
  
          int m2 = m / 2 + m % 2;
          int mod = n % 4;
          int[] r = new int[n];
          int[] g = new int[n];
          int[] b = new int[n];
          for (int i = 0; i < u.length - 1; i++) {
              if (m2 - mod + i < n) {
                  g[m2 - mod + i] = i + 1;
              }
              if (m2 - mod + i + m < n) {
                  r[m2 - mod + i + m] = i + 1;
              }
              if (i > 0 && m2 - mod + i < u.length) {
                  b[i] = m2 - mod + i;
              }
          }
  
          Color[] palette = new Color[n];
          for (int i = 0; i < n; i++) {
              palette[i] = new Color(u[r[i]], u[g[i]], u[b[i]], alpha);
          }
  
          return palette;
      }
docs: Generate jet color palette.
  @param n the number of colors in the palette.
  @param alpha the parameter in [0,1] for transparency.