Daily Creative Coding

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

菊の花

/**
* flower of chrysanthemum
*
* @author aa_debdeb
* @date 2016/05/29
*/

float gray;
float grayStep;
float offset1, offset2; 

void setup(){
  size(500, 500);
  background(0);
  gray = 128;
  grayStep = 0.5;
  offset1 = random(10000);
  offset2 = random(10000);
}

void draw(){
  stroke(gray, 30);
  float radious = map(noise(frameCount * 0.021 + offset1), 0, 1, 50, 300);
  float radianNoise = map(noise(frameCount * 0.0037 + offset2), 0, 1, -PI / 2, PI / 2);
  translate(width / 2, height / 2);
  for(float angle = 0; angle < 360; angle += 20){
    float radian = radians(angle) + radianNoise;
    line(0, 0, radious * cos(radian), radious * sin(radian));
  }
  gray += grayStep;
  if(gray == 0 || gray == 255){
    grayStep *= -1;
  }
}