Daily Creative Coding

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

ラインで複雑なスパイラル2

/**
* 4 Spirals By Line
*
* @author aa_debdeb
* @date 2015/10/17
*/

ArrayList<PVector> circles = new ArrayList<PVector>();
float radious1 = 200, radious2 = 75;

void setup(){
  size(500, 500);
  smooth();
  frameRate(24);
  background(0);

  circles.add(new PVector(75, 75));
  circles.add(new PVector(-75, 75));
  circles.add(new PVector(75, -75));
  circles.add(new PVector(-75, -75));
}

void draw(){
  noStroke();
  fill(0, 100);
  rect(-1, -1, width + 1, height + 1);
  stroke(0, 139, 139, 200);
  strokeWeight(1);
  translate(width/2, height/2);
  for(int angle = 0; angle < 360; angle+=5){
    float radian1 = radians(angle);
    float radian2 = radian1 + frameCount * 0.1;
    for(PVector circle: circles){
      line(radious1 * cos(radian1), radious1 * sin(radian1),
           circle.x + radious2 * cos(radian2), circle.y + radious2 * sin(radian2));
    }  
  }  
}