xxxxxxxxxx
// Circles drawn using recursion.
// sin, cos, frameCount, abs, translate, ellipse, recursion, recursive, grayscale
// Mouse click toggles display.
float howFast;
boolean thisWay;
void setup() {
size(500, 500);
thisWay = true;
}
void draw() {
background(245);
howFast = frameCount *.005;
translate(width/2, height/2);
rotate(sin(howFast));
drawCircle(0, 0, abs(sin(howFast) * 405), abs(cos(howFast) * 405), 0);
}
void drawCircle(float x, float y, float s, float p, int l) {
l++;
if (l > 5) return;
else {
stroke(60);
strokeWeight(.3);
fill(0, 5);
if (thisWay) ellipse(x, y, p, s);
else ellipse(x, y, s, s);
s = s/3;
p = p/3;
drawCircle(x, y, s, p, l);
drawCircle(x+p, y, s, p, l);
drawCircle(x, y+p, s, p, l);
drawCircle(x-p, y, s, p, l);
drawCircle(x, y-p, s, p, l);
}
}
void mousePressed() {
thisWay = !thisWay;
}