Daily Creative Coding

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

柔らかい発光体

/**
* soft illuminant
*
* @author aa_debdeb
* @date 2016/06/07
*/

PVector nStart;
float hue;

void setup(){
  size(500, 500);
  noStroke();
  nStart = new PVector(random(1000), random(1000), random(1000));
  background(30);
  hue = 0;
}

void draw(){
  colorMode(RGB, 255, 255, 255);
  fill(30, 30);
  rect(0, 0, width , height);
  colorMode(HSB, 360, 100, 100);
  translate(width / 2, height / 2);
  for(float radious = 250; radious >= 0; radious -= 2){
    float sat = map(sq(radious), 0, sq(250), 0, 100);
    fill(hue, sat, 100);
    beginShape();
    for(float radian = 0; radian < TWO_PI; radian += PI / 128){
      float xOffset = radious * cos(radian);
      float yOffset = radious * sin(radian);
      float rNoise = map(noise(xOffset * 0.01 + nStart.x, yOffset * 0.01 + nStart.y, frameCount * 0.03 + nStart.z), 0, 1, -50, 50);
      float x, y;
      if(radious + rNoise > 0){
        x = (radious + rNoise) * cos(radian);
        y = (radious + rNoise) * sin(radian);
      } else {
        x = 0;
        y = 0;
      }
      vertex(x, y);    
    }
    endShape(CLOSE);
  }
  hue += 0.3;
  if(hue > 360){
    hue -= 360;
  }
}