pt pickedPoint = P(); int vc=32; // vertex count Polyloop P= new Polyloop(); Polyloop D= new Polyloop(); // used to capture the curve drawn by the user boolean linear=false; // toggle linear interpolation boolean geometric=false; boolean animate=false; // toggle animation boolean sketching=false; // toggle indicaitng that the user is sketching the selected curve float t=0; // current time for animation void myInit() {P.reset(vc);}; void mySave() {P.savePts();}; void myLoad() {P.loadPts();}; void myReset() {P.reset(vc);}; void myRefine() {P.refine(0,0);} void myFilter() {P.smoothen(5);} void myResample() {P.resample(32);} void myActions() { // actions to be executed at each frame scribe("Polygon processing with Geometry Sandbox Jarek Rossignac"); if(mousePressed&&!keyPressed) {if(pickedPoint!=null) pickedPoint.trackMouse(); }; if(mousePressed&&keyPressed) { if(key=='s') myScale(); if(key=='r') myRotate(); if(key=='t') myTranslate(); if(key=='d') D.extendToMouse(); }; if(sketching) {stroke(dred,50); noFill(); P.drawSmooth(0,5); fill(red,50); P.rP(0).show(4); fill(yellow,50); P.rP(1).show(3); stroke(red); noFill(); D.drawOpen(); noStroke();} else {stroke(red); fill(yellow); P.drawSmooth(0,5); fill(white); P.showVertices(); fill(red); P.rP(0).show(4); fill(yellow); P.rP(1).show(3); }; }; void mySelected(int n) {} // user selects curve by typing its number n: select curve void myStartAcquisition() {D.empty(); D.appendPt(Mouse()); sketching=true; } // start acquisition processd void myEndAcquisition() {if(sketching) {D.smoothen(5); for(int i=0; i<4; i++); D.refine(0,0); D.smoothen(10); D.resample(vc); P.setTo(D); sketching=false;}; } // finish acquisition process void myMousePressed() { if (Mouse().isInWindow()&&!keyPressed&&!sketching) pickedPoint=P.pickPoint(); else if (Mouse().isInWindow()&&keyPressed&&(key=='d')) myStartAcquisition(); } void myMouseReleased() {pickedPoint=null; myEndAcquisition();} void myScale() {P.scaleWithMouse();} void myTranslate() {P.translateWithMouse();} void myRotate() {P.rotateWithMouse();}