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.
Page Index Toggle Pages: 1
annemarie (Read 293 times)
annemarie
Aug 10th, 2006, 8:09pm
 
Hi all,

I have tried to type different things into a forloop - I just want to make a grid of squares with the size of 20 pixels that take up the entire window, and where every square is different ...

//I guess it is something like this:
for(int i=0; i<SquareAmt; i++) { sX[i]=sX[i] ?; sY[i]=sY[i] ? }
//then later all the squares are drawn
for(int i=0; i<searchRects; i++) { rect(sX[i], sY[i], 20, 20); }
Re: annemarie
Reply #1 - Aug 10th, 2006, 9:15pm
 
Try this:

Code:
int i=0;
// Max i = (width/20)*(height/20)
for(int y=0;y<height/20;y++)
{
for(int x=0;x<width/20;x++)
{
sX[i]=x*20;
sY[i]=y*20;
i++;
}
}
Page Index Toggle Pages: 1