2016年3月24日 星期四

02160040_周子伍, Week05

今天首要做的是畫會動的眼睛眼球
以下為程式碼:

void setup(){
  size(120,120);
}
void draw(){
  float t =frameCount/180.0*PI;
  background(0);
  fill(255);
  ellipse(40,50, 33,33);
  ellipse(120-40,50,33,33);
  fill(0);
  ellipse(40+15*cos(t),50+15*sin(t),5,5);
  ellipse(123-40+15*cos(t),50+15*sin(t),5,5);
}


這個是用滑鼠控制眼球,可以做出鬥雞眼
以下為程式碼:

void setup(){
  size(120,120);
}
void draw(){
  //float t =frameCount/180.0*PI;
  background(0);
  fill(255);
  ellipse(40,50, 33,33);
  ellipse(120-40,50,33,33);
  fill(0);
  float t=atan2(mouseY-50,mouseX-45);
  ellipse(40+15*cos(t),50+15*sin(t),5,5);
  t=atan2(mouseY-50,mouseX-(120-40));
  ellipse(123-40+15*cos(t),50+15*sin(t),5,5);

這個是做雙螺旋轉動
程式碼如下:
void setup(){
  size(600,600);
}
void draw(){
  //float t =frameCount/180.0*PI;
  background(0);
  float t=frameCount/100.0;
  for(float f=0; f<PI; f+=0.1){
    rect(200+150*cos(f+t),f*100,30,30);
    rect(200+150*cos(f+t+PI),f*100,30,30);
  }
}  



沒有留言:

張貼留言