We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › pdf won't save properly!
Page Index Toggle Pages: 1
pdf won't save properly! (Read 647 times)
pdf won't save properly!
May 26th, 2009, 3:08am
 
so, i've made this code and programmed it to save a pdf once i pressed the 'b' key but when i go and check the pdf it had only saved like 10 frames or something!. Code:
import processing.pdf.*;

PShape a;
PShape b;
PShape c;

float xplus = 0.05;
float yplus = 0.05;


float xx = random(0, 0.05);
float yy = random(0, 10);

void setup(){
size(595,842);
beginRecord(PDF,"ilustração.pdf");

smooth();

frameRate(30);
}


float xpos = random(width);
 float ypos = random(height);
 
 


void draw(){

float x = noise(xx)*width;
float y = noise(yy)*height;
float siZe = random(40);
 xx += xplus;
yy += yplus;

a = loadShape("tattoo1.svg");
 b = loadShape("tattoo2.svg");
 a.disableStyle();
   b.disableStyle();
float blu2 = random(255);
 float blu3 = random(190,255);

if(x <180){

translate(x,y);
 rotate(random(1));
shape(a,-27,-160);
}

else if(y > 592){
 noStroke();
 fill(252,122,0);
ellipse(x,y,siZe*3,siZe*3);
}
else if(x>180){
 
  stroke(0.2);
  fill(0,blu2,blu3);
  rotate(random(1));
  shape(b,x,y);
}
else{

 fill(0,0,blu2);
 stroke(0);
   if(y< 200){
 noStroke();
 fill(252,122,0);
ellipse(x,y,siZe*3,siZe*3);
}
}
}
void keyPressed(){

if(key== 'b'){
 endRecord();
 noLoop();
}
}

Re: pdf won't save properly!
Reply #1 - May 26th, 2009, 4:35am
 
Not sure if that's the problem, but doing a loadShape in draw() will slow down a lot your sketch, even more if the shapes are complex.
Load them in setup() instead.
Re: pdf won't save properly!
Reply #2 - May 26th, 2009, 6:35am
 
it doesn't work! i really like the effect im getting and would like to use it to a poster.... :s
Re: pdf won't save properly!
Reply #3 - May 26th, 2009, 7:00am
 
Can you elaborate on the "it doesn't work" part?
Same result? Worse result? Something else?

BTW, I looked at the PDF reference, and I see "The sketch calls exit(), which is necessary to make sure that the file is properly written when complete." which is something you don't do...
Re: pdf won't save properly!
Reply #4 - May 26th, 2009, 7:33am
 
what it does is, instead of having tones of shapes like when i pressed to save, it only has like 16. i have de exit(); already! its still the same
Re: pdf won't save properly!
Reply #5 - May 26th, 2009, 9:40am
 
I tried with two other SVG files and indeed I had the same problem. Idem with size(x, y, PDF, file). I had better result with createGraphics and blind rendering.

I am not sure whether that's a bug or a performance issue.
Re: pdf won't save properly!
Reply #6 - May 26th, 2009, 11:56am
 
:s so it's not an error in my code? im going to try the way you said, although me being a pretty noob in this!
Page Index Toggle Pages: 1