void setup() { size(640,480,P2D); } private void branch(float x, float y, float ang, float n, int depthcheck) { float dx=(float)Math.cos(ang)*n*mouseY/128; float dy=(float)Math.sin(ang)*n*mouseY/128; strokeWeight(n/4); line(x,y,x+dx,y+dy); float dang = PI*n/96; if (n>1 && depthcheck>0) { branch(x+dx,y+dy,ang+dang+(mouseX-(width>>1))/64f,n*mouseY/512,depthcheck-1); branch(x+dx,y+dy,ang-dang+(mouseX-(width>>1))/64f,n*mouseY/512,depthcheck-1); } } void draw() { background(33); stroke(99); branch(width>>1,height*3>>2,-PI/2,16,8); }