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.
IndexSuggestions & BugsSoftware,  Documentation,  Website Suggestions › pauseRecord() and resumeRecord()
Page Index Toggle Pages: 1
pauseRecord() and resumeRecord() (Read 472 times)
pauseRecord() and resumeRecord()
May 9th, 2006, 11:24pm
 
I've implemented these 2 methods and have found them invaluable.

They enable (obviously!) one to stop the recording of say a PDF and then resume that same recording without a recorder.endFrame occuring. This means that you can build an interactive drawing over a number of frames, but contained within a single PDF frame.

It functions the same as aiexport's takeSnapShot and dumpSnapShot methods for dealing with accumulative images.

Is this likely to be causing problems elsewhere?

Here's an example of its implementation:

Code:


import processing.pdf.*;

void setup() {
size (400, 400);
}

int fileno=1;

void draw() {

pauseRecord(); // if we are recording stop!
// Things not to appear in the pdf
background(255);
stroke((int)random(0,255));
rect(width/2,height/2,mouseY,mouseX);

resumeRecord();
// This will all appear in the pdf
stroke((int)random(0,255));
ellipse (width/2, height/2, mouseX, mouseY);
}

void mousePressed() {

beginRecord(PDF, "foo" + fileno++ + ".pdf");
background(255); // set the intial state of the pdf
}

void mouseReleased() {

endRecord(); // finish up this pdf
}



The following code basically overrides and extends functionality.

Code:


// Overriden methods from processing.core.PApplet

PGraphics container; // temporary storage for recorder

public PGraphics beginRecord(String renderer, String filename) {
filename = insertFrame(filename);
PGraphics rec = createGraphics(width, height, renderer, filename);
beginRecord(rec);
return rec;
}


public void beginRecord(PGraphics recorder) {
this.recorder = recorder;
recorder.beginFrame();
}


public void endRecord() {
if (recorder != null) {
recorder.endFrame();
recorder.dispose();
recorder = null;
container = null;
}
}

public void pauseRecord() {
if (recorder != null) {
container = recorder;
recorder = null;
}
}


public void resumeRecord() {
if (container != null) {
beginRecord(container);
}
}



Page Index Toggle Pages: 1