Daily Creative Coding

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

脈動する2つの円を重ねる

/**
* Pulsebeat
*
* @author aa_debdeb
* @date 2015/12/26
*/

void setup(){
  size(500, 500);
  smooth();
  frameRate(30);
  noStroke();
  fill(255, 0, 0);
}

void draw(){
  float time = frameCount * 0.1;
  background(0);
  translate(width / 2, height / 2);
  rotate(time * 0.1);
  for(float angle = 0; angle < 360; angle += 0.5){
    float radian = radians(angle);
    float amp1 = 150 + 75 * map((1.0 - abs(sin(radian * 8))), 0, 1, -1, 1) * abs(sin(time));
    float amp2 = 150 + 75 * map((1.0 - abs(cos(radian * 8))), 0, 1, -1, 1) * abs(cos(time));
    ellipse(amp1 * cos(radian), amp1 * sin(radian), 2, 2);
    ellipse(amp2 * cos(radian), amp2 * sin(radian), 2, 2);
  }
}