読者です 読者をやめる 読者になる 読者になる

Daily Creative Coding

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

トゲトゲの円

/**
* Unshaped Circle
*
* @author aa_debdeb
* @date 2016/02/03
*/

void setup(){
  size(500, 500);
  noFill();
  mouseMoved();
}

void draw(){
}

void mouseMoved(){
  background(255);
  beginShape();
  float angStep = map(mouseX, 0, width, 30, 1);
  float radiousWidth = map(mouseY, 0, height, 30, 120);
  PVector[] heads = new PVector[3];
  for(int angle = 0, i = 0; angle < 360; angle += angStep){
    float radian = radians(angle);
    float radious = map(random(1), 0, 1, 150 - radiousWidth / 2, 150 + radiousWidth / 2);
    float x = 250 + radious * cos(radian);
    float y = 250 + radious * sin(radian);
    if(i == 0 || i == 1 || i == 2){
      heads[i] = new PVector(x, y);
    }
    curveVertex(x, y);
    i++;
  }
  for(int i = 0; i < 3; i++){
    curveVertex(heads[i].x, heads[i].y);  
  }

  endShape();
}