void setup()
{
fullScreen(P3D); // 全屏
textSize(32); // 文字大小
}
float timer = 0;
void draw()
{
background(0); //背景
stroke(#74F599); // 绿色边框
noFill(); //不设置填充
lights(); // 环境光
pushMatrix(); //将当前变换矩阵推送到矩阵堆栈
translate(width/2,height/2,200 * sin(timer));
/* 鼠标左键拖动旋转 */
if (mouseButton == LEFT)
{
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
sphereDetail(mouseX/4); //通过调整球体网格的顶点数量来控制用于渲染球体的细节。默认分辨率为30
}
rotateY(timer); // y 轴旋转
rotateX(PI/6); // x 轴旋转30
sphere(300); //球密度
textMode(CENTER); // 球体中部文字
fill(255, 0, 0);
text("Hello world,My name is F-91", -300, 0, 0);
popMatrix();
timer = (timer+0.01)%TWO_PI;
text(year()+"年"+ month()+"月"+day()+"日"+hour()+"时"+minute()+"分"+second()+"秒",50,height-50,0);
}
void mouseClicked()
{
if (mouseButton == RIGHT)
{
String picName = "PDE_" + year()+ "_" + month()+"_" + day()+"_" + hour()+"_" + minute()+"_" + second();
save(picName + ".png");
println(" ----> Picture saved.");
}
}