PFont fontA, fontB, fontC, fontD, fontE;
PImage cover;
String abc = "The quick brown fox jumps over the lazy dog.";
int page = 0;
void setup() {
background(255);
size(400,400);
noStroke();
smooth();
fontA = loadFont("AmericanTypewriter-72.vlw");
fontB = loadFont("Baskerville-72.vlw");
fontC = loadFont("Courier-72.vlw");
fontD = loadFont("Didot-72.vlw");
fontE = loadFont("Eurostile-72.vlw");
cover = loadImage("cover.jpg");
}
void draw() {
if (page == 0) {
image(cover, 0,0);
}
if (keyPressed && key == 'a') {
page = 1;
}
if (keyPressed && key == 'b') {
page = 2;
}
if (keyPressed && key == 'c') {
page = 3;
}
if (keyPressed && key == 'd') {
page = 4;
}
if (keyPressed && key == 'e') {
page = 5;
}
if(page == 1) {
background(255);
fill(#ac0b13);
rect(0,0,400,140);
fill(255);
textFont(fontA);
text("American", 45, 70);
text("Typewriter", 7, 115);
// sample text button
fill(#ac0b13);
rect(0,150,155,25);
fill(255);
textSize(18);
text("view sample", 40, 168);
if (mousePressed == true && mouseX > 0 && mouseX < 150 && mouseY > 155 && mouseX < 180) {
fill(150);
textSize(48);
textLeading(45);
text(abc, 25, 200, 370, 205);
}
} // end page
if(page == 2) {
background(255);
fill(#e6688e);
rect(0,0,400,140);
fill(255);
textFont(fontB);
text("Baskerville", 45, 90);
// sample text button
fill(#e6688e);
rect(0,150,155,25);
fill(255);
textSize(18);
text("view sample", 50, 168);
if (mousePressed == true && mouseX > 0 && mouseX < 150 && mouseY > 155 && mouseX < 180) {
fill(150);
textSize(48);
textLeading(45);
text(abc, 25, 200, 370, 205);
}
} // end page
if(page == 3) {
background(255);
fill(#eba81b);
rect(0,0,400,140);
fill(255);
textFont(fontC);
text("Courier", 55, 90);
// sample text button
fill(#eba81b);
rect(0,150,155,25);
fill(255);
textSize(18);
text("view sample", 30, 168);
if (mousePressed == true && mouseX > 0 && mouseX < 150 && mouseY > 155 && mouseX < 180) {
fill(150);
textSize(48);
textLeading(45);
text(abc, 25, 200, 370, 205);
}
} // end page
if(page == 4) {
background(255);
fill(#a1ba54);
rect(0,0,400,140);
fill(255);
textFont(fontD);
text("Didot", 85, 90);
// sampel text button
fill(#a1ba54);
rect(0,150,155,25);
fill(255);
textSize(18);
text("view sample", 45, 168);
if (mousePressed == true && mouseX > 0 && mouseX < 150 && mouseY > 155 && mouseX < 180) {
fill(150);
textSize(48);
textLeading(45);
text(abc, 25, 200, 370, 205);
}
} // end page
if(page == 5) {
background(255);
fill(#82b6e5);
rect(0,0,400,140);
fill(255);
textFont(fontE);
text("Eurostile", 65, 90);
// sample text button
fill(#82b6e5);
rect(0,150,155,25);
fill(255);
textSize(18);
text("view sample", 55, 168);
if (mousePressed == true && mouseX > 0 && mouseX < 150 && mouseY > 155 && mouseX < 180) {
fill(150);
textSize(48);
textLeading(45);
text(abc, 25, 200, 370, 205);
}
} // end page
} // end void drawExercise E - Font Alphabet Book
on Sunday, Apr 19, 2009 – 9:20 pm