Daily Creative Coding

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

三次元のホワイトノイズ

/**
* 3D White Noise
*
* @author aa_debdeb
* @date 2015/11/27
*/

void setup(){
  size(500, 500, P3D);
  smooth();
  frameRate(30);
}

void draw(){
  background(255);
  stroke(0);
  strokeWeight(1);
  fill(128, 128);
  lights();
  rotateX(-PI / 4);
  rotateY(-PI / 4);
  for(int x = 0; x <= 300; x+= 20){
    for(int y = 0; y <= 300; y+= 20){
      for(int z = 0; z <= 300; z += 20){
        if(random(1) < 0.5){
          pushMatrix();
          translate(x - 50, y + 300, z - 400);
          box(20, 20, 20); 
          popMatrix();
        }
      }
    }
  }
}