PImage front;
void setup() {
size(400, 400);
stroke(2);
smooth();
front=loadImage("cover.jpg");
background(front);
}
void draw() {
if ((keyPressed == true) && (key == 'a')) { // Key A
PImage img;
img= loadImage("apple candy.jpg");
image(img, 0, 0, 400, 400);
PFont font;
font= loadFont("SnellRoundhand-32.vlw");
textFont(font);
fill(145, 25, 28);
String a= "Apple candy";
text(a, 90, 100);
} else if ((keyPressed == true) && (key == 'b')) { // Key B
PImage img;
img= loadImage("Blue.jpg");
image(img, 0, 0, 400, 400);
PFont font;
font= loadFont("SnellRoundhand-32.vlw");
textFont(font);
fill(60, 63, 70);
String a= "Blueberry muffins";
text(a, 80, 50);
} else if ((keyPressed == true) && (key == 'c')) { // Key C
PImage img;
img= loadImage("cotton candy.jpg");
image(img, 0, 0, 400, 400);
PFont font;
font= loadFont("SnellRoundhand-60.vlw");
textFont(font);
fill(255);
String a= "Cotton Candy";
text(a, 80, 330);
} else if ((keyPressed == true) && (key == 'd')) { // Key D
PImage img;
img= loadImage("Donut.jpg");
image(img, 0, 0, 400, 400);
PFont font;
font= loadFont("SnellRoundhand-60.vlw");
textFont(font);
fill(180, 122, 100);
String a= "Donuts";
text(a, 225, 210);
} else if ((keyPressed == true) && (key == 'e')) { // Key E
PImage img;
img= loadImage("egg pie.jpg");
image(img, 0, 0, 400, 400);
PFont font;
font= loadFont("SnellRoundhand-32.vlw");
textFont(font);
fill(143, 48, 20);
String a= "sweet Egg pie";
text(a, 20, 200);
}
}Charlene - F
on Wednesday, Oct 15, 2008 – 2:27 am
One Comment
Simple idea, but good layouts.
It’s much better to load images and fonts in setup(). Because you’re only using two fonts, you only need two font variables.