Complex gradient loop

You have to keep the rest of the code that creates the PImage. And because you have 6 points, you have to set N to 6 at the top or can set it to N = pos.length; after creating the pos array as I did in the code below.

void initControlPoints() {
float[][] pos = {
  { 525, 150 }, { 990, 500 }, { 550, 925 },
  { 275, 725 }, { 500, 125 }, { 250, 200 }
};
color[] cols = { 
  color( 179, 100, 100 ), color( 68, 100, 100 ), color( 303, 100, 100 ),
  color( 299, 100, 100 ), color( 276, 100, 100 ), color( 193, 100, 100 )
};

  N = pos.length;
  inputs = createImage( N, 2, ARGB );
  inputs.loadPixels();
  for( int i=0; i<N; i++ ) {
    int x = (int)(65536 * pos[i][0] / grad.width);
    int y = (int)(65536 * pos[i][1] / grad.height);
    inputs.pixels[ i ] = (x << 16) | y;
    inputs.pixels[ i+N ] = cols[i];
  }
  inputs.updatePixels();
  gradShader.set( "inputs", inputs );
  gradShader.set( "N", N );
}