Daily Creative Coding

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

展開・縮小する弧

/**
* expanding and closing arcs
*
* @author aa_debdeb
* @date 2017/01/21
*/

color[] colors = {
  color(0, 136, 164),
  color(175, 220, 222)
};

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

void draw(){
  background(234, 239, 249);
  translate(150, 300);
  rotate(-PI  / 5.0 * 3.0);
  int partNum = 10;
  int stepNum = partNum * 2 + 1;
  int step = frameCount % stepNum;
  float angSize = (PI / 5.0 * 4) / partNum;
  if(step == 0){
    return; 
  } else if(step < partNum + 1) {
    for(int i = 0; i < step; i++){
      fill(lerpColor(colors[0], colors[1], float(i) / partNum));
      arc(0, 0, 500, 500, angSize * i, angSize * step);
    }
  } else {
    for(int i = step - partNum; i < partNum; i++){
      fill(lerpColor(colors[0], colors[1], float(i) / partNum));
      arc(0, 0, 500, 500, angSize * i, angSize * partNum);
    }  
  }
}
f:id:aa_debdeb:20170116214627j:plain