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 › Problem with images transitions
Page Index Toggle Pages: 1
Problem with images transitions (Read 1735 times)
Problem with images transitions
Jun 10th, 2010, 6:13pm

I'm making a program that includes 5 images connected to arduino.
What do i need to do?

I need to load that images ( all vectors ) , and my animation will start one of this images, and each pulse that arudino sends to processing, make the alpha transition between the images.

I have already make this:

void setup(){


PImage a;
a = loadImage("1.jpg");
image(a, 0, 0);

PImage b;
b = loadImage("2.jpg");
image(b, 0, 0);


void draw(){
 if (portaArduino.available() > 0)   // Se o dado esta disponivel,
   val = portaArduino.read();         // leia esse valor e armazene em "val"

 // - - - - LDRS COME‚àö√°O
 switch(val) {

 case 110: //
   int cont = 5;
   a = tint(255,(60+cont));

The code its not ready yet as you can see. I make a counter to change the alpha channel for each image when comes the pulse. BUUT, when the arduino stops to send pulses, the alpha needs to come back to normal gradually


Re: Problem with images transitions
Reply #1 - Jun 13th, 2010, 4:27pm
Hi Gustavo,

The tint(...) function works like the stroke(...) and fill(...) functions: it prepares the "painting brush" for the next image.  They don't change images that have already been drawn.

Thus, you want to move the image(...) and tint(...) calls into draw(), which is better anyway because setup() is for setup and draw() is for drawing Wink  Make sure each tint(...) call is before the image(...) call for which you intended it.

You'll need to move the PImage a/b declarations outside the setup() function to make them available in draw(), of course.  Also, your cont variable should be a global variable as well.  You can increase it if arduino sends pulses, and decrease it otherwise.

Hope that helps.
Page Index Toggle Pages: 1