Nested for loop

void setup() {
  size(400, 400);
  background(0);
  smooth();
  stroke(255, 50);
  //noStroke();
}

void draw() {
  
  for(int i = 0; i < width; i+=50) {
    
    for(int j = 0; j < height; j+=50) {
      fill(100, 0, 150, 100);
      ellipse(25 + i, 25 + j, 50, 50);
      fill(20, 100, 0, 50);
      rect(i, j, 50, 50);
      println("i = " + i + " j = " + j);
    }
    
  }
  
}

source

Comments are closed.