We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Currently this is the scripts i'm using. I'm wondering if there is a way to capture a particular frame or clip in the animation? I am pasting the code here for reference. Thank you so much!
import processing.pdf.*;
PImage img;
int w=759, h=756, sx=w, x, y;
boolean record;
void setup() {
size (759,756 );
img = loadImage("Mullion_texture_2_rot.jpg");
}
void draw() {
if (record) {
//Note that #### will be replaced with the frame number. Fancy Oh you fancy, oh you fancy!
beginRecord(PDF, "img-01-####.pdf");
}
if (sx-->0)for (x=0;x++<w;) for (y=0;(y+=sx)<h;) {
stroke(img.get(x,y));
line(x,y,x+1,y+sx);
strokeWeight(1);
if (sx-->0)for (x=0;x++<w;) for (y=0;(y+=sx)<h;) {
stroke(img.get(x,y));
line(x,y,x+1,y+sx);
strokeWeight(1);
}
}
if (record) {
endRecord();
record = false;
}
}
void mousePressed() {
record = true;
}
Answers
To newcomers in this forum: read attentively these instructions
You chose no category and you don't know how to format. I fixed these.
"to capture a particular frame or clip in the animation?"
Not too sure what is "particular". Is is by frame number?
One problem with PDF capture is that it can only capture what is being drawn, it cannot capture what has been already drawn. Ie. it records the drawing function calls (stroke, line, etc.) as they happen. If you start to record in the middle of the sketch run, you only capture from the point of the start of the capture.
Now, you are lucky, your sketch is deterministic, not relying on random numbers. What you can do is to store the frameCount value when you click. Then you start the record, and replay all the animation at once (do a loop over the frameCount, simulating the successive draw() calls).
Side note: in general, you must call strokeWeight() before drawing a line. Here, it doesn't change anyway, so you can call it only once, in setup().
http://forum.processing.org/one/topic/pdf-export-shapes-misaligned
http://forum.processing.org/two/discussion/4275/how-to-compile-a-series-of-functions-into-one-variable
You can try this (untested, it is to give you a general idea of what I am talking about):