Visual Experiment 09 (Processing)

Tags:

Nested loops allow us to perform multiple iterations, as in this example, where by combining three nested loops, we can generate a pattern of concentric circles which, depending on the size of the canvas, can be repeated indefinitely.

void setup() {
  size(800, 800);
}

void draw() {
  background(20);
  noFill();
  stroke(255, 150, 0, 150);
  strokeWeight(3);

  int grid = 100;
  
  for (int i = grid; i < width; i += grid) {
    for (int j = grid; j < height; j += grid) {
      

      for (int k = 80; k > 0; k -= 9) {

        ellipse(i, j, k, k);
      }
    }
  }
  noLoop();
}