2016年3月24日 星期四

02160615_成庭萱_week05

第一節課

先看別人做的範例影片
(1)有很多視窗 可以變化成不同的字
(2)眼睛會轉動

google: processing create window


1. 眼睛會轉動















void setup(){
  size(120,100);
}
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(120-40+15*cos(t),50+15*sin(t),5,5);
}

需要用到三角函數 會比較難


第二節課

2. 眼睛會跟著滑鼠跑
void setup(){
  size(320,300);
}
void draw(){
  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(120-40+15*cos(t),50+15*sin(t),5,5);
}


3. 雙螺旋
void setup() {
  size(600, 600);
}
void draw() {
  background(255);
  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);
  }
}

會像DAN雙股螺旋一樣
只是方向有點不對
要自己在調過

沒有留言:

張貼留言