Daily Creative Coding

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

渦巻く花

/**
* Vortical Flower
*
* @author aa_debdeb
* @date 2016/01/08
*/

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

void draw(){
  float time = frameCount * 0.01;
  background(0);
  translate(width/2, height/2);
  for(int angle = 0; angle < 360; angle += 30){
    float radian = radians(angle);
    for(int radious = 50; radious < 200; radious += 20){
      float radian2 = radians(angle + map(sin(time), -1, 1, -radious, radious));
      PVector position = new PVector(radious * cos(radian2), radious * sin(radian2));
      float distance = position.mag();
      float diameter = map(sin(time * map(distance, 0, 200, 10, 1)), -1, 1, 5, 20);
      fill(map(distance, 0, 200, 255, 255), map(distance, 0, 200, 140, 20), map(distance, 0, 200, 0, 147));
      ellipse(position.x, position.y, diameter, diameter);
    }
  }
}