Relative File Naming for PDFs

edited February 2014 in How To...

I have been looking all over, but can't seem to find out how to do it.

I know you the saveFrame() function works with "filname-###.jpg"

Code:

import processing.pdf.*;

int total = 40;

PShape mask;

void setup() {

  size(500, 500, PDF, "NIR-###.pdf");
  background(255);
  strokeWeight(200);
  smooth();


  mask = loadShape("white-mask.svg");
}

void draw() {

  for (int i = 0; i < total; i++) {
    float q = random(500);
    float r = random(10,500);
    float g = random(10,255);

    stroke(random(250,255),random(0,255),90,255);
    line(q, 0, r, height);
    }

  shape(mask,0,0,500,500);  

  if (frameCount == 100);
  println("D O N E");
  exit();

}

void mousePressed() {
  background(255);
  redraw();
}

void keyPressed() {
  if(key == 's')
  { 
    saveFrame("NIR-###.jpg");
  }
  if(key == 'a')  {
    setup();
    redraw();
  }  
}
Tagged:

Answers

  • How'bout

    import processing.pdf.*;
    //String outputDirectory = "outputDir";
    //or
    String outputDirectory = "../outputDir";
    String outputFilename = outputDirectory + "/output.pdf";
    size(300, 300, PDF, outputFilename);
    rect(10, 10, 100, 150);
    exit();
    
Sign In or Register to comment.