2009年10月1日 星期四

Homework 2: Repetition

2_1a




size(600,400);
background(250);
frameRate(1);
println(width+" "+height);
for(int i = 0 ; i<=100; i++)
{
fill(random(240),random(240),random(240),random(240));
rect(random(width),random(height),random(150),random(200));
}

2_2改圖



for (int y = 20; y <= 80; y += 6)

{

for (int x =20; x <= 80; x +=6)

{

if ((x % 10) == 0))

{

line(x, y, x+10, y-10);

}

else

{

line(x, y, x-10, y+8);

}

}

}



2_3



size(800,600);
background(250);
for(int x=100; x<800 ; x+=200)
{
for(int y=100; y<600 ;y+=200)
{
fill(188,198,35);
ellipse(x,y,200,200);
}
}
for(int x=100; x<800 ; x+=200)
{
for(int y=100; y<600 ;y+=200)
{
fill(0);
ellipse(x,y,100,100);
}
}
for(int x=100; x<800 ; x+=200)
{
for(int y=100; y<600 ;y+=200)
{
fill(230,120,0);
ellipse(x,y,50,50);
}
}

心得
這次作業比上次的還要活用,上次只是簡單的幾何圖形跟上色,這次有學到怎麼使用時間,讓圖片就像動畫般,不斷地動,不斷地更新,而且第三個開始用起loop,兩個loop一起用,沒試過,是一個很特別的經驗,很好玩,雖然我有不小心把數字"0"打成英文"o",害我一直找不出錯誤,停滯了很久,不過完成後,看著圖片被我用程式畫出來,就覺得很有成就感,不知道下次還會做些什麼好玩的程式。

沒有留言:

張貼留言