2008年4月7日 星期一

for迴圈


void setup()
{
size(800,600);
background(60,60,60);
noLoop();
}
void draw()
{
for(int j=0;j<80;j++)
{
float x,y,c1,c2,c3,c4;
x = random(0,800);
y = random(0,600);
c1 = random(0,255);
c2= random(0,255);
c3 = random(0,255);
c4 = random(0,255);
fill(c1,c2,c3,c4);
ellipse(x,y,40,40);
}
for(int i=0;i<220;i++)>
{
float x,y,lx,ly,c1,c2,c3,c4; // Random rand = new Random();
x = random(0,800);
y = random(0,600);
lx = random(0,100);
ly = random(0,100);
c1 = random(0,255);
c2= random(0,255);
c3 = random(0,255);
c4 = random(0,255);
fill(c1,c2,c3,c4);

rect(x,y,lx,ly); }
}

沒有留言: