the operator == is undefined for the argument type(s) boolean,void
in
Programming Questions
•
6 months ago
hi
im just starting out in processing ( making a data visualization) and having some trouble with the if mousepressed function with text and having it display an image. Basically, i want the user to be able to click on a piece of text and have a certain image appear. Any help with what I am doing wrong would be great... heres my code
PImage blue;
PImage red;
PImage green;
PImage orange;
PImage yellow;
PImage original;
void setup() {
size(800,800);
// f = loadFont("Calibri-48.vlw");
// Make a new instance of a PImage by loading an image file
blue = loadImage("bluemap.gif");
image(blue,0,0);
blue.resize(800,0);
image(blue,0,0);
red = loadImage("redmap.gif");
image(red,0,0);
red.resize(800,0);
image(red,0,0);
green = loadImage("greenmap.gif");
image(green,0,0);
green.resize(800,0);
image(green,0,0);
orange = loadImage("orangemap.gif");
image(orange,0,0);
orange.resize(800,0);
image(orange,0,0);
yellow = loadImage("yellowmap.gif");
image(yellow,0,0);
yellow.resize(800,0);
image(yellow,0,0);
original = loadImage("originalmap.png");
image(original,0,0);
original.resize(800,0);
image(original,0,0);
}
void draw() {
background(0);
// Draw the image to the screen at coordinate (0,0)
image(original,0,0);
// legend
textSize(15);
// textFont(f,48);
textAlign(CENTER); // position of the text at the center
fill(240,15,15);
text("white",60,540);
fill(5,40,230);
text("black",60,560);
fill(20,120,10);
text("asian",60,580);
fill(240,130,15);
text("hispanic",60,600);
fill(250,235,10);
text("other",60,620);
if ( mousePressed == text("black",60,540)) {
image(blue,0,0);
}
}
1