3D图形的旋转:
//import processing.opengl.*;
void setup(){
size(800, 600, P3D);
noStroke();
fill(255, 190);
}
void draw(){
background(0);
pushMatrix();
translate(width/2, height/2);
rotateX(mouseX/100.0);
rotateY(mouseY/100.0);
int dim = 18;
for(int i = -height/2; i < height/2; i+=dim*1.2){
for(int j = -height/2; j < height/2; j+=dim*1.2){
beginShape();
vertex(i, j, 0);
vertex(i+dim, j, 0);
vertex(i+dim, j+dim, -dim);
vertex(i, j+dim, -dim);
endShape();
}
}
popMatrix();
String time = "The time is " + hour() + ":" + minute() + ":" + second() + "\n";
pushMatrix();
translate(0,0,0);
stroke(255, 255, 0);
text(time, 20, 20);
noStroke();
popMatrix();
}