//global variables PFont f1; PImage picture; void setup() { size(600,600); f1 = loadFont("font1.vlw"); picture = loadImage("gnome.jpg"); } void draw() { println("Please choose one of the following:"); println(" [d] to see a sweet do loop"); println(" [w] to see an awesome while loop"); println(" [f] to see a wicked cool for loop"); println(" [c] to erase the extra stuff"); println(frameCount); showChoices(); if(key == 'd') { showDo(); } else if(key == 'w') { showWhile(); } else if(key == 'f') { showFor(); } else if(key == 'c') { eraseScreen(); } else if (frameCount > 1) { showErrorMessage(); } noLoop(); } void drawInitials(float x, float y, float iWidth, float iHeight) { noFill(); strokeWeight(4); stroke(0, 0, 255); beginShape(); curveVertex(x + .6*iWidth, y + .1*iHeight); curveVertex(x + .4*iWidth, y + .15*iHeight); curveVertex(x + .2*iWidth, y + .20*iHeight); curveVertex(x, y + .5*iHeight); curveVertex(x + .2*iWidth, y + .80*iHeight); curveVertex(x + .4*iWidth, y + .85*iHeight); curveVertex(x + .6*iWidth, y + .9*iHeight); endShape(); // First C noFill(); stroke(0, 255, 0); strokeWeight(4); beginShape(); curveVertex(x + .8*iWidth, y + .1*iHeight); curveVertex(x + .7*iWidth, y + .2*iHeight); curveVertex(x + .7*iWidth, y + .3*iHeight); curveVertex(x + .6*iWidth, y + .4*iHeight); curveVertex(x + .8*iWidth, y + .5*iHeight); curveVertex(x + .7*iWidth, y + .6*iHeight); curveVertex(x + .9*iWidth, y + .7*iHeight); curveVertex(x + .7*iWidth, y + .8*iHeight); curveVertex(x + .8*iWidth, y + .9*iHeight); endShape(); // Very Squiggly I noFill(); stroke(255, 0, 0); strokeWeight(4); beginShape(); curveVertex(x + 1.6*iWidth, y + .05*iHeight); curveVertex(x + 1.6*iWidth, y + .25*iHeight); curveVertex(x + 1.3*iWidth, y + .3*iHeight); curveVertex(x + 1.1*iWidth, y + .5*iHeight); curveVertex(x + 1.3*iWidth, y + .7*iHeight); curveVertex(x + 1.6*iWidth, y + .75*iHeight); curveVertex(x + 1.6*iWidth, y + .9*iHeight); endShape(); // Second C } void showWhile() { int i=0; while(i <= 500) { drawInitials(30+ i, 400, 30, 30); image(picture, 10 + i, 460, 90, 120); i = i + 98; } } void showDo() { textFont( f1, 20); fill(255, 255, 0); float inc = TWO_PI/25.0; float j = 0; do { text( "*", 300+ 100*cos(j), 300+ 100*sin(j)); j = j + inc; } while( j <= TWO_PI ); text("O", 255, 275); text("O", 315, 275); noFill(); stroke(255,255,0); strokeWeight(5); ellipse(304,288,175,175); beginShape(); curveVertex(300, 350); curveVertex(300, 350); curveVertex(340, 340); curveVertex(350, 300); curveVertex(350, 300); endShape(); textFont(f1, 40); text("BONUS TIME!", 300, 590); } void showFor() { stroke(0); strokeWeight(1); fill(0, 255, 0); float a = 0.0; float inc = TWO_PI/25.0; for(int i=0; i<400; i++) { ellipse(i*4, 250, i*4, 50+cos(a)*40.0); a = a + inc; } fill(125, 0, 0); text("BONUS TIME!", 10, 590); } void eraseScreen() { background(random(200), random(200), random(200)); showChoices(); } void showErrorMessage() { textFont( f1, 28 ); fill(255, 0, 0); text("EPIC FAIL", 20, 320); println("TRY AGAIN LOLZ!!!"); } void keyPressed() { loop(); } void showChoices() { textFont(f1, 24); fill(0); text("Please choose one of the following:", 10, 25); text(" [d] to see a sweet do loop", 10, 55); text(" [w] to see an awesome while loop", 10, 85); text(" [f] to see a wicked cool for loop", 10, 115); text(" [c] to erase the extra stuff", 10, 145); }