Daily Creative Coding

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

波面 3D

/**
* surface of wave 
*
* @author aa_debdeb
* @date 2016/10/15
*/

PVector center;
PVector nOffset;

void setup(){
  size(500, 500, P3D);
  center = new PVector(width / 2, height / 2);
  nOffset = new PVector(random(10000), random(10000));
}

void draw(){
  background(160, 220, 255);
  translate(width / 2, height * 2.0 / 3);
  rotateX(PI / 2);
  
  for(int w = -500; w <= 500; w += 5){
    for(int h = -500; h <= 500; h += 5){
      float sv = sin(h * 0.01 + frameCount * 0.01);
      float nv = noise(w * 0.01 + nOffset.x, h * 0.01 + nOffset.y + frameCount * 0.01, frameCount * 0.01);
      float alpha = map(sv * nv, -1, 1, 0, 255);
      float z = map(sv * nv, -1, 1, -150, 150);
      stroke(150, alpha);
      point(w, h, z);
    }
  }
}
f:id:aa_debdeb:20161009075346j:plain