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 › why doesnt end this up in a slow program
Page Index Toggle Pages: 1
why doesnt end this up in a slow program (Read 277 times)
why doesnt end this up in a slow program
Mar 23rd, 2009, 10:30pm
 
What I wondered about the code below is why doesnt it get slow, all shapes created still exist, they only leaved the board the viewable area exept for the rect created which is drawn over and over again. So how it comes that processing doesnt get terrible slow after running this sometime?


float y = 50.0;
float speed = 1.0;
float radius = 15.0;
int direction = 1;

void setup() {
 size(100, 100);
 smooth();
 noStroke();
 ellipseMode(RADIUS);
}

void draw(){
 fill(0, 12);
 rect(0, 0, width, height);
 fill(255);
 ellipse(33, y, radius, radius);
 y += speed * direction;
 if ((y > height-radius) || (y < radius)) {
   direction = -direction;
   println(y);
 }
}
Re: why doesnt end this up in a slow program
Reply #1 - Mar 23rd, 2009, 11:32pm
 
Unlike some other languages (JavaFX for example), rect and ellispe only change some pixels on the screen buffer, they don't create new objects.
Even if they did, they would be eligible for being garbage collected, I suppose.
Page Index Toggle Pages: 1