|
Author |
Topic: Repaint background in for-loop (Read 337 times) |
|
mogens Guest
|
Repaint background in for-loop
« on: Mar 3rd, 2004, 2:04pm » |
|
Sorry if this is a silly question. But how do I force the background to refresh from within a "for"-loop? This does not seem to work (draw a line at the final position. Not a line moving across the screen) for (int x=0; x<100; x++) { background(100); line (x,0,x,100); }
|
|
|
|
TomC
|
Re: Repaint background in for-loop
« Reply #1 on: Mar 3rd, 2004, 3:05pm » |
|
As I understand it, everything is automatically double buffered, and the buffers are flipped after the loop function returns. There might be a sneaky undocumneted way to do it, but without fighting processing I think the effect you want is best achieved like so: Code: int x = 0; void loop() { background(100); line (x,0,x,100); x++; if (x >= 100) { x = 0; } } |
|
|
|
|
|
mogens Guest
|
Re: Repaint background in for-loop
« Reply #2 on: Mar 3rd, 2004, 8:53pm » |
|
You're right. I can achieve the moving line. But I was woundering why it didn't work from within the for-loop. I guess you are right - it must be the buffering! MO
|
|
|
|
|