Visual Experiment 02 (Processing)

Tags:

Categories:

,

This code generates its visual output using a triple-nested loop. The outer loops establish a grid across the canvas, while the innermost loop draws a series of shrinking, layered squares at each grid point. The color of each square is randomly determined within the HSB color space, and its position is slightly offset to create a jittering effect. This entire process is captured frame-by-frame to build the final animation.

import gifAnimation.*;
GifMaker gifExport;
int totalFrames = 60;
int currentFrame = 0;

void setup() {
  background(0);
  colorMode(HSB, 360, 100, 100);
  size(800, 800);
  gifExport = new GifMaker(this, "out.gif");
  gifExport.setRepeat(0);
  gifExport.setQuality(10);
  gifExport.setDelay(33);
}

void draw() {


  int size = 80, move = 5, osc=20;

  for (int x=0; x<width+size; x=x+size) {
    for (int y=0; y<width+size; y=y+size) {
      for (int i = size; i>1; i=i-move) {
        noStroke();
        fill(random(0,255), random(0,255), random(0,255));
        rect(x+random(-osc, osc), y+random(-osc, osc), i,i);
      }
    }
  }
  
  gifExport.addFrame();
  currentFrame++;
  if (currentFrame >= totalFrames) {
    gifExport.finish();
    println("GIF saved!");
    noLoop();
  }
}