日常の進捗

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

イメージと形

なかなか頭のなかにある動きのとおりに形が作れず、時間切れ。

OpenProcessingで選べるレンダラのモードでWEBGLがあるけど、色空間の指定がイメージしているものと違うので今度調べる。

float s = 250;
float step = s / 2.5;

// setup関数 : 初回1度だけ実行される
void setup() {
  size(960, 540,WEBGL); // ウィンドウサイズを960px,540pxに
  smooth(); // 描画を滑らかに
}

// draw関数 : setup関数実行後繰り返し実行される
void draw() {
  stroke(255,255,255);
  lights();
  ambientLight(127, 0, 0);
  background(0, 0, 0);
  translate(width/2, height/2, -500);
  for (float y = -s; y < s; y += step) {
    for (float x = -s; x < s; x += step) {
      fill(0, 80, 100);
      pushMatrix();
      float z1 = map(sin(x*0.001+y*0.002+frameCount*0.01), -1, 1, -s*2, s*2);
      translate(0, 0, z1);
      rotateZ(PI/4);
      pushMatrix();
      translate(x, y, 0);
      float theta = (x+y)*0.5+z1*0.01;
      rotateX(theta);
      rotateZ(frameCount*0.01);
      box(step*1/2);
      popMatrix();
      popMatrix();
    }
  }
  translate(step/2,step/2);
  for (float y = -s; y < s; y += step) {
    for (float x = -s; x < s; x += step) {
      fill(180, 80, 100);
      pushMatrix();
      float z2 = map(sin(PI+x*0.001+y*0.002+frameCount*0.01), -1, 1, -s*2, s*2);
      translate(0, 0, z2);
      rotateZ(PI/4);
      pushMatrix();
      translate(x, y, 0);
      float theta = (x+y)*0.5+z2*0.01;
      rotateX(theta);
      rotateZ(frameCount*0.01);
      box(step*1/2);
      popMatrix();
      popMatrix();
    }
  }
}