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 › performance problem
Page Index Toggle Pages: 1
performance problem? (Read 359 times)
performance problem?
Feb 1st, 2009, 10:45pm
 
hi guys

i just begin to do some sketch in p5 using sin function.
if i write my picture in setup()
no problem.
in draw.. processing goes down, stay in silence, not making any output and i have to force close it by task manager.

i make a nested for in draw.. perfomance problem??

here is my code:

Code:
void setup()  {
size(1000, 1000);
background(255);
//smooth();
}

void draw() {

int i = 0;
int j = 0;
int space = mouseX/10;
int rotation;
int _color = 60;
int _scale = 60;
float rad = PI/180;
float sinVal;

for(;j<5;j++) {

stroke(_color);
for (i=0;i<width;i+=space) {

sinVal = sin(i*rad) * _scale + height-j*2;
rotation = j*space;
line(i+rotation, 0, i, sinVal);
}
//_scale+=25;
_color += 20;
}

}
Re: performance problem?
Reply #1 - Feb 2nd, 2009, 11:03am
 
I think it's that space will equal 0 on the first run through, and so "for(i=0;i<width;i+=space)" will never end
Page Index Toggle Pages: 1