// Example of using a while loop void setup () { size(400, 400); background(200); } void draw () { background(50); int xCoord = mouseX; int yCoord = mouseY; int numColumns = 8; boolean squareIsBlack = true; int numRows = 8; while (numRows > 0) { numColumns = 8; xCoord = mouseX; while (numColumns > 0) { if (squareIsBlack == true) { fill(0); // Draw a black rectangle } else { fill(255, 0, 0); // Draw a red square } rect(xCoord, yCoord, 25, 25); xCoord = xCoord + 25; numColumns = numColumns - 1; squareIsBlack = !squareIsBlack; } // ends inner while loop (row) squareIsBlack = !squareIsBlack; numRows = numRows - 1; yCoord = yCoord + 25; // Drop down } }