Function: Populate2DArray( )
Populate2DArray(PShape[][] shapeMatrix, int rows, int cols, int cellSize){
color c1=color(157, 83, 56);
color c2 = color(258, 66, 96);
for( int i=0; i< rows; i++){
for( int j=0; j< cols; j++){
int k = i + j;
//calculate fill color
float kFraction = map( k, 0, (rows-1) + (cols-1),0.0, 1.0);
color c3 = lerpColor(c1, c2, kFraction);
//fill( c3 ); ///use map? max of k is 10
PShape curShape;
if( k %2==0){
//create Shape and setFill
curShape = cirPattern( cellSize-10, c3);
} else{
curShape = rectPattern( cellSize-10, c3);
}
shapeMatrix[i][j]= curShape; //store in 2D array
} //end of inner loop (cols)
} //end of outer loop (rows)
return shapeMatrix;
}Populate2DArray - with Color input-paramters
Program using Populate2DArray
Logic to render each PShape at a given x,y location
Last updated