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 & HelpPrograms › image transition
Page Index Toggle Pages: 1
image transition (Read 1291 times)
image transition
Dec 10th, 2005, 1:22pm
 
how could I create a smooth transition between two PImage instances ?

thanks
Re: image transition
Reply #1 - Dec 10th, 2005, 2:57pm
 
Re: image transition
Reply #2 - Dec 10th, 2005, 3:01pm
 
I tried with tint() but don't understand it well ... could you help me ?

If I have PImage1 and PImage2...

should I create all images between 1 and 2 and then output them in sequence ?
or is there another way ?
how does tint create the in between images ?

thanks
Re: image transition
Reply #3 - Dec 10th, 2005, 3:26pm
 
What I'd do is:
Code:
int a;
PImage img1;
PImage img2;

void setup()
{
size(200,200,P3D); // or however big you need.
img1=loadImage("image1.jpg");
img2=loadImage("image2.jpg");
a=0;
}

void draw()
{
image(img1,0,0);
tint(255,255,255,a); // 4th variable is the alpha, or transparency.
// so the next image will start off 100% transaprent, then
// slowly fade into view, until it's solid.
image(img2,0,0);
if(a<255);
a++;
}
Re: image transition
Reply #4 - Dec 10th, 2005, 3:50pm
 
thanks for the code...

I think it might not work since everytime you display the image , the current background is not the first image anymore...
that could give strange results i think ...
am I wrong ?
Re: image transition
Reply #5 - Dec 10th, 2005, 4:04pm
 
You're probably right. The tint carries over from one loop through draw to the next, so you need to reset the tint before drawing img1 then set it to the variable tint before img2.

Code:
int a;
PImage img1;
PImage img2;

void setup()
{
size(200,200,P3D); // or however big you need.
img1=loadImage("image1.jpg");
img2=loadImage("image2.jpg");
a=0;
}

void draw()
{
background(0);
noTint();
image(img1,0,0);
tint(255,255,255,a);
image(img2,0,0);
if(a<255)
a++;
}
Re: image transition
Reply #6 - Dec 10th, 2005, 4:09pm
 
wouldn't that make a flikker effect ?
Re: image transition
Reply #7 - Dec 10th, 2005, 6:34pm
 
I've answered this question before. I'm pretty sure of it.

Twice I believe

And in case you don't believe my code works.

And JohnG's first code works fine. Tint doesn't need reseting, not with JAVA2D at least. Depends on what you're doing I guess.
Page Index Toggle Pages: 1