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 & HelpPrograms › Simple for loop question.
Page Index Toggle Pages: 1
Simple for loop question. (Read 564 times)
Simple for loop question.
Aug 17th, 2009, 11:03am
 
Hi , I can do a simple line made of ellipses with a for loop with this code :


Code:
size(500,500); 
smooth();
background(255);




for(int i=0;i<width;i+=10){
ellipse(i,i,10,10);

}



But now i want to do it the other way around, like if it was flipped.

but i cant,  i get lots of ellipses all over the screen,  can you explain me why i get that result and how to get the "line" but fliped?

this is my new code wich fills the screen with ellipses:

Code:

size(500,500);
smooth();
background(#F7021F);
int gros = 40;
strokeWeight(gros);
stroke(#212121);








for (int y= height; y>0; y-=gros){
for ( int x=0; x<width; x+=gros) {
ellipse(x,y,5,5);
}
}





Re: Simple for loop question.
Reply #1 - Aug 17th, 2009, 1:13pm
 
First code with line: ellipse(i, width - i, 10, 10); (untested)
If you do two loops, indeed you fill each position, as you act on two dimensions.
Page Index Toggle Pages: 1