I have this code , where if you press the image on the top -left corner , it takes you to processing.com.
Buut the thing is , like it is on draw it opens many links ,
is there a way to make the mousepressed only act once ???
heres the code :
you need an image called "javi_img_01.jp" in your folder , just rename any image and put it in the sketch folder.
thanx !!!
Code:int borde = 20;
int hoover = 5;
int borde_hoover;
PImage b;
void setup(){
size(600,600);
smooth();
background(255);
b = loadImage("javi_img_01.jpg");
}
void draw(){
background(255);
drawR_1(width/2-borde,width/4,height/4);
drawR_2(width/2-borde,width-width/4,height/4);
drawR_3(width/2-borde,width/4,height-height/4);
drawR_4(width/2-borde, width-width/4,height-height/4);
}
void drawR_1( int tamanio, int rx_pos, int yx_pos ){
fill (0);
imageMode(CENTER);
noStroke ();
if(mouseX > borde_hoover && mouseX < width/2-borde_hoover && mouseY > borde && mouseY < height/2-borde_hoover ){
tamanio += hoover ;
} else {
tamanio -=hoover ;
}
image (b , rx_pos, yx_pos , tamanio, tamanio);
// here is link
if (mouseX > borde_hoover && mouseX < width/2-borde_hoover && mouseY > borde && mouseY < height/2-borde_hoover && mousePressed == true ){
link("http://processing.org");
}
}
void drawR_2 ( int tamanio, int rx_pos, int yx_pos ){
fill (0);
rectMode ( CENTER);
noStroke ();
if (mouseX > width/2+borde_hoover && mouseX < width-borde_hoover && mouseY > borde && mouseY < height/2-borde_hoover ){
tamanio += hoover ;
}
else{
tamanio -=hoover ;
}
rect ( rx_pos, yx_pos , tamanio, tamanio);
}
void drawR_3 ( int tamanio, int rx_pos, int yx_pos ){
fill (0);
rectMode ( CENTER);
noStroke ();
if (mouseX > borde && mouseX < width/2-borde_hoover && mouseY > height/2 && mouseY < height-borde_hoover ){
tamanio += hoover ;
}
else{
tamanio -=hoover ;
}
rect ( rx_pos, yx_pos , tamanio, tamanio);
}
void drawR_4 ( int tamanio, int rx_pos, int yx_pos ){
fill (0);
rectMode ( CENTER);
noStroke ();
if (mouseX > width/2+borde_hoover && mouseX < width- borde && mouseY > height/2+borde_hoover && mouseY < height-borde_hoover ){
tamanio += hoover ;
}
else{
tamanio -=hoover ;
}
rect ( rx_pos, yx_pos , tamanio, tamanio);
}