FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   updatestage
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: updatestage  (Read 450 times)
kevin

WWW
updatestage
« on: Jul 28th, 2003, 11:47pm »

Hi all,
 
I'm trying to create a small animation. It's going to be within a for loop, so is it possible to use the draw commands, and and update the screen before continuing with the loop.
 
Or should I be approaching this in a different manner?
 
It seems like a bit of a kludge to 'wrap' the loop around the main loop() to me, but I figured you guys might be able to steer me in the right direction.
 
Thanks,
 
- Kevin
« Last Edit: Jul 28th, 2003, 11:48pm by kevin »  
toxi

WWW
Re: updatestage
« Reply #1 on: Jul 29th, 2003, 3:38pm »

i think you should reconsider your program structure for this one. i know you can use the "long repeat loop plus updateStage" structure in director, but even there it's not the best or cleanest of solutions as everything else will stop and you can potentially lock up the machine for the time your repeat loop is running.
 
a much better/elegant solution is to use the processing main loop() method to do your animation:
 
Code:
int i=0;
 
void setup() {
  size(200,200);
  stroke(0);
}
void loop() {
  if (i<1000) {
    line(i,0,mouseX,mouseY);
    i++;
  }
}

as opposed to something like this:
 
Code:

void setup() {
  size(200,200);
  stroke(0);
}
void draw() {
  for(int i=0; i<1000; i++) {
    line(i,0,mouseX,mouseY);
    update(); // show changes on screen
  }
}

the draw() method is only intended for creating static images. no background refresh will happen (amongst other things).
 

http://toxi.co.uk/
kevin

WWW
Re: updatestage
« Reply #2 on: Jul 29th, 2003, 5:15pm »

on Jul 29th, 2003, 3:38pm, toxi wrote:
a much better/elegant solution is to use the processing main loop() method to do your animation:

 
Ah righty, that was my first inclination but I thought that was the wrong way to approach it, because I wasn't sure how you'd cope with nested loops and the like.  
 
I'll give it a go and see how I get on.
 
Thanks.
 
Pages: 1 

« Previous topic | Next topic »