Hi , i got this sketch :
http://openprocessing.org/visuals/?visualID=9579Is a simple sketch where the rects grow as you hoover over them.
I want that instead of a rect , there was an image .
But the image function only has width and height and format :
PImage()
PImage(width, height)
PImage(width, height, format)
PImage(img)How do i tell processing where to position the image
Can i recycle my code , where i use rects
Code:
int borde = 20;
int hoover = 5;
int borde_hoover;
void setup (){
size (600,600);
smooth();
background (255);
}
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);
}
// functions
void drawR_1 ( int tamanio, int rx_pos, int yx_pos ){
fill (0);
rectMode ( CENTER);
noStroke ();
if (mouseX > borde_hoover && mouseX < width/2-borde_hoover && mouseY > borde && mouseY < height/2-borde_hoover ){
tamanio += hoover ;
}
else{
tamanio -=hoover ;
}
rect ( rx_pos, yx_pos , tamanio, tamanio);
}
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);
}