Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Midterm Explanation

By: caitlinorbanek on Dec 15th, 2011  |  syntax: None  |  size: 1.25 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PFont f;
  2.  
  3. float a = 'b';
  4.  
  5.  
  6. //variable to store text as it is being typed
  7. String typing = "";
  8. //a different variable to store the text when enter is pressed
  9. String saved = "";
  10.  
  11. void setup() {
  12.   size (700, 500);
  13.   f = loadFont ("ArialMT-16.vlw");
  14. } //close setup brackets
  15.  
  16. void draw() {
  17.    background (226, 197, 247); //purple background
  18.    int indent = 50;
  19.    //if (keyPressed = 'a')  {
  20.     // typing = 'b';
  21.    //}
  22.    //set font and font color
  23.    textFont (f);
  24.    fill(0); //black text
  25.    //Display everything
  26.    text ("Program intent: \nI wanted to play with the pointillize function. \nI was curious how an image would turn out if I added a stroke weight to each of the points. \nI also wanted to start playing with text, which is why I chose to run my directions in this program. \nThis program is also interactive! \nType in the box \nIf you mess up, oh well. Apparently backspace isn't an option right now. ",indent,40);
  27.    text (typing, indent, 300);
  28.    text (saved, indent, 200);
  29. }
  30.  
  31. void keyPressed() {
  32.   //If the return key is pressed, save the String and clear it
  33.   if (key == '\n') {
  34.     saved = typing;
  35.     typing = "";
  36.     //otherwise, concatenate the string
  37.   } else {
  38.     typing = typing + key;
  39.   }
  40. } //close void keyPressed