Building A Text Editor With Processing

edited June 2014 in How To...

Code 00:

PFont font;
String letters = "";
int back = 102;

void setup() {
  size(200, 200);

  textAlign(CENTER);
}

void draw() {
  background(back);
  text(letters, 50, 50);

}
void keyPressed() {
  if ((key == ENTER) || (key == RETURN)) {
    letters = letters.toLowerCase();
    println(letters);
   if (letters.equals("black")) {
    back = 0;
  } else if (letters.equals("gray")) {
    back = 204;
  }
    letters = ""; //clear the variable
  } else if ((key > 31) && (key != CODED)) {
    // If the key is alphanumeric, add it to the String
    letters = letters + key;
  }
}

//I will add threads, buttons, and more as I go along.

Sign In or Register to comment.