1. 程式人生 > >Processing 教程(13) 我的3D開山之作!

Processing 教程(13) 我的3D開山之作!


float t;
void setup(){
//size(720,404, P3D);
fullScreen(P3D);
t=0;
textSize(32);
}


void draw(){
  background(20);
  noFill();
  stroke(#74F599);
  
  lights();
  pushMatrix();
  translate(width/2, height/2, 200 * sin(t));
  rotateY(t);
  rotateX(PI/6);
  sphere(300);
  fill(#74F599);
  textMode(CENTER);
  text(str(second()*19840921),0,0,0);
  popMatrix();
  String time_now = str(year()) + " - " + str(month()) + " - " + str(day()) + " - " + str(hour()) +" : " + str(minute()) +" : " + str(second());
  text(time_now,100,150,0);
  text("Frame count: " + str(frameCount),100,200,0);
  t = (t + 0.01) % TWO_PI;
}


void mouseClicked(){  
    if(mouseButton == RIGHT){          
        String picName = "PDE_" + year()+ "_" + month()+"_" + day()+"_" +   
                                  hour()+"_" + minute()+"_" + second();  
        save("D:\\myProcessingPics\\" + picName + ".png");  
        println(picName + " ----> Picture saved.");  
    }  
}