int playing = 0; int i = 1250; int h = 2; int firsttime = 0; //PImage click; void setup() { size(400,400); //click = loadImage("http://www.williamjcrook.com/click.png"); noStroke(); smooth(); frameRate(25); noLoop(); } void draw(){ //triangle coordinates int ax=width/2; int ay=45; int bx=10; int by=200/160*height-10; int cx=width-10; int cy=by; int pointselection = 0; //draw background(38,38,38); triangle(ax,ay,bx,by,cx,cy); //halving for (int reps=0;reps<9;reps++) { float pointselector=random(7); if (pointselector<6) { pointselection = 6; }; if (pointselector<5) { pointselection = 5; }; if (pointselector<4) { pointselection = 4; }; if (pointselector<3) { pointselection = 3; }; if (pointselector<2) { pointselection = 2; }; if (pointselector<1) { pointselection = 1; }; switch(pointselection) { case 1: bx=(bx+cx)/2; by=(by+cy)/2; break; case 2: bx=(bx+ax)/2; by=(by+ay)/2; break; case 3: cx=(cx+ax)/2; cy=(cy+ay)/2; break; case 4: cx=(cx+bx)/2; cy=(cy+by)/2; break; case 5: ax=(ax+bx)/2; ay=(ay+by)/2; break; case 6: ax=(ax+cx)/2; ay=(ay+cy)/2; break; default: } float r = random(255); float blu = random(255); float g = random(255); fill(r,g,blu); triangle(ax,ay,bx,by,cx,cy); //saveFrame("triangle-####.png"); }; //click+speedup if (firsttime<1){ // image(click,167,20); } if (firsttime>1){ delay(i); i = i - i/h ; if (h<20){ h=h+1; } } if (firsttime>0){ firsttime=2; } } //start void mousePressed() { if (playing<1) { loop(); playing=1; firsttime=1; } }