import processing.pdf.*;
boolean record = true;
void setup() {
size(500,500, P3D);
noStroke();
}
public void draw() {
if(record){
beginRaw(PDF, "output.pdf");
// beginRecord(PDF, "output.pdf"); //僅能紀錄2D data, 無法紀錄3D data
}
background(0,50,0);
//3D data
lights();
translate(width/2,height/2);
rotateY(PI/4);
rotateX(PI/4);
scale(8);
fill(240,255,0,220);
box(10,50,10);
fill(150,255,0,220);
box(50,10,10);
fill(255,150,0,220);
box(10,10,50);
fill(255, 0, 0, 100);
sphere(15);
//2D data
fill(0, 0, 255, 100);
rect(0, 0, 300, 300);
if(record){
endRaw();
// endRecord(); //僅能紀錄2D data, 無法紀錄3D data
record = false;
println("PDF file is output !");
}
}