float a1, a2; int generations; PImage bg; float[] sintab = new float[3600]; float sin2(float a){ return sintab[abs(int(a*10) )%3600]; } float cos2(float a){ return sintab[abs(int(a*10)+900)%3600]; } void windblow() { a1=10 * sin2(frameCount*2.0) +40; a2=10 * sin2(frameCount*2.71) -30; } void tri(float x, float y, float a, float l, int gen) { if(gen<0) return; float x2=x+l*cos2(a); float y2=y-l*sin2(a); stroke(130, 355/(gen+2), 0); line(x+1, y, x2+1, y2); stroke(100, 225/(gen+1), 0); line(x, y-1, x2, y2-1); stroke(50, 205/(gen+1), 0); line(x, y, x2, y2); tri(x2, y2, a+a1, l*.7, gen-1); tri(x2, y2, a+a2, l*.7, gen-1); } void setup(){ size(320, 240); framerate(30); bg = loadImage("bg.jpg"); for(int i=0; i<3600; i++) sintab[i]=sin(i/1800.0*PI); smooth(); generations=0; } void draw(){ windblow(); if(framerate>8 && frameCount>(generations-2)*300) generations++; background(bg); tri(width/2, height-50, 87, 20+frameCount/80.0, generations); }