Daily Creative Coding

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

様々な色の円を描き続ける

/**
* Endless Circles
*
* @author aa_debdeb
* @date 2015/09/15
*/

float centerX;
float centerY;
float startAngle;
float endAngle;
float currentAngle;
float colorR;
float colorG;
float colorB;
float radious;

float ANGLE_STEP = PI / 32;
float MAX_RADIOUS = 200;
float MIN_RADIOUS = 50;

void setup(){
  size(500, 500);
  smooth();
  frameRate(30);
  noStroke();
  
  background(255);
  setNewCircle();
}

void draw(){
  currentAngle += PI / 128.0;
  fill(colorR, colorG, colorB);
  arc(centerX, centerY, radious * 2.0, radious * 2.0, startAngle, currentAngle);
  
  if(currentAngle >= endAngle){
    setNewCircle();  
  }
}

void setNewCircle(){
  centerX = random(width);
  centerY = random(height);
  startAngle = random(2.0 * PI);
  endAngle = startAngle + 2.0 * PI;
  currentAngle = startAngle;
  radious = random(MAX_RADIOUS - MIN_RADIOUS) + MIN_RADIOUS;
  colorR = random(255);
  colorG = random(255);
  colorB = random(255);
}