Daily Creative Coding

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

円環におけるパルスの伝達

/**
* ripple on circles
*
* @author aa_debdeb
* @date 2016/05/19
*/

color bgc, src;

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

void mousePressed(){
  bgc = color(random(255), random(255), 255);
  src = color(0, 0, random(255));
}

void draw(){
  background(bgc);
  stroke(src);
  strokeWeight(2);
  translate(width / 2, height / 2);
  float maxD = sqrt(sq(width) + sq(height));
  float md = map(frameCount % 50, 0, 49, 0, maxD);
  float dStep = 15;
  for(float d = 0; d <= maxD; d += dStep){
    if(d <= md && md < d + dStep){
      ellipse(0, 0, md, md); 
    } else {
      ellipse(0, 0, d, d);
    }
  }
}