2008年4月14日 星期一

延伸

從上次的圓形延伸動態變色
效果是每個圓都會隨著時間改變顏色
看起來就像有很多眼睛一直不斷在變色
很有迷幻的感覺

...

其實我是想寫時鐘的,但是processing 不支援單次定義法
也就是..
if(db==null){
db=1;
int x;
}
很可惜,如果processing可以這樣寫的話可以延伸更多動態圖案的...

void setup(){
size(800,600);
frameRate(10);
background(random(5,20),random(5,20),random(5,20),50);
}
void draw(){
for(int i=0;i<=800;i+=200){
for(int j=0;j<=600;j+=200){
fillstar(i,j);
}
}
}

void fillstar(int q,int k){
noStroke();
smooth();
float radius = 1;
for (int deg = 0; deg < 360*40; deg += 55) {
float angle = radians(deg);
float x=q+(cos(angle)*radius);
float y=k+(sin(angle)*radius);
fill(random(10,255),k--,q,q--);
ellipse(x, y, 5, 3);
radius = radius + 0.5;
}
}

沒有留言: