Daily Creative Coding

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

ツイストする四角形

/**
* Twisting Rectangle
*
* @author aa_debdeb
* @date 2015/10/18
*/

void setup(){
  size(500, 500);
  smooth();
  frameRate(24);
}

void draw(){
  fill(0, 150);
  rect(-1, -1, width, height);
  noStroke();
  fill(0, 255, 0, 200);
  translate(width/2, height/2);
  for(int x = -150; x <= 150; x += 10){
    for(int y = -150; y <= 150; y += 10){
      float distance = sqrt(x * x + y * y);
      pushMatrix();
      rotate((distance / (150 * sqrt(2))) * PI * sin(frameCount * 0.1));
      ellipse(x, y, 7, 7);
      popMatrix();  
    }
  }
}