texts/images
in
Programming Questions
•
10 months ago
I am having trouble figuring out how to display the text and image. Here is what I am talking about (
http://evc-cit.info/cit020/screenshots/europe/index.html). This is what I have so far;
String [] picName = {
"france", "germany", "spain", "sweden"
};
String[] country = {
"France", "Germany", "Spain", "Sweden"
};
PImage[] flag = new PImage[picName.length];
PImage[] map = new PImage[picName.length];
PImage empty;
PFont f;
void setup( )
{
size(350, 350);
/*
You do this:
Use a for loop with loadImage( ) to load
the flag images and map images.
*/
for (int i = 0; i < picName.length; i++)
{
flag[i] = loadImage(picName[i] + "_flag.png");
map[i] = loadImage(picName[i] + ".png");
}
empty = loadImage("europe.png"); // load the blank map
f = createFont("Arial", 24, true); // create font
textFont(f); // use that font
}
void draw( )
{
float y;
background(255);
textFont(f, 24);
textAlign(CENTER);
tint(255);
/* You do this: Draw the empty map at (90, 25) */
image(empty, 90, 25);
noFill();
/* You do this: Draw a rectangle around the map */
rect(89, 24, 247, 251);
fill(0);
/* You do this:
For each country: {
If the mouse is in that country's flag rectangle, {
set tint(255) for full color
display the map of Europe with that country highlighted
display the country name centered at (175, 310)
}
otherwise {
set tint(255, 128) for light colors
}
draw the flag for the country
}
*/
y = 25;
for (int i = 0; i < picName.length; i++)
{
if ( false )
{
tint(255);
}
image(flag[i], 15, y);
y = y + 72;
text(country[i], 175, 310);
}
tint(255, 128);
}
String [] picName = {
"france", "germany", "spain", "sweden"
};
String[] country = {
"France", "Germany", "Spain", "Sweden"
};
PImage[] flag = new PImage[picName.length];
PImage[] map = new PImage[picName.length];
PImage empty;
PFont f;
void setup( )
{
size(350, 350);
/*
You do this:
Use a for loop with loadImage( ) to load
the flag images and map images.
*/
for (int i = 0; i < picName.length; i++)
{
flag[i] = loadImage(picName[i] + "_flag.png");
map[i] = loadImage(picName[i] + ".png");
}
empty = loadImage("europe.png"); // load the blank map
f = createFont("Arial", 24, true); // create font
textFont(f); // use that font
}
void draw( )
{
float y;
background(255);
textFont(f, 24);
textAlign(CENTER);
tint(255);
/* You do this: Draw the empty map at (90, 25) */
image(empty, 90, 25);
noFill();
/* You do this: Draw a rectangle around the map */
rect(89, 24, 247, 251);
fill(0);
/* You do this:
For each country: {
If the mouse is in that country's flag rectangle, {
set tint(255) for full color
display the map of Europe with that country highlighted
display the country name centered at (175, 310)
}
otherwise {
set tint(255, 128) for light colors
}
draw the flag for the country
}
*/
y = 25;
for (int i = 0; i < picName.length; i++)
{
if ( false )
{
tint(255);
}
image(flag[i], 15, y);
y = y + 72;
text(country[i], 175, 310);
}
tint(255, 128);
}
1