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

Daily Creative Coding

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

層が回転しながら入れ替わるリング

決定論
f:id:aa_debdeb:20161029162122j:plain

two-layered ring - OpenProcessing

/**
* two-layered ring
*
* @author aa_debdeb
* @date 2016/11/04
*/

float radius1 = 125;
float radius2 = 50;

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

void draw(){
  fill(0, 150);
  rect(0, 0, width, height);
  translate(width / 2, height / 2);
  for(float angle = 0; angle < 360; angle += 10){
    float radian1 = radians(angle);
    pushMatrix();
    translate(radius1 * cos(radian1), radius1 * sin(radian1));
    float radian2 = radian1 - frameCount * 0.04;
    fill(0, 191, 255);
    ellipse(radius2 * cos(radian2), radius2 * sin(radian2), 10, 10);
    fill(255, 191, 0);
    ellipse(radius2 * cos(radian2 + PI), radius2 * sin(radian2 + PI), 10, 10);
    popMatrix();
  }
}