rotate2.pde

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

PDE
43
字号
/** * Rotate 2.  *  * The push() and pop() functions allow for more control over transformations. * The push function saves the current coordinate system to the stack  * and pop() restores the prior coordinate system.  */ float a;                          // Angle of rotationfloat offset = PI/24.0;             // Angle offset between boxesint num = 12;                     // Number of boxescolor[] colors = new color[num];  // Colors of each boxcolor safecolor;boolean pink = true;void setup() {   size(640, 360, P3D);  noStroke();    for(int i=0; i<num; i++) {    colors[i] = color(255 * (i+1)/num);  }  lights();}  void draw() {       background(0, 0, 26);  translate(width/2, height/2);  a += 0.01;       for(int i = 0; i < num; i++) {    pushMatrix();    fill(colors[i]);    rotateY(a + offset*i);    rotateX(a/2 + offset*i);    box(200);    popMatrix();  }} 

⌨️ 快捷键说明

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