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)
   displaying images
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: displaying images  (Read 264 times)
der_rabe

343748541343748541 WWW
displaying images
« on: Feb 16th, 2004, 5:36pm »

BImage bild_1;
BImage bild_2;
boolean change;
 
void setup(){
  size(100,100);
  bild_1 = loadImage("sun.jpg");
  bild_2 = loadImage("star.jpg");
  change = true;
}
 
void loop(){
    image(bild_1,0,0);
    delay(1000);
    image(bild_2,0,0);
    delay(1000);
}
 

Bernd Salewski
student of digital media
Hochschule Bremen
toxi_
Guest
Email
Re: displaying images
« Reply #1 on: Feb 16th, 2004, 6:14pm »

wow, so we only have to guess what your problem is!
 
delay() will not actually pause the sketch immediately, only specifies the time between loops. you could re-write it like that:
 
Code:
BImage bild_1;
BImage bild_2;
boolean change;
 
void setup(){
  size(100,100);
  bild_1 = loadImage("sun.jpg");
  bild_2 = loadImage("star.jpg");
  change = true;
}
 
void loop(){
  if (change) image(bild_1,0,0);
  else image(bild_2,0,0);
  change=!change;
  delay(1000);
}

 
macht sinn?
 
toxi_
Guest
Email
Re: displaying images
« Reply #2 on: Feb 16th, 2004, 7:29pm »

mr.rabe, i'm sorry, but i was wrong! please see here
sorry!
 
der_rabe

343748541343748541 WWW
Re: displaying images
« Reply #3 on: Feb 17th, 2004, 3:37pm »

hi toxi,  
 
sorry for my confusing post, but i had serious connection-problems yesterday.  
the problem i had was that of displaying two images alternately.
i could not understand why the code, which i posted does not work.
i have two images which a draw on the screen. one after the other. with a delay in between.
 
i figured out the method with the boolean variable but i still would like to know why the posted code does not
work.
 
any hints?
 

Bernd Salewski
student of digital media
Hochschule Bremen
toxi

WWW
Re: displaying images
« Reply #4 on: Feb 17th, 2004, 5:01pm »

okay, understood. i gueess, it would be because all drawing in processing is done to an offscreen buffer and the content of the sketch/applet window doesn't get updated until loop() has finished. inserting a call to "update()" before each of your delay()'s should solve it, though i'd still prefer the version with the boolean toggle.
 

http://toxi.co.uk/
Pages: 1 

« Previous topic | Next topic »