Daily Creative Coding

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

くるくる回る円

/**
* flip-flop
*
* @author aa_debdeb
* @date 2016/12/11
*/

int CIRCLE_NUM = 10;
float CIRCLE_SIZE = 50;
color bg, c1, c2;

void setup(){
  size(500, 500);
  mousePressed();
}

void mousePressed(){
  c1 = color(random(255), random(255), random(255));
  c2 = color(255 - red(c1), 255 - green(c1), 255 - blue(c1));
  bg = color(random(255), random(255), random(255));
}

void draw(){
  background(bg);
  noStroke();
  float sinVal = sin(frameCount * 0.25);
  for(int x = 0; x < CIRCLE_NUM; x++){
    for(int y = 0; y < CIRCLE_NUM; y++){
      if(sin < 0){
        if((x + y) % 2 == 0){
          fill(c1);
        } else {
          fill(c2);
        }
      } else {
        if((x + y) % 2 == 0){
          fill(c2);
        } else {
          fill(c1);
        }
      }
      ellipse((x + 0.5) * CIRCLE_SIZE, (y + 0.5) * CIRCLE_SIZE, abs(sinVal * CIRCLE_SIZE), CIRCLE_SIZE);
    }
  }
}
f:id:aa_debdeb:20161209203054j:plain