int playing = 0; int i = 750; int h = 12; int firsttime = 0; int n = 6; PImage click; int alph = 0; void setup() { size(400,400); click = loadImage("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(0); 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; }; //manually determine pointselector if (n>99){ pointselection = n ; n=n-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){ rotate(1.08); image(click,140,-200); } if (firsttime>1){ delay(i); i = i - i/h ; if (h<20){ h=h+1; } } if (firsttime>0){ firsttime=2; } float r = random(255); float blu = random(255); float g = random(255); fill(r,g,blu); } void keyPressed(){ noLoop(); redraw(); firsttime=0; playing=0; } //start void mousePressed() { if (playing<1) { loop(); playing=1; firsttime=1; } }