Daily Creative Coding

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

三次元の表面を波立たせる

/**
* Waving Surface
*
* @author aa_debdeb
* @date 2015/11/25
*/

void setup(){
  size(500, 500, P3D);
  smooth();
  sphereDetail(5);
}

void draw(){
  background(0);
  noStroke();
  lights();
  fill(0, 128, 128);
  for(int x = 0; x <= width; x += 20){
    for(int y = 0; y <= height; y += 20){
      pushMatrix();
      float xAmp = 20 * sin(frameCount * 0.04 + x * 0.03);
      float yAmp = 20 * sin(frameCount * 0.02 + y * 0.03);
      translate(x, y, 0 + xAmp + yAmp);
      sphere(5);
      popMatrix();
    }
  }
}