Daily Creative Coding

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

トゲトゲの円

/**
* Stinging Circle
*
* @author aa_debdeb
* @date 2015/09/19
*/

float RADIOUS = 200;
float RADIOSU_VARIANT = 20;
float CENTER_X;
float CENTER_Y;

float time = 0.0;
float TIME_STEP = PI / 32.0;

void setup(){
  size(500, 500);
  smooth();  
  noStroke();
  frameRate(30);
  CENTER_X = width / 2.0;
  CENTER_Y = height / 2.0;
}

void draw(){
  background(255);
  fill(220, 20, 60);
  beginShape();
  for(float degree=0; degree < 360.0; degree += 1.0){
    float rad = radians(degree);
    float radious = (RADIOUS + sin(rad * 50) * sin(time) * RADIOSU_VARIANT);
    float x = CENTER_X + radious * cos(rad);
    float y = CENTER_Y + radious * sin(rad);
    vertex(x, y);    
  }
  endShape(CLOSE);
  time += TIME_STEP;
}