float theta = 0; float delta = 0.05; int depthLimit = 8; float scaleFactor = 0.6; void setup() { size(512, 512); frameRate(30); smooth(); } void draw() { background(255); rectMode(CENTER); noStroke(); translate(mouseX, mouseY); rotate(theta); drawPlanet(0); theta += delta; } void drawPlanet(int depth) { if (depth > depthLimit) { return; } fill(240, depth*32, depth*32); rect(0, 0, 90, 90); pushMatrix(); translate(-120, 0); scale(scaleFactor); rotate(theta); drawPlanet(depth+1); popMatrix(); pushMatrix(); translate(120, 0); scale(scaleFactor); rotate(theta); drawPlanet(depth+1); popMatrix(); }