Daily Creative Coding

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

動く色の扇

/**
* moving fan
*
* @author aa_debdeb
* @date 2016/10/12
*/

float y;
float hue;

void setup(){
  size(320, 640);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  fill(0);
  background(0, 0, 100);
  y = height - 100;
}

void draw(){  
  fill(hue, 100, 100, 10);
  float angle = map(noise(frameCount * 0.01 + 10000), 0, 1, 0, PI / 2);
  float radious = map(noise(frameCount * 0.005 + 20000), 0, 1, 100, 600);
  pushMatrix();
  translate(width / 2, y);
  rotate(-HALF_PI);
  arc(0, 0, radious, radious, -angle, angle);
  popMatrix();
  pushMatrix();
  translate(width / 2, y + height);
  rotate(-HALF_PI);
  arc(0, 0, radious, radious, -angle, angle);
  popMatrix();
  y--;
  if(y < 0){
    y = height;
  }
  hue += 0.5;
  if(hue > 360){
    hue -= 360;
  }
}
f:id:aa_debdeb:20161006072424j:plain