2018年9月27日 星期四

Week03 光

第三週 畫旋轉三角 馬力歐憤怒鳥


void draw(){
  ellipse(250,250, 480,480);//(圓心X,圓心Y,直徑,直徑)
  for(float angle=0; angle<PI*2; angle+=PI/3){//PI=圓周率
    triangle(250,250,//圓心位置
      250+240*cos(angle), 250+240*sin(angle),//圓心位置250+半徑長240
      250+240*cos(angle+PI/3), 250+240*sin(angle+PI/3));
  }
}



noFill();//不填滿















嘗試看影片畫會旋轉的圖 網址:FB社團



void myTriangle(int cx, int cy){
  float a=-PI/2;
  for(int R=15; R>0; R-=5){
    triangle( cx+R*cos(a), cy+R*sin(a),
              cx+R*cos(a+2*PI/3), cy+R*sin(a+2*PI/3),
              cx+R*cos(a-2*PI/3), cy+R*sin(a-2*PI/3) );
  }
}
void draw(){
  background(255);
  for(int cx=15; cx<800; cx+=40){
    for(int cy=15; cy<400; cy+=40){
      myTriangle(cx,cy);
    }
  }
}


沒有留言:

張貼留言