cubicgrid.pde

来自「This is processing for java examples.」· PDE 代码 · 共 48 行

PDE
48
字号
/** * Cubic Grid  * by Ira Greenberg.  *  * 3D translucent colored grid uses nested pushMatrix() * and popMatrix() functions.  */float boxSize = 40;float margin = boxSize*2;float depth = 400;color boxFill;void setup() {  size(640, 360, P3D);  noStroke();}void draw() {  background(255);    // Center and spin grid  translate(width/2, height/2, -depth);  rotateY(frameCount * 0.01);  rotateX(frameCount * 0.01);  // Build grid using multiple translations   for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){    pushMatrix();    for (float j =- height+margin; j <= height-margin; j += boxSize){      pushMatrix();      for (float k =- width+margin; k <= width-margin; k += boxSize){        // Base fill color on counter values, abs function         // ensures values stay within legal range        boxFill = color(abs(i), abs(j), abs(k), 50);        pushMatrix();        translate(k, j, i);        fill(boxFill);        box(boxSize, boxSize, boxSize);        popMatrix();      }      popMatrix();    }    popMatrix();  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?