Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

円弧と四角

/**
* arc & rect
*
* @author aa_debdeb
* @date 2016/11/23
*/

int X =25;
int Y = 25;
float step = 20;

void setup(){
  size(500, 500);
  noStroke();
  fill(248, 248, 255);
}

void draw(){
  background(255, 180, 0);
  for(int x = 0; x < X; x++){
    for(int y = 0; y < Y; y++){
      pushMatrix();
      translate(x * step + step / 2, y * step + step / 2);
      if((x + y) % 2 == 0){
        rotate(frameCount * 0.07);
      } else {
        rotate(-frameCount * 0.07);      
      }
      if(x % 2 == 0 && y % 2 == 0){
        arc(0, 0, step, step, HALF_PI, HALF_PI * 4);
      } else if(x % 2 == 1 && y % 2 == 0){
        arc(0, 0, step, step, HALF_PI * 2, HALF_PI * 5);      
      } else if(x % 2 == 0 && y % 2 == 1){
        arc(0, 0, step, step, HALF_PI * 0, HALF_PI * 3);      
      } else if(x % 2 == 1 && y % 2 == 1){
        arc(0, 0, step, step, HALF_PI * -1, HALF_PI * 2);      
      }   
      popMatrix();
    }
  }
}
f:id:aa_debdeb:20161116072515j:plain