Daily Creative Coding

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

回転する重なった円

/**
* rotating circles
*
* @author aa_debdeb
* @date 2016/03/03
*/

void setup(){
  size(500, 500);
  frameRate(30);

  stroke(0);
  strokeWeight(1);

}

void draw(){
  background(255);
  translate(width / 2, height / 2);
  rotate(frameCount * 0.3);
  for(float i = 0.0; i <= 1.0; i += 0.02){
    float diameter = map(i, 0, 1, 500, 0);
    float diff = map(i, 0, 1, 0, (500.0 / 2.0) * map(sin(frameCount * 0.017), -1, 1, 0.1, 0.9));
    float gray = map(pow(i, 0.5), 0, 1, 30, 255);
    pushMatrix();
    translate(diff, 0);
    fill(gray);
    ellipse(0, 0, diameter, diameter);
    popMatrix();
  }
}