Sim
Sim

Reputation: 231

Save output in processing every X seconds

Hi I'm using processing and want to know if there is a way I can automatically save my output every X amount of seconds?

Any help would be great!

Upvotes: 0

Views: 591

Answers (1)

exoddus
exoddus

Reputation: 2340

You are looking for saveFrame() method. Inside your draw() method, you can save a screenshot of your visual output.

void draw() {
  // YOUR CODE
   ...
  // Saves each frame as screenshot-000001.png, screenshot-000002.png, etc.
  saveFrame("screenshot-######.png");
}

More info: https://processing.org/reference/saveFrame_.html

And for take screenshot every X seconds:

int lastTime = 0;

void draw(){
  // YOUR CODE
  ...
  // 1000 in milisecs, that's 1 sec
  if( millis() - lastTime >= 1000){
    saveFrame("screenshot-######.png");
    lastTime = millis();
  }
}

Upvotes: 1

Related Questions