2018年9月27日 星期四

week 03 0927

1.

void setup(){
 size(500,500);
}
void draw(){
    ellipse(250,250,480,480); //圓
    for(float angle=0; angle<PI*2; angle+=PI/3){
      triangle(250,250,
            250+240*cos(angle), 250+240*sin(angle),
            250+240*cos(angle+PI/3),250+240*sin(angle+PI/3));
    }
}

2.

void setup(){
 size(500,500);
}
void draw(){
    ellipse(250,250,480,480);
    for(float angle=0; angle<PI*2; angle+=PI/3){
      for(int R=0; R<=240; R+=20){  //圓內畫線
        noFill();
      triangle(250,250,
            250+R*cos(angle), 250+R*sin(angle),
            250+R*cos(angle+PI/3),250+R*sin(angle+PI/3));
      }
  }
}

3.

void setup(){
 size(500,500);
}
void myTriangle(int cx, int cy){
  float R=20, a=PI/2;
    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(225);
  for(int cx=10; cx<800; cx+=40){
    for(int cy=10; cy<400; cy+=40){
      myTriangle(cx,cy);
    }
  }
}

4.

void setup(){
 size(500,500);
}
void myTriangle(int cx, int cy){
  float R=20, a=-PI/2; //三角形轉向
    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(225);
  for(int cx=10; cx<800; cx+=40){
    for(int cy=10; cy<400; cy+=40){
      myTriangle(cx,cy);
    }
  }
}

沒有留言:

張貼留言