int niveauMax = 50;
float angleInc = 0.0;
void setup() {
size(400,400);
smooth();
stroke(255);
strokeWeight(0.3);
strokeCap(ROUND);
}
void draw() {
background(0);
branche(width*0.5,height*0.5+25,50,-HALF_PI,true,0);
angleInc = (angleInc+0.002)%TWO_PI;
}
void branche(float x,float y,float longueur,float angle,boolean droite,int niveau) {
if(niveau>niveauMax) return;
float newx = x+cos(angle)*longueur;
float newy = y+sin(angle)*longueur;
line(x,y,newx,newy);
branche(newx,newy,longueur,droite? angle+angleInc : angle-angleInc,droite,niveau+1);
if(niveau%10==0) branche(newx,newy,longueur,droite? angle-angleInc : angle+angleInc,!droite,niveau+1);
}