Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Saved PDF is blank :(

$
0
0
That's right! Found out that too! Those lines are being drawn far off screen!
And keeps getting even farther as it goes!

Since the screen isn't cleared after all, it displays the initial drawings which were still inbound!
However, PDF mode doesn't care what was previously displayed. Recording is only for newer content!

Here's your program tweaked and fixed:
    // http://forum.processing.org/topic/saved-pdf-is-blank
    
    import processing.pdf.*;
    
    final static short SHAKE = 10, FPS = 20, BOLD = 4;
    final static color BG = -1, FG = #FF0000;
    
    final String NAME = "frame-####.pdf";
    String path;
    
    void setup () {
      size(300, 200);
      frameRate(FPS);
    
      path = dataPath(NAME);
    
      initialize();
    }
    
    void draw () {
      final boolean isRecording = keyPressed | mousePressed;
    
      if (isRecording) {
        beginRecord(PDF, path);
        initialize(); // initialize PDF's own graphics setup
      }
    
      background(BG);
    
      final int posX = frameCount % width + (int) random(SHAKE);
      line(posX, 0, posX, height);
    
      if (isRecording)    endRecord();
    }
    
    void initialize() {
      smooth();
      stroke(FG);
      strokeWeight(BOLD);
    }


Viewing all articles
Browse latest Browse all 1768

Trending Articles