PButton startBtn, clearBtn ; PFont myFont; float t1, t2; float x, y, cre, cim; int j = 0; int k =0; int period = 20; float sc = 150.0; float modsqr; float [] cA2 = {0.0, 0.0}; color[] colA = {#0000FF, #2323DC, #4646B9, #696996, #8C8C73, #AFAF50, #D2D22D, #F5F50A, #FFFF00}; void setup(){ size(400, 500); startBtn = new PButton(320,450,60,20, "Start"); clearBtn = new PButton(250,450,60,20, "Clear"); myFont = loadFont("sansserif.bold-14.vlw"); fill(#000000); textFont(myFont); noLoop(); } void draw() { if(startBtn.over()) runthis(); if(clearBtn.over()) clearthis(); } float[] mandel(float x, float y, float pre, float pim) { float[] result = {pre+(x*x-y*y), 2*x*y + pim}; return (result); } //event handler void mouseReleased () { if(startBtn.over())startBtnAction(); if(clearBtn.over()) redraw(); } void startBtnAction(){ j= 0; k = 0; t1 = millis(); redraw(); } void clearthis(){ color c = get(248, 450); noStroke(); fill(c); rect(0,0, 400, 449); noLoop(); } void runthis(){ while( j <201){ for(int i=0; i<400; i++) { cre = (i-300)/sc; cim = (j-200)/sc; x = 0.0; y = 0.0; modsqr = x*x + y*y; stroke(#000000); while ((kx && mouseXy && mouseY