Tree t1,t2,t0; void setup(){ size(500,500); t1 = new Tree(1,350); t2 = new Tree(.75,170); t0 = new Tree(.5,450); noStroke(); } float speed = 2; void mouseMoved(){ speed = map(mouseY,0,500,4,-4); } void draw(){ BASEY += speed; if(BASEY > 0) BASEY = 0; if(BASEY < -3900) BASEY = -3900; background(255,255,225); //YELLOW t0.draw(); t2.draw(); t1.draw(); // fill(0); //text(BASEY,50,100); } float BASEY = -1500; float TREEWIDTH = 40; float TREEHEIGHT = 5000; class Tree{ float centerX; float scale; ArrayList branches = new ArrayList(); Tree(float pScale, float pCenter){ scale = pScale; centerX = pCenter; for(int i = 0; i< 50; i++) branches.add(new Branch(scale,random(TREEHEIGHT))); } void draw(){ stroke(0); //fill(255); fill(225 -( 100 * scale)); stroke(225 -( 100 * scale)); // rect(centerX - scale * 40, 0, 80 * scale, 500); pushMatrix(); translate(centerX, BASEY * scale); rect(-scale*TREEWIDTH,0,scale*2*TREEWIDTH,scale*TREEHEIGHT); for(Branch b:branches){ pushMatrix(); translate(0,b.loc*scale); b.draw(); popMatrix(); } popMatrix(); } } class Branch{ float scale; float s; float loc; ArrayList limbs = new ArrayList(); ArrayList puffs = new ArrayList(); Branch(float pscale, float ploc){ scale = pscale; loc = ploc; float angle = random(-.3,.3); boolean downish = true; if(random(1) < .5) { angle += PI; downish = false; } float ex = 0; float ey = 0; float w = scale * 15; float s = random(20,50) * scale; for(int i = 0; i < 5; i++){ ex += s * cos(angle); ey += s * sin(angle); if(downish) angle -= .1; else angle += .1; w *= .9; limbs.add(new Limb(ex,ey,w)); } for(int i = 0; i < 4; i++){ float x = scale * random(-10,10); float y = scale * random(-10,10); float a = random(20*scale,60*scale); float b = random(20*scale,60*scale); puffs.add(new Puff(x,y,a,b)); } } void draw(){ float lx =0, ly=0; for(Limb m : limbs){ strokeWeight(m.w); line(lx,ly,m.x,m.y); lx = m.x; ly = m.y; } for(Puff p : puffs){ ellipse(lx+p.x,ly+p.y,p.a, p.b); } } } class Puff{ float x,y,a,b; Puff(float px, float py, float pa, float pb){ x = px; y= py; a = pa; b = pb; } } class Limb{ float x,y,w; Limb(float px, float py, float pw){ x = px; y = py; w = pw; } }