'

| Advanced Animation With Gimp Or How To Use AnimFrames Gimp has many excellent tools for making animations. The far most advanced of these tools is AnimFrames. We will unleash the power of it in this chapter.

## Basic Concepts

You will find the AnimFrames tool under `right-click|``AnimFrames`. As the name indicates, AnimFrames works with image frames. A frame is an ordinary Gimp image saved with a special extension.

When you make an ordinary GIF animation you create a multi-layered image, where the object that you want to animate moves a little bit for every new layer. If you want to use more than one animation object, you have to put all of the objects in the same layer. This makes it hard to create advanced animations.

If you want to work with several objects that can move independently of each other, the ordinary Gimp animation filters do not suffice. To find out more about the Gimp animation filters, read "Animation Filters" starting on page 369.

AnimFrames overcomes this problem in a wonderful way. Instead of using a single multi-layered image, AnimFrames works with several images, where each image can have several layers with different objects in them. This makes every object independent of the other animation objects, just like in a cartoon frame where several people move around independently, because each character has been painted on a separate plastic sheet.

## How To Create An Animation With AnimFrames

### Making A Frame

1. The first thing you have to determine when you create an animation is the size of the background image. When you've made up your mind, select `right-click|File|``New`, and specify the desired size in the dialog box.

2. AnimFrames is built up of frames, and to turn your image into a frame, you must first save it. Choose `right-click|File|``Save` `as` and save the new image as `animationname_0001.xcf` (the special extension for AnimFrames is `_0001.xcf`).

3. Now, it's time to create the frames. Choose `right-click|AnimFrames|``Duplicate` `Frame`. This brings up a dialog asking you to specify how many duplicates you want, or in other words, how many frames you want for your animation (the slide only goes as far as to 50 frames, but you can easily change that by typing a number of frames in the field.)

#### Format And Save Functions

The format must be XCF (Gimp's native file format), but if you are low on disk space, you can choose a compressed XCF by adding `.gz` or `.bz` to the end of the frame name. To make this work, you must of course have either gzip or bzip2 installed on your system.

Don't worry about saving; all frames are stored on disk immediately without explicit save. The same happens when you work with other tools in AnimFrames, so you only have to save when you exit AnimFrames.

### How To Navigate Frames

We assume that you have now created a few basic frames, for example, 10 frames. We are in frame number 1 (`name_0001.xcf`).

This is certainly something that we want to avoid, so we suggest you use the special AnimFrames menu commands for navigating the frames instead. You can navigate in the following ways:

· `Goto First` will bring you to frame My_anim_0001.xcf

· `Goto Next` -> My_anim_0002.xcf

· `Goto Prev` -> My_anim_0001.xcf

· `Goto Last` -> My_anim_0010.xcf

· `Goto Any` will bring up a dialog asking you which frame to go to

The author of the plug-in suggests that you assign hotkeys to the `Goto` commands, because you will move around a lot in your frames.

Read more about hotkeys in "Default Shortcuts And Dynamic Key Bindings" starting on page 9. You can choose any key bindings you like, but here are a few suggestions:

Goto First Ctrl+Alt+1

Goto Prev Alt+1

Goto Next Alt+2

Goto Any Alt+3

Goto Last Ctrl+Alt+2

## Your First Animation

### How To Make A Move Path

The main tool in AnimFrames is the Move Path tool. This tool allows you to move your animation object along a specified path. You need at least two things to make an animation:

· A set of frames, i.e., your 10 `My_anim` images

· An object to animate

1. To make an animation object, start by creating a new transparent image (`right-click|File|``New`) and paint a simple object in the center of the image -- a big, red do, for example.

2. Open the first frame (`My_anim_0001.xcf`) and select the Move Path option in the AnimFrames menu, and the Move Path window will appear. This window is where you control the animation sequence. This simple example will help you get a basic understanding of how Move Path works. Later in this chapter, we'll return for a more in-depth description of the Move Path window.

3. In the Source Select field, set SourceImage/Layer to your animation object. Set Handle to Center, Stepmode to Loop and Mode to Normal.

4. Mouse-click somewhere in the preview window, press the Add Point button and click somewhere else in the preview window.

5. Now, set the Start Frame slider to your first frame and the End Frame slider to your last frame. Leave the Layerstack and Preview Frame as they are and press OK.

You have now created your first animation. The red dot will move from the first click-point to the second, and it will use ten frames to complete the movement. In order to view the animation, you must select `AnimFrames|``Frames``` `Flatten` and include all of your frames in the Select Frame Range input field in the Frames Flatten dialog.

The second step is to make your frames turn into a multi-layered image. Do this by selecting `AnimFrames|``Frames` `to` `Image` and choosing all your frames. Now, you can watch the animation with the Animation Playback filter in the `Filters/Animation` menu.

If you want to save it as a GIF animation, you will have to index your image first. We suggest that you stick to RGB during the whole animation process, and don't convert to Indexed until you're done. Presently, you can only save your animations as GIF, but it's probably only a matter of time before other animation formats will be supported by Gimp.

Note that the animation object must be of the same type as the frame. You can't mix indexed images with RGB images, but an RGB and an RGB alpha will work just fine. The frame and the object layer don't need to be of the same size.

## Move Beyond The Basics With The Move Path Tool

### How Far Can AnimFrames Take Me?

There are nearly no limits to what you can achieve with AnimFrame, but certain kinds of animations are harder to create than others. To create some effects, you may have to edit frames by hand.

We've made an animation demo (see Animation Gallery/Tutorial), where we show a few examples of what AnimFrames is capable of; like panning the background, making an aftertext that rolls over the frame, a perspective intro text, moving objects away from you and towards you, setting different speeds to objects, etc.

### The Animation Studio

The Move Path window is the heart of AnimFrame, so let's have a closer look at what it can do and what the parameter settings signify.

The dialog is divided into three different parts: Source Select, Move Path Preview and a bottom part where you set some slides and buttons.

### Source Select

#### SourceImage/Layer

This menu is where you select the animation object, i.e., the layer or image where your animation object is. You can only open AnimFrames/Move Path from a frame image, so you must keep a frame image (just one!) open, as well as one or more object images.

#### Mode

Here, you define how to combine the color/brightness values of the imported layer/image and the rest of the layers in the frame. You can read more about modes in "Modes" starting on page 335.

#### Handle

The Handle determines which part of the imported image/layer should be used as a point of departure for the move path. Handle is used for locking a certain corner of the source layer/image to the move path. If you select top-left handle, the control point will stick to the top-left corner of the source layer, forcing the layer's position to the bottom-right side of the control point.

#### Stepmode

Stepmode determines the sequence of the animation. Loop creates a continuous animation from the first control point to the last. Loop reverse does the same but goes the other way around -- from the end point to the first control point. (Once and Once reverse are currently the same as Loop, but that will change with the development of this plug-in). Ping Pong makes your animation go from the first point to the last point, back to the position after the first point, to the position before the last point and so on. None cancels the animation. We recommend that you stick to Loop and Loop reverse, and control the output by animating different sequences separately, or by exchanging frames.

### The Preview Window

Here's where the actual setting of the animation takes place. By placing a number of control points along a track, you create a linear moving path for the object. Note that the path and the points are invisible. You can only see them by stepping your way forward or backward with the Next Point/Prev Point buttons.

Tip: If you find it hard to visualize a path created with the mouse in the preview window, make a freehand drawing of the track to guide you when you place the control points. When you have finished the path, you can erase the pencil lines.

#### Move Path Preview And Control Points

The animation object will move from the first to the last control point over the frames you set using the slides Start Frame and End Frame.

By default, the first control point is placed in the top-left corner. If you want to start from here, continue the path by pressing the Add Point button to add a second point to the path. Then, c lick in the preview window to set the position of the second control point.

If you don't want the path to begin from the top-left corner, change the position of the first control point by clicking in the preview window to set the new position. To continue the move path, press Add Point, click on a new position to set the second control point, and so on.

If you want to adjust the position of a control point, press Prev Point or Next Point to navigate the path. The status of the point controls will now change from X[2] to X[1], for example, so you know what control point you are dealing with. Adjust the position of the chosen control point by clicking at the spot in the preview window where you want it, and the move path will automatically conform to the new position.

Note: You can't add a control point to adjust the path between two existing points. You can only add to prolong the path, so always make sure that you stand at the last control point when you add a new point; otherwise, it will be quite hard to follow the path you're creating.

If you want to prolong the path by adding another control point, press the Next Point button until you arrive at the last control point, then press Add Point and click at the place where you want to put it.

Because the animation object's move path is determined by the control points, you will have to use a lot of control points to create a circular path. The maximum number of control points are 256, but that is quite sufficient for most GIF animations.

#### Options

A very nice option is the possibility to save and import control points. This makes it possible to let different objects use the same move path (you can also save your favorite move path for later use).

You can create a very exact moving path by inserting a value in the control point position fields X and Y. The values here give you the necessary numerical information about every point's position.

Note: The position cross is not restricted to the area inside the preview. Dragging it outside of the preview window will, for example, enable you to pane the background.

The Width and Height controls allow you to resize the layer/image at a certain control point. This is, of course, ideal for zooming.

Opacity controls transparency of the object image. You can, for example, use this control to fade in and out of images. As you see, these controls allow you to create many of the common effects you've seen in ordinary movies.

A really nice feature is the Rotate deg option, which enables you to rotate the animation layer. With this option it's very easy to spin an object around.

#### A Short Example

1. Create 50 frames.

2. Create a simple cross in a new image (let the image be 25x25 pixels).

3. Open Move Path and make 12 control points.

4. Set control point 1 to 0°, point 2 to 90°, point 3 to 180° and so on.

5. Set Source Image/Layer to the cross image you made.

6. Set Handle to center.

7. Set every control point to be in the center of the preview area.

8. Press OK.

Now you have 50 film frames of a spinning cross. OK, it's a fairly simple example, but the function is very versatile. You can easily create a spinning plane, a car moving in a circle, etc. It's just up to your imagination.

### Control Slides

#### The Frame Slidebars

These slidebars control where and how the import layer should be placed in your frame. The Start Frame and End Frame sliders determine which frames the image/layer (with the current move path) should be imported to. The Preview Frame slider controls which frame you'll see when you press the update preview button. Note that this only works for the first and last control points. This tool is for viewing the beginning and end of an animation sequence

#### The Layerstack

The Layerstack slidebar controls in which position the imported layer/image will be placed in relation to the other layers in the frame. In order to understand this you must think of the layers as a stack of cards. If the layerstack is set to zero, then the layer will end up on top of all other layers (cards). If the layerstack is set to 1, then the layer card will be inserted between the first and second layer cards, etc.

## The AnimFrame Menu

### Undo And Preview

Other than the preview in the Move Path tool, there is no preview that lets you see your animation while it's under production (it would be too slow to load and unload images from disk, especially if there are a lot of layers). If you want a preview, you can either step forward with the GotoNext command (use the assigned shortcut command), or create a multi-layered image with Flatten Frames followed by Frames to Image, and view it with `right-click|Filters|Animation|``Animation Playback`.

There is no Undo in AnimFrames, because all frames are saved immediately. A way around this is to always keep your layers in the frames. If you aren't satisfied with a certain frame layer sequence, then you can easily delete it with the Frames Layer Delete command.

### Frames LayerDel And Delete Frames

The Frames LayerDel command will bring up a dialog asking you to specify what Frame Range should be affected, and the position of the unwanted layer sequence in the Layerstack. Be careful here, because when you press OK, there's no return.

The Delete Frames command will delete the frame that you opened the Delete Frames dialog from. It can also delete the following frames in the range you specify.

### Frames Convert

If you want to export your frames to different image formats, you can use the Frames Convert command.

The drop-down menu lets you select whether you want to keep the image type (RGB) or convert it to a different format (Gray, Indexed or RGB). This is essential if you want to save your frames in GIF format, because GIF images by definition are indexed. The field above the menu is for specifying image format by typing the suffix (such as .gif, .tiff or .jpeg) To verify what frames to convert, use the From Frame and To Frame slidebars.

If you want to, you can also set a new base name for the frames in the Basename field. Just remember that the basename is the whole path plus the name of the image without the number extension. For example, don't use `/home/me/gap/test_0001.gif`, use `/home/me/gap/test` which is the correct basename, because the _0001.gif extension is added automatically.

The Flatten checkbox flattens the frames before you save them. If you save them as GIF's, flattening is not necessary, because GIF can handle layers. However, if you want to save them as TIF images (or any other image format that does not handle layers), you have to flatten the images first, because TIF doesn't support layers.

When you save the frames as an indexed image, you can specify the desired number of colors with the Color slide. You can also let the indexed image be dithered by checking the Dither checkbox.

### Exchange Frame

Exchange Frame is used for rearranging your frames. In the dialog, set what frame you want to swap the current frame with. For example, if you invoke the command from frame 3 and set the slide to 5, then frame 3 will end up as frame 5, and frame 5 will end up as frame 3.

### Frames Flatten And Frames To Image

Invoke the Frames Flatten command when you want to preview your animation, and the Frames to Image command when your animation is finished and you want to save it as a GIF animation.

Frames Flatten will flatten the layers in each frame. The result of applying this command is a sequence of merged (AnimFrames) frames, which can be viewed step-by-step with `AnimFrames|``Goto Next`. All frames must be flattened before you can preview your animation using this command.

To create a GIF animation, you can't use the frames as they are, flattened or not; you'll need an image composed of several layers to do that.To convert your set of flattened frames to a multi-layered image, you must use the Frames to Image command.

When you use Frames Flatten, we recommend that you do this on a copy, and not the original frames (`cd "your frame directory" && mkdir framecopy && cp * framecopy` in a terminal window). If you flatten the original frames, you'd better make sure that everything's OK, because once the frames are flattened there is no way to edit the frame layers.

Frames to Image is a bit more friendly; it creates a new image and won't destroy the original.

#### Frames To Image Options

In the Layer Mergemode parameter area, you'll find the most important parameter settings in the Frames to Image dialog box.

· Clipped to image is generally the most efficient option. Clipped to image will create a multi-layered image from multi-layered frames. Each frame will be flattened on the fly and merged into a single layer in the resulting multi-layered image. The resulting image will be of the same size as the frame.

· Flattened image is nearly the same as Clipped to image. The main difference is that if your animation has transparent parts, they will be filled with the background color in the toolbox.

· Expand as necessary will enlarge the resulting image if any of the frame layers are outside of the frame canvas.

· Clipped to bottom layer, used with an unchecked Exclude BG-Layer checkbox, can be quite useful. In order to set the size of the animation, you often start working with an empty bottom layer. As you create the animation, you add a lot of layers. When you are finished, you'll want to keep the size of the bottom layer, but not the actual bottom layer. If this is the case, Clipped to bottom layer is the perfect tool.

In the Select Layer(s) parameter area you can select which frame layers should be included in the image conversion.

· With the check buttons, pick the layers by Pattern or by Layerstack position. There are tooltips for each selection type, so just point, and you will get an explanation.

· When you have decided how to search for/select the layers, insert the search pattern name or layerstack position numbers in the Select Pattern input field.

### Frame Duplicate

As we've mentioned before in Making A Frame, this tool is used for creating base frames in an animation. Note that if you are in the middle of an animation and want to duplicate a frame, the duplicate frames will be inserted after the original frame.

### Frames Crop, Resize And Scale

All of these tools work exactly as they would on an ordinary image, but they take effect on all of your frames. So, think carefully before you press OK, because these actions have no undo!

Resize and Scale will bring up the old familiar dialogs, just as they would have if you had invoked them on an ordinary image.

Crop is a bit different because you'll only get a parameters settings dialog. In order to use Crop effectively, use a few guides to set up your cropmarks in the frame. When you have set those marks, you'll know what parameters to set in the Crop dialog:

· Offset X is the distance from the left side to the first vertical cropmark and Y offset is the distance from the top of the image to the first horizontal cropmark.

· New height is the distance from the top cropmark to the bottom cropmark, and New width is the distance from the left to the right cropmark.

### Split Img To Frames

This is a very versatile tool. You can use it to convert MPEG and GIF animations to frames and thereby edit animations more easily. There aren't many options here, the main thing is to set the extension (image type), but the default extension (which is XCF) is often the best choice.

#### Parameter Settings

· Inverse order means that the top layer will be frame 1 and the background layer will be the last frame. You will have to check how your animation is stored to determine what type of order you need.

· Flatten doesn't really flatten. If any of the layers that will become a frame contain transparent areas, those areas will be filled with the background color from the toolbox.

### Frames Modify

If you want to modify several frames at once, this is the command to use.

#### Parameter Settings

1. First, use the sliders to specify the range; that is, which frames should be affected by the operation.

2. Then, with the Select Layer(s) check buttons, pick the layers by Pattern or by Layerstack position. There are tooltips for each selection type, so just point, and you will get an explanation.

3. When you have decided how to search for/select the layers, insert the search pattern name or layerstack position numbers in the Select Pattern field.

4. Check the Case sensitive checkbox if you want to differentiate layer names with or without capital letters.

5. If you want to perform the operation on frames that you haven't selected, check Invert Selection.

6. When you have set all of these parameters, it's time to choose what to do in the Function drop-down menu. If you choose the rename Layer(s) option, you also have to specify the new name in the New Layername field. If you choose the apply filter on Layer(s) option, then the `right-click|Filters|Animation|``Filter` `All` `Layers` dialog will appear (see Filter All Layers).

### Framesequence Shift

This filter will shift your frames just like you shift cards in a deck of cards.

Suppose that you have 9 frames and you want to shift the frame sequence starting from frame 2 and ending in frame 7. You want to move this sequence 2 steps (N = 2 in the dialog).

Then, frame 2 will be the new frame 4, frame 3 will become frame 5, etc. until you reach frame 8 which will be frame 2 and frame 9 which will now be frame 3.

## Filter Layers

### Using A Script Or Filter

There is a Script-Fu that can be very useful when dealing with animations. It's the `right-click|Script-Fu|Animators|``Sel` `To` `AnimImage` script, which lets you apply any filter (plug-in) on all layers in an image.

You may think this is equal to `right-click|Animation|``Filter` `All Layers` (see Filter All Layers), but that isn't completely true. If you want to apply a filter smoothly in each layer, the Selection to AnimImage script is the better choice.

#### Example

You have ten layers and you want to apply `right-click|Filters|Distort|``Whirl` with slightly different values to each layer. If you use Filter all Layers, you have to do this by hand, but if you use Sel To AnimImage, you only have to set the start and end values. The script will calculate the values between the start and end layers, and create a smooth transition.

These operations can only be performed on an image, not on frames, so you must first convert your frames with the Frames to Image command. When you are finished, you can easily transform it back to frames with the Split Image to Frames command.

## Animation Gallery/Tutorial

We have made a little animation to show you some of the things you can do with AnimFrame. The animation is 186 frames long.

#### Zooming

The animation begins with a logo that moves toward you before it bounces back, stretches out and finally fades away. Those effects were quite easy to achieve:

We started by specifying a low value for Width and Height in the first point in the logo's Move Path, so that the logo would appear to move toward the camera.

The fade away/stretch effect was created by setting the opacity in the final point to 0%, the X scale to 200 and the Y scale to 0.

#### Fading

The next phase in the animation was to fade over from the background in the bouncing logo scene to the space background in the next scene. This was done by placing the space background in the lowest layer in a series of 10 frames, then we made a Move Path with the blue logo background with 100% opacity in the first control point and 0% opacity in the final control point.

#### StarWars Text

Then, we amused ourselves by creating a paraphrase of the rolling perspective text in a movie we assume you've never heard of. (Don't bother reading the text; it's quite meaningless).

For the perspective effect we used an image that was higher than the frame, and then we skewed the text with the Transform/Perspective tool. The Move Path (center handle) begins a bit below the actual frame, and the second and final points, were placed a bit below the center of the image.

The final point also scaled down the import image to about a third of its original size. This made the text float away, just like in the movie. Afterward, we adjusted the time each frame was shown to keep the text from accelerating as it moves away.

Paning And Accelerating

The space scene displays an orbiting spacecraft or satellite. The spacecraft accelerates as it moves away from you and around the Earth. As background setting we used a large image of the Earth seen from space.

The space part of the background was paned with the Move tool, and the last stage in the scene was a pane and zoom down toward the Earth.

Then we added the spacecraft image with a move path from the right side of the "screen" to the left. At the same time as the spacecraft was moving along the path, it was scaled down. This created the acceleration effect, and the feeling that the beholder is moving away from the spacecraft as it disappears beyond the horizon.

#### Fading Again

Now, it's time for some propaganda in the Help Us Fight the Evil Empire fade-out scene. This text was faded in the same fashion as the bouncing logo background, only in reverse direction.

#### Moving Around

The final scene displays the production team behind this animation, and this book. The Frozenriver logo was made to circulate around the word "Production" and fade away at the same time. This was done by using "Production" as a background. The logo was then made to move around the text in a five-point move path, where the opacity was lowered for each control point .

| Note: This animation demo comes both in GIF and AnimFrame format, and can be downloaded from `ftp://manual.gimp.org/pub/manual`.

Frozenriver Digital Design http://www.frozenriver.nu Voice: +46 (0)31 474356 Fax: +46 (0)31 493833 support@frozenriver.com | Publisher Coriolis http://www.coriolis.com