Loops for Drawing
You can, of course, use the loop variable to draw things.Gradient
size(256,100);
int x;
for (x=0;x < 256;x++)
{
stroke(x);
line (x,0,x,100);
}
Here, 'x' means both the x coordinate of a line AND the stroke value. You can also generate other variables based on the loop variable.
Row of Dots
size(600,400);
int i;
int x;
int s;
for (i=0 ; i < 10 ; i++)
{
x=i * 50;
s=i * 2;
ellipse(x,200,s,s);
}
Moire
void setup()
{
size(700,500);
}
void draw()
{
int x1,y1;
int x2,y2;
background(0);
stroke(255,255,255,128);
for (y1=0;y1< 500;y1=y1+10)
{
y2=500-y1;
line(0,y1,700,y2);
}
for (x1=0;x1<700;x1=x1+10)
{
x2=700-x1;
line(x1,0,x2,500);
}
}