日常の進捗

主に自分のための,行為とその習慣化の記録

#Codevember day11: RGB

ザ・手癖でコーディングした.

function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);   
}

function draw() {
  background(0);
    
  ambientLight(100);
    directionalLight(255,255,255,0,0,1); 
  
  normalMaterial();
  
  translate(0,0,-500);
  // 回転
  rotateX(radians(frameCount * 0.3));
  rotateY(radians(frameCount * 0.4));
  rotateZ(radians(frameCount * 0.5));

  for (let z = -250; z < 250; z += 500 / 10) {
    for (let y = -250; y < 250; y += 500 / 10) {
      for (let x = -250; x < 250; x += 500 / 10) {
                push();
        translate(x,y,z);
        noStroke();
        let r = map(x,-250,250,0,255);
        let g = map(y,-250,250,0,255);
        let b = map(z,-250,250,0,255);
        
        let n = map(sin(radians(z * 500 * 500 + y * 500 + x + frameCount*10)),-1,1,0,500/10);
        
        fill(r,g,b);
                box(n);        
        pop();
      }
    }
  }
}