We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › charging an image
Page Index Toggle Pages: 1
charging an image (Read 879 times)
charging an image
May 11th, 2005, 10:32am
 
Hi, My name is Mark and It's the firsttime that I use processing. I'm a student that have to do a project with processing.

I wrote the follow simple code:
-----------------------------
PImage bg;
int a;

void setup()
{
 size(487,683);
 framerate(30);  
 bg = loadImage("homePage.jpg");
}

void draw()
{
 background(bg);
 
}
-----------------------------------
My problesm is: how is possible to define a small area in the image background where I can click (with mouse_pressed) and charge a new image (this new image must replace the old one), like an homepage on the web. Please give me a hand.Thank you.
Re: charging an image
Reply #1 - May 11th, 2005, 2:31pm
 
try this one:
http://processing.org/learning/examples/mousefunctions.html

you should load both images inside setup() and keep them in two variables.
inside draw() you check if the mouse is pressed and if it is inside your hotspot-region. if it is you draw the one image, if it is not you just draw the other ...

F
Re: charging an image
Reply #2 - May 13th, 2005, 11:24am
 
Thank you for your help fjen.
Page Index Toggle Pages: 1