Starting and stopping PDF recording in an animation

Can you please help me. I am trying to control where I begin and end recording of a multiple frame (into one file) PDF in order to capture a segment of the animation. Currently the recording starts automatically once the animation starts playing - I want to be able to control this "in point", presumably with pressing a key e.g. "s". I can stop the animation, all ok, and it writes the pdf; I just need to able to control when I start it. Any help appreciated!

import processing.pdf.*;


ArrayList<Snake>snake;
float x,y;
float t;
float count = 0;
int delay = 0;

void setup(){
  beginRecord(PDF, "everything.pdf");


 size(500,500);
 smooth();
 snake = new ArrayList<Snake>();
 noStroke();
}


void draw(){
  background(6,7,175);
  translate(width/2, height/2);
  delay++;
  if(delay>=5){
    count++;
    delay = 0;
    if(count<=80){
      snake.add(new Snake(count));
    }
  }
  for(Snake s : snake){
    s.update();
    s.display();
  }
}

void keyPressed() {
  if (key == 'q') {
    endRecord();
    exit();
  }
}

Answers

Sign In or Register to comment.