buttons Buttons= new buttons(); class button { int x=0, y=0; String name = "valeur"; float V=1.234, Vmin=-10, Vdefault = 0, Vmax=10, Vincrement=0.1, VfastIncrement=1; int d=18, i=4; button() {}; button(String _name, float _Vmin, float _Vdefault, float _Vmax, float _Vincrement, float _VfastIncrement) { name=_name; Vmin=_Vmin; Vdefault= _Vdefault; Vmax= _Vmax; Vincrement= _Vincrement; VfastIncrement= _VfastIncrement; V=Vdefault; }; void putAt(int _x, int _y) {x=_x; y=_y;}; float v() {return(V);} void show() { stroke(dgreen); fill(20, 60, 120); rect(x+i,y,d,d); rect(x+i+d+i,y,d,d); rect(x+i+2*(d+i),y,d,d); rect(x+i+3*(d+i),y,d,d); rect(x+i+4*(d+i),y,d,d); fill(black); noStroke(); text(" |< - . + >| "+Format(V,4,4)+" = "+name,x,y+14); noFill(); }; boolean click() { if ( (x+i=0) sign="+"; String spaces = " "; String s=nf(abs(f),n,z); while (s.indexOf("0")==0) {s=s.substring(1,s.length());}; int b=s.indexOf("."); int a=max(0,n-b); int c=s.length()-b-1; int d=0; if (c>z) {s=s.substring(0,b+1+z); c=z;} else { d=z-c;}; String front = spaces.substring(0, a); String back = spaces.substring(0, d); return(front+sign+s+back); }; void loadButtons() { // define buttons that control numeric values here Buttons.add(new button("recursions",0,rec,7,1,7)); // defines Label and values (min, current, max, increment, fast increment) Buttons.add(new button("button 2",0,3,7,1,7)); // replace this with your button and add more if desired Buttons.add(new button("button 3",0,3,7,1,7)); // replace this with your button and add more if desired } void loadToggles() { // define toggles that control boolean values here Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle(" ",true)); // toggle 0 (bottom) Toggles.add(new toggle("Show Frame",showFrame)); // toggle 1 (bottom) Toggles.add(new toggle("Show Ghosts",showGhostFrame)); // toggle 2 Toggles.add(new toggle("Reset",false)); // toggle 3 Toggles.add(new toggle("Animate",animate)); // toggle 1 (bottom) Toggles.add(new toggle("Show subdivision",showSubdivision)); // toggle 1 (bottom) Toggles.add(new toggle("Show curve",showCurve)); // toggle 1 (bottom) Toggles.add(new toggle("Show construction",showConstruction)); // toggle 1 (bottom) } void mousePressed() { int k= Buttons.click(); int m=-1; // bind value-buttons to actions here (same order as definition above) if(k== ++m) {rec=int(Buttons.v(m));}; // actions for button 1 if(k== ++m) { }; // actions for button 2 if(k== ++m) ; // Can reset the value of any button with Buttons.setValue(button,value); k= Toggles.click(); m=-1; // bind boolean-toggles to actions here (same order as definition above) m=12; if(k==++m) showFrame=Toggles.v(m); // actions for toggle 1 if(k==++m) showGhostFrame=Toggles.v(m); // actions for toggle 2 if(k==++m) {Toggles.B[m].V=false; reset(); }; // actions for toggle 3 always resets it to false if(k==++m) {animate=Toggles.v(m); if(animate) tt=acos(t*2-1); else t=(cos(tt)+1)/2;} // toggles animation and resets time if(k==++m) showSubdivision=Toggles.v(m); // actions for toggle 2 if(k==++m) showCurve=Toggles.v(m); // actions for toggle 2 if(k==++m) showConstruction=Toggles.v(m); // actions for toggle 2 // ***** pick: find index p of point closest to the mouse when clicked if (mouse().isInWindow()) { if (!keyPressed) { p=0; float d=PP[0].disToMouse(); for (int i=1; i