User Tools

Site Tools


part_12-_video

Processing Tutorial

Part 12: Video

-12.1: Frame-Based Animation

We can do frame-based animation, but we have to use the Book's classes.

If we are to use the book's classes, we have to have them as tabs in the current sketchbook or put them in the “code” folder. See the Bugs and Workarounds section of Reports for more. This can get messy, but it works. It's safe to include them all except SoundTest.java.

An example:

import java.awt.*;

//public class MovieMaker_java {  //As an application
public class MovieMaker_java extends PApplet{ //As a sketch

  //public void makeRectangleMovie  //As an application
  void makeRectangleMovie(String directory) //As a sketch
  { 
    int framesPerSecond = 30;
    Picture p;
    Graphics g = null;
    FrameSequencer frameSequencer = new FrameSequencer(directory);
  
    for(int i=0; i<framesPerSecond; i++)
    {
      p = new Picture(640,480);
      g = p.getGraphics();
      g.setColor(Color.RED);
      g.fillRect(i*10,i*5,50,50);
      frameSequencer.addFrame(p);
    }
    
    frameSequencer.show();
    frameSequencer.play(framesPerSecond);
  }
  
  //public static void main(String[] args)  //As an application
  void setup() //As a sketch
  {
    MovieMaker_java movieMaker = new MovieMaker_java();
    String dir = "C:\\";
    movieMaker.makeRectangleMovie(dir);
  }
}


Next: Part 13- Abbreviated Reference Guide

Last: Part 11- Sound

part_12-_video.txt · Last modified: 2007/08/30 13:53 (external edit)