Hello everyone,
I am working on a processing code for a map project. I want to make a map so that when I go with the mouse above certain area an image shows up on the screen, but then when I move the mouse from that area the image disappears. I am able to load an image when I have the mouse above certain area, but then when I move the mouse the image stays, i.e. it does not disappear. I was wondering if somehow I can control the transparency or appearance of the image? I feel this should be easy to do, but I am new to processing so I did not manage. Please send me your thoughts.
Below is the code I used.
Many thanks!
PImage bg;
PImage a;
PImage b;
PShape sh1;
int value = 0;
import processing.video.*;
Movie myMovie;
PFont font;
void setup(){
size(1200,900);
bg = loadImage("laguna_1200x900_full_gray.jpg");
background(bg);
imageMode(CENTER);
shapeMode(CENTER);
sh1 = loadShape("test.svg");
font = loadFont("Arial-Black-24.vlw");
textFont(font);
fill(250,169,86);
// historical monuments
ellipse(350, 250, 10, 10);
ellipse(250, 120, 10, 10);
ellipse(150, 250, 10, 10);
ellipse(250, 194, 10, 10);
ellipse(250, 750, 10, 10);
ellipse(170, 450, 10, 10);
ellipse(250, 240, 10, 10);
fill(56,169,86);
// green landscape
ellipse(250, 640, 10, 10);
ellipse(186, 700, 10, 10);
ellipse(230, 450, 10, 10);
ellipse(120, 650, 10, 10);
ellipse(310, 550, 10, 10);
ellipse(630, 350, 10, 10);
ellipse(220, 624, 10, 10);
ellipse(120, 230, 10, 10);
fill(0,176,236);
// marine boats, blue
ellipse(180, 550, 10, 10);
ellipse(455, 590, 10, 10);
ellipse(110, 750, 10, 10);
ellipse(200, 424, 10, 10);
ellipse(176, 800, 10, 10);
ellipse(520, 110, 10, 10);
ellipse(570, 80, 10, 10);
ellipse(430, 250, 10, 10);
ellipse(280, 324, 10, 10);
ellipse(150, 200, 10, 10);
}
void draw(){
if(mouseX >450 && mouseX < 650 && mouseY > 650 && mouseY <850) {
fill(0);
text("Transportation Node", 900, 750, 250, 500);
text("Here you will encounter the door of Timeless Venice", 900, 780, 250, 500);
}
}
void mousePressed() {
if(mouseX >345 && mouseX < 355 && mouseY > 245 && mouseY <255) {
if (mouseButton == LEFT) {
ellipse(350, 250, 0, 0);
shape(sh1, 350, 250, 100, 100);
shape(sh1, 750, 750, 200, 200);
shape(sh1, 550, 750, 200, 200);
}else if (mouseButton == RIGHT){
shape(sh1, 0, 0, 0, 0);
ellipse(350, 250, 10, 10);
}
}
}
I am working on a processing code for a map project. I want to make a map so that when I go with the mouse above certain area an image shows up on the screen, but then when I move the mouse from that area the image disappears. I am able to load an image when I have the mouse above certain area, but then when I move the mouse the image stays, i.e. it does not disappear. I was wondering if somehow I can control the transparency or appearance of the image? I feel this should be easy to do, but I am new to processing so I did not manage. Please send me your thoughts.
Below is the code I used.
Many thanks!
PImage bg;
PImage a;
PImage b;
PShape sh1;
int value = 0;
import processing.video.*;
Movie myMovie;
PFont font;
void setup(){
size(1200,900);
bg = loadImage("laguna_1200x900_full_gray.jpg");
background(bg);
imageMode(CENTER);
shapeMode(CENTER);
sh1 = loadShape("test.svg");
font = loadFont("Arial-Black-24.vlw");
textFont(font);
fill(250,169,86);
// historical monuments
ellipse(350, 250, 10, 10);
ellipse(250, 120, 10, 10);
ellipse(150, 250, 10, 10);
ellipse(250, 194, 10, 10);
ellipse(250, 750, 10, 10);
ellipse(170, 450, 10, 10);
ellipse(250, 240, 10, 10);
fill(56,169,86);
// green landscape
ellipse(250, 640, 10, 10);
ellipse(186, 700, 10, 10);
ellipse(230, 450, 10, 10);
ellipse(120, 650, 10, 10);
ellipse(310, 550, 10, 10);
ellipse(630, 350, 10, 10);
ellipse(220, 624, 10, 10);
ellipse(120, 230, 10, 10);
fill(0,176,236);
// marine boats, blue
ellipse(180, 550, 10, 10);
ellipse(455, 590, 10, 10);
ellipse(110, 750, 10, 10);
ellipse(200, 424, 10, 10);
ellipse(176, 800, 10, 10);
ellipse(520, 110, 10, 10);
ellipse(570, 80, 10, 10);
ellipse(430, 250, 10, 10);
ellipse(280, 324, 10, 10);
ellipse(150, 200, 10, 10);
}
void draw(){
if(mouseX >450 && mouseX < 650 && mouseY > 650 && mouseY <850) {
fill(0);
text("Transportation Node", 900, 750, 250, 500);
text("Here you will encounter the door of Timeless Venice", 900, 780, 250, 500);
}
}
void mousePressed() {
if(mouseX >345 && mouseX < 355 && mouseY > 245 && mouseY <255) {
if (mouseButton == LEFT) {
ellipse(350, 250, 0, 0);
shape(sh1, 350, 250, 100, 100);
shape(sh1, 750, 750, 200, 200);
shape(sh1, 550, 750, 200, 200);
}else if (mouseButton == RIGHT){
shape(sh1, 0, 0, 0, 0);
ellipse(350, 250, 10, 10);
}
}
}
1