void mousePressed() { if (mouse().isInWindow()) if (keyPressed) clickPolygon(); else pickAB(); } void keyPressed() { if (key==' ') showHelpText=!showHelpText ; if (key=='m') {} // used to set mode when mouse pressed if (key=='i') {} // used to set mode when mouse pressed if (key=='d') {} // used to set mode when mouse pressed if (key=='O') loopIsClosed=!loopIsClosed; if (key=='#') showVertexIds=!showVertexIds ; if (key=='V') showVertices=!showVertices; if (key=='S') {refine(0.5); coarsen();}; if (key=='R') refine(0.5); if (key=='C') coarsen(); if (key=='W') savePts(); if (key=='G') loadPts(); if (key=='X') {String S=" "+"-####.tif"; saveFrame(S);}; ; if (key=='?') printIt=true; // toggle debug mode if (key==',') {n--; n=max(n,1); resetPoints(); println("n="+n); }; if (key=='.') {n++; n=min(n,P.length); println("n="+n);resetPoints();}; }; void showHelp() { fill(dblue); pushMatrix(); translate(20,20); text("PGS (PLANAR GEOMETRY SANDBOX) by Jarek Rossignac",0,0); translate(0,20); text(" ",0,0); translate(0,20); text("Project 2 for CS4351 (individual): Ray shooting ",0,0); translate(0,20); text("Show point Q where ray(A,B) first hits the polygon and the direction R of the reflected ray at Q ",0,0); translate(0,20); text("Produce web page with running applet and explanation of your solution",0,0); translate(0,20); text("DUE DATE: February 1st BEFORE CLASS",0,0); translate(0,20); text(" ",0,0); translate(0,20); text("First click in the window to activate it ",0,0); translate(0,20); text("Press SPACE to show/hide this help text",0,0); translate(0,20); text("Click & drag ray end-points, A and B ",0,0); translate(0,20); text(" ",0,0); translate(0,20); text("TO EDIT or PROCESS POLYGON ",0,0); translate(0,20); text("',' & '.' to change vertex count ",0,0); translate(0,20); text("Click&drag while pressing 'i' to insert, 'd' to delete, 'm' to move vertex ",0,0); translate(0,20); text("Click&drag while pressing 't' to transalte, 'z' to zoom polygon",0,0); translate(0,20); text("Press 'R' to refine, 'F' to fair, and 'C' to coarsen polygon",0,0); translate(0,20); text(" ",0,0); translate(0,20); text("'O': close/open loop. '#': show/hide IDs, 'V' to show/hide vertices",0,0); translate(0,20); text("'W' write polygon to file, 'G' get it back ",0,0); translate(0,20); text(" ",0,0); translate(0,20); text("Press 'X' top snap a picture (when running Processing, not in browser)",0,0); translate(0,20); text("'?' print debugging stuff (when running Processing, not in browser) ",0,0); translate(0,20); popMatrix(); noFill(); }