/** * Displaying time, jpg image, text and circle - needs to be in the same folder * * The time comes up first, then if C is pressed a circle appears and remains on * until another key is pressed (as the noLoop function is used). * If Y is pressed an image appears and also remains until another key is pressed (noLoop) * at the end a Loop function is used to make draw run again. * Any other key pressed, time is shown again as it is the "else" in the if..else function. */ PFont font; String waiting = "I'm waiting"; String thank = "Thank you..."; void setup() { size(300, 400); font = loadFont("Verdana-48.vlw"); textFont(font); } void draw() { if(keyPressed) { if (key == 't' || key == 'T') { background(0); text(thank, 22, 300); fill (12, 90, 20); //Only appears when key is pressed as does not contain noLoop(). } if (key == 'w' || key == 'W') { background(0); text(waiting, 22, 300); fill (12, 90, 20); //Only appears when key is pressed as does not contain noLoop(). } if (key == 'y' || key == 'Y') { noLoop(); size(300, 400); PImage a; // Declare variable "a" of type PImage a = loadImage("mark.jpg"); // Load the images into the program background (255); // Background is white image(a, 0, 0); } if (key == 'c' || key == 'C') { noLoop(); background (0); // Background is black size(300, 400); fill (12, 90, 27); ellipse (150, 150, 300, 300); } } else { background(0); int s = second(); int m = minute(); int h = hour(); String t = nf(h,2) + ":" + nf(m,2) + ":" + nf(s,2); text(t, 40, 200); fill (255); //keeps text white } } void keyPressed() { // if any key is pressed, then draw() is re-run loop(); }