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 › draw()ing for beginners
Pages: 1 2 
draw()ing for beginners (Read 2042 times)
Re: draw()ing for beginners
Reply #15 - Oct 19th, 2005, 12:43am
 
from the look of this code, my guess is that you're holding down the 's' key, which will cause keyPressed() to be called several times, the same way a key repeats if you hold it down in an application.

which would cause it to save several images in sequence, slowing things down significantly.
Re: draw()ing for beginners
Reply #16 - Oct 19th, 2005, 8:32am
 
Nope, I did not (and I am absolutely certain of that).
Re: draw()ing for beginners
Reply #17 - Oct 19th, 2005, 10:13pm
 
I modified the example program C a bit to prove my point:

Code:
// Example D: No keyboard input but things get r-e-eally sluggish anyway

color[] cols = new color[3];
int a = 0, b = 0, f = 0, t = 0;

void setup() {
size(100, 100);
cols[0] = color(255, 0, 0);
cols[1] = color(0, 255, 0);
cols[2] = color(0, 0, 255);
t = millis();
}

void draw() {
f++;
a = (a + 1) % 2;
b = (b + 1) % 3;
stroke(cols[b]);
for ( int y = a; y < 100; y += 2) {
line(0, y, 99, y);
}
if ( f % 100 == 0 ) {
float frate = 100000.0 / (millis() - t);
println("Framerate = " + frate + " fps. Saving frame " + f + " ...");
saveFrame();
t = millis();
}
}


I get the following output:

Code:
Framerate = 296.7359 fps. Saving frame 100 ...
Framerate = 4.9050865 fps. Saving frame 200 ...
Framerate = 5.0190725 fps. Saving frame 300 ...
Framerate = 4.920049 fps. Saving frame 400 ...


That's whopping 98% decrease in performance after the first call to saveFrame().
Re: draw()ing for beginners
Reply #18 - Oct 20th, 2005, 12:06pm
 
I've just tried this on 0093, and I don't get any decrease in framerate. (Oh and your printed framerate is 10 times higher than reality, try printing the built-in variable 'framerate')


Code:
Framerate = 492.61084 fps. Saving frame 100 ...
Framerate = 492.61084 fps. Saving frame 200 ...
Framerate = 492.61084 fps. Saving frame 300 ...
Framerate = 531.9149 fps. Saving frame 400 ...
Framerate = 531.9149 fps. Saving frame 500 ...
Framerate = 492.61084 fps. Saving frame 600 ...
Framerate = 492.61084 fps. Saving frame 700 ...
Framerate = 492.61084 fps. Saving frame 800 ...
Framerate = 492.61084 fps. Saving frame 900 ...
Framerate = 531.9149 fps. Saving frame 1000 ...
Framerate = 531.9149 fps. Saving frame 1100 ...
Framerate = 531.9149 fps. Saving frame 1200 ...
Framerate = 492.61084 fps. Saving frame 1300 ...
Framerate = 492.61084 fps. Saving frame 1400 ...
Framerate = 492.61084 fps. Saving frame 1500 ...
Framerate = 531.9149 fps. Saving frame 1600 ...
Framerate = 531.9149 fps. Saving frame 1700 ...
Framerate = 492.61084 fps. Saving frame 1800 ...
Framerate = 492.61084 fps. Saving frame 1900 ...
Re: draw()ing for beginners
Reply #19 - Oct 20th, 2005, 12:14pm
 
Quote:
(Oh and your printed framerate is 10 times higher than reality, try printing the built-in variable 'framerate')


I'm an optimist, can't help it Wink
Pages: 1 2