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_
   Bugs
   Software Bugs
(Moderator: fry)
   clear trouble?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: clear trouble?  (Read 1580 times)
Martin

122417302122417302martingomez_listsmg1ph WWW Email
clear trouble?
« on: Nov 1st, 2004, 5:15pm »

got my hands on processing again. was wondering if this should matter...
 
void loop() // this works
{
  clear(); // <-----
  ellipseMode( CENTER_DIAMETER );
  stroke(0,153,204,255);
  fill(0,153,204,75);
  ellipse( 100, 100, 100, 100 );
}
 
void loop() // this DOESN'T work
{
  ellipseMode( CENTER_DIAMETER );
  stroke(0,153,204,255);
  fill(0,153,204,75);
  ellipse( 100, 100, 100, 100 );
  clear(); // <-----
}
 
when clear() is called at the end, everything just clears and doesn't redraw as it should be.
 
btw, am using 0067
« Last Edit: Nov 1st, 2004, 5:27pm by Martin »  
fry


WWW
Re: clear trouble?
« Reply #1 on: Nov 1st, 2004, 6:22pm »

clear() is an internal function, you shouldn't use it. use background() instead if you want to clear the background.
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: clear trouble?
« Reply #2 on: Nov 2nd, 2004, 5:32am »

got it. same case for background(). it clears the whole canvas and doesn't redraw.
 
fjen

WWW
Re: clear trouble?
« Reply #3 on: Nov 2nd, 2004, 1:44pm »

loop() is called _to_ redraw the screen. if you call background at the end it just "clears" everything after you've drawn something to it and before it's shown. so use background always at the beginning.
 
think of it this way:
everything in loop is drawn to a image which is pasted onto screen _after_ loop is done.
 
i think there are _no_ operations in processing except for draw and loop which redraw the screen by themselfs. the screen is redrawn as often as possible or as often as you want it to (framerate()).
 
/F
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: clear trouble?
« Reply #4 on: Nov 6th, 2004, 3:12pm »

agree. was thinking, it might be good to have some detection scheme since say, a beginner wouldn't know this. a high school student for example would think of loop() as an infinite cycle of sorts -- what comes around goes around. what do you think?
 
cello

marcello3d WWW
Re: clear trouble?
« Reply #5 on: Nov 7th, 2004, 12:44am »

I think the concept of stuff happening in order in a computer program is pretty rudimentary knowledge.  If someone writes on chalkboard then erases it, the chalkboard will be blank.  If they first erase it, then write on it, you will see their writing.
 
The key difference here is that the lights are shut off before loop() starts, and turned on again after loop() completes.  So you don't know what happens in the interim.
 
The function has been renamed to the more accurate draw() in megabucket, so that should help avoid unnecessary confusion.
 
Marcello
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: clear trouble?
« Reply #6 on: Nov 7th, 2004, 11:15am »

thanks for this cello.
 
Pages: 1 

« Previous topic | Next topic »