export PGraphic as pdf
              in 
             Programming Questions 
              •  
              2 years ago    
            
 
           
             If you run this script and press the mouse to save the pdf then 1 line is vector and the other is made out of pixels.
            
I need them both out of vectors. I understand that it's pixels because i use the image() method.
This script below is just a simple variant of a more complex thing i do, I understand that in the script below i can easily get the same result in vector by avoiding the pgraphic but that's not an option.
            
            
            
            
 
           
 
            
           I need them both out of vectors. I understand that it's pixels because i use the image() method.
This script below is just a simple variant of a more complex thing i do, I understand that in the script below i can easily get the same result in vector by avoiding the pgraphic but that's not an option.
- import processing.pdf.*;
 PGraphics pg = createGraphics(400, 400, P2D);
 boolean saveOneFrame = false;
 void setup() {
 size(600, 600);
 }
 void draw() {
 if(saveOneFrame == true) {
 beginRecord(PDF, "Line.pdf");
 }
 background(255);
 stroke(0, 20);
 strokeWeight(20.0);
 line(mouseX, 0, width-mouseY, height);
 pg.beginDraw();
 pg.background(255, 0);
 pg.line(mouseX, 0, width-mouseY, height);
 pg.endDraw();
 image(pg, 50, 50);
 if(saveOneFrame == true) {
 endRecord();
 saveOneFrame = false;
 }
 }
 void mousePressed() {
 saveOneFrame = true;
 }
 
              
              2  
            
 
            
 
 
          