void scribe(String S) {fill(black); text(S,20,20); noFill();}
void scribe(String S, int i) {fill(black); text(S,20,20+i*20); noFill();}
void scribe(String S, int i, int j) {fill(black); text(S,width-10*j,20+i*20); noFill();}

void mousePressed() {myMousePressed();}
void mouseReleased() {myMouseReleased();} 

void keyPressed() { 
  if(key=='s'){trav = s(trav);} //swing
  if(key=='n'){trav = n(trav);} //next
  if(key=='p'){trav = p(trav);} //previous
  if(key=='o'){trav = o(trav);} //oppisite
  if(key=='1'){trav = l(trav);} //left
  if(key=='2'){trav = r(trav);} //right
  if (key==' ') showHelpText=!showHelpText ; 
  if (key=='?') printIt=true;  // toggle debug mode
  if  (47<int(key)) if (int(key)<56)  { int n=int(key)-48; mySelected(n);}

  if(key=='b'){myBulge(); show3D = !show3D; showMirror = false; ax = 800; az = 0;}
  if(key=='m'){myBulge(); showMirror = !showMirror; show3D = false; ax = 800; az = 0;};
  
  if(key=='a'){meshAnimating = !meshAnimating;};
  
  if(key=='S'){saveMesh();};
  if(key=='L'){loadMesh();}; 

  

  if(key=='l') myDenoise();  
  //if(key=='e') showEkey=!showEkey; 
  if(key=='f') showFrames=!showFrames;
  if(key=='k') showKeys=!showKeys;  
//  if(key=='m') myTranslate();  // executed in my actions for faster response
  if(key=='w') showTriangles=!showTriangles;
  //if(key=='n') showMouseProjection=!showMouseProjection;
  if(key=='e') mySet();
  if(key=='q') mySpray();
  if(key=='r') myRefine();  
  if(key=='s') myLaplace();  
  if(key=='t') mySample();
  //if(key=='t') myRotate();  // executed in my actions for faster response
  if(key=='v') showVertices=!showVertices;  // toggle showing control vertices

//  if(key=='z') myScale();  // executed in my actions for faster response
  //if(key=='z') loading=!loading;

  if (key=='R') myReset();  
  if (key=='T') showBorder=!showBorder;
  };          

void showHelp() {
    fill(dblue); pushMatrix(); translate(20,20);
     text("Polyloop Manipulations",0,0); translate(0,20);               // **P04
     text("  ",0,0); translate(0,20);
     text("Begin by clicking 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("",0,0); translate(0,20);
     text("2D Functions",0,0); translate(0,20);
     text("To enter a new polyloop hold 'd' and draw with the mouse.",0,0); translate(0,20);
     text("Click and drag to manually alter the polyloop (press 'q' to respray afterwards).",0,0); translate(0,20);
     text("Press 'x' to translate the polyloop.",0,0); translate(0,20);
     text("Press 'z' to scale the polyloop.",0,0); translate(0,20);
     text("Press 'R' to reset, 'S' to save, and 'L' to load a 2D polyloop.",0,0); translate(0,20);
     text("Press 'w' to display/hide the mesh, axis, and traversal.",0,0); translate(0,20);
     text("Press 'q' to respray the interior of the polyloop.",0,0); translate(0,20);
     text("Press 'e' to reset V, O, axis, and otherwise allow 3D capacity.",0,0); translate(0,20);
     text("Press 'm' to switch between full 3D and 2D.",0,0); translate(0,20);
     text("Press 'b' to bulge the 2D mesh into a 3D mesh." ,0,0);translate(0,20);
     text("",0,0); translate(0,20);
     text("Traversal Functions",0,0); translate(0,20);
     text("Press 'n' and 'p' for next and previous in mesh index array.",0,0); translate(0,20);
     text("Press 'o' for the corresponding value in the corner opposite table.",0,0); translate(0,20);
     text("Press 's' to swing through the mesh.",0,0); translate(0,20);
     text("",0,0); translate(0,20);
     text("3D Functions",0,0); translate(0,20);
     text("Press 'a' while in 3D to animate the figure.",0,0); translate(0,20);
     text("Press 'm' to switch between full 3D and 2D.",0,0); translate(0,20);
     popMatrix(); noFill();
   }
     
