Simple scrolling background with GIMP-GAP
This tutorial explains how to pixel-perfectly scroll an image that is larger than the view area. It is a technique that can later be generalized to parallax scrolling.
The result looks like this (heavily color reduced to reduce size):
one static image to be scrolled (640x240)
one 'blank' animation (320x240, 160 frames)
Note that the image doesn't have to be static, nor does the animation need to be blank, but we ignore these factors for now for simplicity's sake.
How do you create a blank animation?
This is a simple three-step process:
first, create an empty image of the correct size (320x240).
Next, save it with a filename like 'myanim_001.xcf'. The 001 indicates it is the first frame in an animation.
Use the menu item Video->Frames Duplicate to duplicate this frame. We want 160 total frames, and 1 frame already exists, so we set N to 159.
We now have a blank 160-frame animation
How should you make your image-to-be-scrolled?
It can be any kind of content that you could put in a normal GIMP layer. In this case we will use a completely opaque background so that the black we started with does not show through.
This is the background image I will be using:
It's very simple, created by throwing some patterns together in gimp and applying GMIC's 'Segmentation' filter to block-ify the color areas.
Compare it with the shape of the the blank image we are using:
It is exactly twice as wide.
** Calculating keyframe positions **
For this animation, we will scroll the image smoothly to the right.
Position keyframe coordinates in GIMP-GAP are relative to the animation which you are adding to. so, (0,0) would place the top-left corner of the background image at the top-left corner of the animation.
Note that coordinates are zero-based. 0,0 is the top left of the canvas, 319,239 is the bottom right. Keeping this in mind may save you some confusion on more complex animations.
Considering these factors, at the end of the animation, we want the position of the background to be (-320,0) (placing the leftmost 320 pixels of the layer off-canvas, and having the rightmost 320 pixels visible.)
This means the background travels exactly 320 pixels in 160 frames.. exactly 2 pixels per frame. We could choose other speeds, but we must choose both the movement speed and the number of frames carefully, to ensure that we can truly get pixel-perfect scrolling. When you divide the number of frames by the distance travelled, it must be a whole number to achieve pixel-perfect scrolling.
Before we actually scroll the background, there is one important condition that must be met:
Make sure that both the blank animation and the background image are open in GIMP.
Inserting and scrolling the background
We insert and scroll the background with a single, versatile command: "Move Path". Like all other GIMP-GAP commands, this can be found under the 'Video' menu.
This is a powerful and somewhat complex GUI, but for now we can ignore most of it.
First, we need to select the source image using the selector near the top left.
The Move Path dialog always starts with a single point, set to 0,0. This happens to be what we decided was our first keyframe, so we leave it as-is.
We need to add another point, using the 'add point' button, and set the 'x' input box to -320 (this is the most reliable way of choosing positions that are off-canvas.).
We now have the correct keyframes. Notice how Keyframe is grayed out. This is because the first point is always mapped to the first frame in the frame range, and the last point is always mapped to the last frame in the frame range.
Note the From Frame,To Frame pair on the right. This should be set to 1, 160 as shown.
We can now preview the output (this is optional, but usually helps avoid unnecessary render time):
Click 'Anim Preview'. Some work will be done, a new image will be created, and the standard Filters->Animation->Playback command is automatically invoked on it.
Hit Play to play the preview. You can alter the playback rate. play or pause the animation, and step through the frames. This is good when you are experimenting with timing.
Close the Animation Playback window when you are satisfied.
A few other items in the dialog are circled in red, I will get back to them later.
Hit OK to actually insert the background image in your animation. Some time will be spent rendering.
When rendering finishes, your previously blank animation will contain the scrolling BG.
GIMP-GAP also supports rendering to normal video formats like MP4, but we want a GIF.
We can create a GIF with the help of the Video->Frames to Image command. This is a reference to the fact that the builtin GIMP animation filter contains all the frames as consecutive layers in a single image.
We can safely ignore most of this dialog, we only care about the From Frame and To Frame settings, which should be set to 1 and 160 respectively; then we can click OK. GIMP-GAP will create a new image.
In this new image, we just need to do the normal things to prepare a GIF now:
Convert to Indexed (Image->Mode->Indexed, click Convert)
Filters->Animation->Optimize for GIF (this probably won't save much on this particular animation, but it's a good habit to get into)
Optimize for GIF created another new image, which we will Export as a GIF.
'As animation' is the only important thing here; it should be checked, then you can hit Export.
Here's the result (again, heavily color reduced to reduce size)
(EDIT: removed image, it was incorrect)
There are a few things here I didn't explain earlier:
Next/Prev point : use these to navigate through waypoints as needed.
The color panel on the left: Waypoints are shown in this color, you can click on it to change it in case it blends in too much with your image.
Layerstack: This effects where in the layerstack the item is inserted. 0 is the top of the stack (above everything else), 1 is one below the top of the stack, ... -1 is at the bottom of the stack.
Another thing, that I didn't circle, is the 'handle'. This specifies exactly what point in the inserted image the X,Y coordinates point to. For backgrounds, Left Top is good, but for other types of object, Center or other settings may be more useful.
In this animation, we just use the default FPS, 24. If you want a different FPS, you can use the Framerate field in Video->VCR Navigator to set it.
cels on Pixelation forums: Inspired me to write this up properly
retext: MarkDown editing with live preview.
Shutter: Screenshot capturing and annotating.
GIMP, GIMP-GAP: Tutorial subject