Animating with layers


Using layers to create an animation can save a lot of time and effort. Instead of editing each frame pixel by pixel you set up key frames defining the positions of all the layers. Once you are happy with the setup you can create all of the frames at the touch of a button. Naturally you will need to be very comfortable using layers, so if you aren't I would suggest you play with the examples in the mtPaint source package with the help of the documentation:
mtpaint src/animation/*/*.txt
mtpaint src/graphics/*.txt


Preparation of ideas

Once you have come up with an idea for an animation you need to prepare your plans before using mtPaint. For example you need to decide on issues like final image size, frames per second, number of colours used and total animation duration.


Project Initializing

Before starting work on the animation it is advisable to create a new directory to put all of the image files in as this makes file management much easier. You then create a background image which will set the size of the final animation. Finally you create each of the image layers that you want in the animation. Naturally you will need a good understanding of using layers in mtPaint. The documentation should help with this if you are new to the procedures involved.

Once the image layers are in place you can then configuration the animation with the menu option "Frames->Configure Animation". Here you determine the first and last frame numbers, the name of the directory to hold the frames, etc.


Setting up positions & cycle data

After you have positioned each of the layers for the first frame, you select the menu option "Frames->Set key frame". You can then do this for further key frames in the animation. In the positions tab of the configuration window, you could have the following 2 lines:

1 10 10 100 0

10 20 20 50 0

This layer will begin at position (10,10) in frame 1 and move to (20,20) at frame 10 with opacity changing from 100% to 50%. Each of the frames 2-9 are calculated by mtPaint as in between frames. The 0 at the end means this will be a straight line. A value of 1 would mean mtPaint moves this layer on a slightly smoother curve between the given points.

Lastly you set the cycle data if you want frames visibilty to be cycled or changed at any point. You can then preview this animation by pressing the preview button (or via the menu) and dragging the slider to view the animation. You can also use the arrow keys, page up/down keys, or + or - keys to change frames.


Exporting frames for GIF or MPEG encoding

When you are happy with the animation you have created you can export the frames with the "Create Frames" button. If you have selected the GIF toggle mtPaint will generate indexed palette GIF files, but if not it will generate RGB PNG files. You can then use encoding software such as gifsicle or mencoder to turn these frames into an animation file. If encoding to GIF files, mtPaint will attempt to call gifsicle automatically and create the animated GIF for you. On GNU/Linux systems gifview will also be used to display the result.

Here is an example of how to get mencoder to create an MPEG file with RGB PNG files:

mencoder mf://*.png -mf fps=10 -ovc lavc -lavcopts vcodec=mpeg4 -o output.avi

For more information on how to use mencoder, check out the mplayer home page HERE

For more information on how to use gifsicle, check out the home page HERE


Extra notes

If you are composing a particularly long animation that needs more than 100 lines in the position or cycle table you can simply copy the layers file and have different files for each section of the animation. For example "layers00001-00500.txt" could be for the first 500 frames and "layers00500-01000.txt" could be for the second 500 frames. You then create the frames as normal in each case and knit them together with your favourite encoder software.


Examples

I have put together some examples to demonstrate these facilities - They are in the sources distribution in the directory ./src/animation. Explore them from the command line with "mtpaint src/animation/*/*.txt". They should end up as follows:



SourceForge.net Logo