Daily Creative Coding

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

踊るリング

/**
* dancing ring
*
* @author aa_debdeb
* @date 2016/08/10
*/

void setup(){
  size(640, 480, P3D);
  noFill();
  stroke(255);
  strokeWeight(3);
}

void draw(){
  background(0, 206, 209);
  translate(width / 2, height / 2);
  rotateY(frameCount * 0.02);
  for(float degree = 0; degree < 360; degree += 10){
    float radian = radians(degree);
    pushMatrix();
    float x = map(sin(frameCount * 0.1), -1, 1, 120, 180) * cos(radian);
    float y = map(sin(frameCount * 0.01), -1, 1, -50, 50) * sin(radian * 2 + frameCount * 0.1);
    float z = map(sin(frameCount * 0.03 + PI / 3), -1, 1, 120, 180) * sin(radian);
    translate(x, y, z);
    rotateY(-radian);
    ellipse(0, 0, 50, 50);
    popMatrix();
  }
}
f:id:aa_debdeb:20160804180557j:plain