float distance = 0.0; float speed = 4; float objStep = 40;
color c1, c2; boolean useRect;
void setup(){ size(640, 640, P3D); rectMode(CENTER); mousePressed();
}
void mousePressed(){ c1 = color(255); c2 = color(167); useRect = random(1) < 0.5 ? true: false; }
void draw(){ background(0); lights(); translate(width / 2, height / 2); stroke(c2); strokeWeight(2); noFill(); for(float depth = 0; depth < 1500; depth += objStep){ pushMatrix(); translate(0, 0, depth - distance % objStep); float objSize = map(noise((distance + depth - distance % objStep) * 0.004), 0, 1, 50, 200); if(useRect){ rect(0, 0, objSize, objSize); } else { ellipse(0, 0, objSize, objSize); } popMatrix(); } distance += speed;
noStroke();
fill(255,0,0);
sphere(19);
}