Loading...
Logo
Processing Forum
Hi. 
This is my first attempt at Processing, sorry for the silly questions.
I need to save frames at 300 dpi minimum for professional printing. 
I tried to use a frame 4 times the size of my monitor, but I really need to see what's happening when I record so it does not work for me.
Instead I tried to use the PDF library but I only save 'blank' frame, I don't understand why.
Is there a better way of saving at high resolution, if not, can you tell me what's wrong with my code?
Thank you for your help!

import processing.pdf.*;

boolean record;

 
int num = 60;
int colorL=255,k = 0,j=100,i=200;
 
float x,y,z;
float r,th=0,step=.1,epi=200;
float m = 1,n1=-1,n2=0,n3=0;
float b=1,a=1;
int counter1=0, counter2=0;
 
 
void setup() 
{
  size(1800,1100);
  background(0);
  frameRate(50);
  smooth();
}
 
void draw() {
 if (record) {
    // #### will be replaced with the frame number. 
    beginRecord(PDF, "frame-####.pdf");
    }
{
   
  fill(0,5);
  rect(-5, -5, 1805, 1105);
  counter1++;
  if (counter1 == 75) {
    m=int(random(3,60));
    n1=random(2);
    n2=random(2);
    n3=random(.1);
    epi=random(50,200);
    step=random(.01,10);
    counter1 = 0;
  }
  translate(mouseX, mouseY-100);
  stroke(colorL,35);
  noFill();
  beginShape();
  for(int i=1; i < num; i++) {
    r = epi*pow(((pow(abs(cos(m*th/5)/a),n2))+(pow(abs(sin(m*th/5)/b),n3))),(-1/n1)) * random(10000)/random(1000); 
    th = th + step;
    x = r*cos(th);
    y = r*sin(th);
    curveVertex(x,y);
  }
  endShape();
  
  if (record) {
  endRecord();
  record = false;
  }
 
}
}
 // Use a keypress so thousands of files aren't created
void mousePressed() {
  record = true;


Replies(4)

You draw white lines on the default PDF background which is white...
A solution is to do:
 if (record) {
    // #### will be replaced with the frame number.
    beginRecord(PDF, "H:/Temp/frame-####.pdf");
    background(0);
    }
but it probably won't record what you expect.
A PDF recorder must record drawing orders from the start, if you want a kind of "screenshot" effect.
Hey, thanks for the super fast response!

" A PDF recorder must record drawing orders from the start, if you want a kind of "screenshot" effect."
So I should put a recorder in my void set up? (sorry to waste your time, I'm really new to this).

Also, I tried the code you proposed before, but I have this error message when I call the background(0):  


Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
at processing.core.PApplet.runSketch(PApplet.java:9660)
at processing.core.PApplet.main(PApplet.java:9469)
Caused by: java.lang.NullPointerException
at processing.core.PApplet.fill(PApplet.java:13500)
at test_pdf.<init>(test_pdf.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at processing.core.PApplet.runSketch(PApplet.java:9658)
... 1 more

Don't use my path in the beginRecord() line, I added it because I don't save most sketches I try from the forum.
You probably don't have a H drive... I forgot to remove the path.
Just add the background call.
Hey PhiLho,
Thanks a lot for your help!
Everything's working fine now.