Monday, August 19, 2013

Processing example: Capture images of sketch with saveFrame()

saveFrame() saves a numbered sequence of images, one image each time the function is run. The following example save frames of the sketch when mouse pressed. The images will be saved in the sketch folder with name "draw-######.png".

void setup() {  // setup() runs once
  size(400, 300);
  background(0);
  stroke(255);
}

void draw() {
  if(mousePressed){
    point(mouseX, mouseY);
    
    //Saves a numbered sequence of images
    saveFrame("draw-######.png");
  }
}

sketch captured with saveFrame()
sketch captured with saveFrame()
With the saved images, you can create video with Processing 2 build-in Movie Maker.

No comments:

Post a Comment