Daily Creative Coding

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

重なる市松模様

/**
* overlayed checks
*
* @author aa_debdeb
* @date 2016/03/26
*/

int CELL_NUM = 200;
int CELL_SIZE = 10;

void setup(){
  size(640, 640);
  noStroke();
  background(255);
}

void draw(){
  translate(mouseX, mouseY);
  rotate(frameCount * 0.05);
  for(int x = 0; x <CELL_NUM; x++){
    for(int y = 0; y < CELL_NUM; y++){
      if(frameCount % 2 == 1 && (x + y) % 2 == 0){
        fill(0);
        rect(x * CELL_SIZE - CELL_SIZE * CELL_NUM / 2, y * CELL_SIZE - CELL_SIZE * CELL_NUM / 2, CELL_SIZE, CELL_SIZE);
      } else if(frameCount % 2 == 0 && (x + y) % 2 == 1){
        fill(255);
        rect(x * CELL_SIZE - CELL_SIZE * CELL_NUM / 2, y * CELL_SIZE - CELL_SIZE * CELL_NUM / 2, CELL_SIZE, CELL_SIZE);
      }
    }
  }
}