I have a somewhat simple sketch but whenever I export to pdf it looks really bad. What is the best way to get a vector file for this sketch that will look like how it does when run in Processing?
import processing.pdf.*;
boolean recordPDF;
float grid = 200;
float angle;
void setup() {
size(500, 500, P3D);
rectMode(CENTER);
background(255);
}
void draw () {
// Begin making the PDF
if (recordPDF) {
beginRaw(PDF, "3D.pdf" );
}
colorMode(HSB, 100, 100, 100, 100);
translate(width/2, height/2);
rotateX(radians(angle/1));
rotateY(radians(angle/2));
float h1 = map(sin(angle/50), -1, 1, 50, 100);
float h2 = map(sin(angle/50), -1, 1, 70, 100);
noStroke();
fill(h1, h1, 100, 1);
ellipse(0, 0, grid, grid);
fill(h2, h2, 100, 1);
ellipse(0, 0, grid, grid);
angle+=1;
if (recordPDF) {
endRaw();
recordPDF = false;
}
}
void keyPressed() {
// Use a key press so that it doesn't make a million files
if (key == 'r') {
recordPDF = true;
}
}
Then I trued using Pgraphics
and that looks super off (2d):
import processing.pdf.*;
boolean recordPDF;
PGraphics pg1;
float grid = 200;
float angle;
void setup() {
size(500, 500, P3D);
pg1 = createGraphics(width, height, P3D);
rectMode(CENTER);
background(255);
}
void draw () {
// Begin making the PDF
pg1.beginDraw();
pg1.colorMode(HSB, 100, 100, 100, 100);
pg1.translate(width/2, height/2);
pg1.rotateX(radians(angle/1));
pg1.rotateY(radians(angle/2));
float h1 = map(sin(angle/50), -1, 1, 50, 100);
float h2 = map(sin(angle/50), -1, 1, 70, 100);
pg1.noStroke();
pg1.fill(h1, h1, 100, 20);
pg1.ellipse(0, 0, grid, grid);
pg1.fill(h2, h2, 100, 20);
pg1.ellipse(0, 0, grid, grid);
angle+=1;
}