Daily Creative Coding

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

揺れる重なった正方形

/**
* waving multi-layered squares
*
* @author aa_debdeb
* @date 2016/09/26
*/

void setup(){
  size(500, 500);
  rectMode(CENTER);
  fill(30);
  stroke(220);
}

void draw(){
  background(220);
  translate(width / 2, height / 2);
  for(int i = 0; i <= 40; i++){
    float x = map(i, 0, 40, 100, -100) + 20 * sin(frameCount * 0.03 + i * PI / 24); 
    float y = map(i, 0, 40, -100, 100) + 20 * cos(frameCount * 0.03 + i * PI / 24); ; 
    rect(x, y, 200, 200);
  }
}
f:id:aa_debdeb:20160921184719j:plain