Animate drawings with Pencil2D

Tutorial – Pencil2D

Author(s):

Pencil2D, an easy-to-use painting and 2D animation program, lets you create small animations quickly. Despite the simple user interface, you might need a little help getting started.

If you want a hand-drawn ball to drop elegantly from the ceiling in a YouTube video, Pencil2D [1] is the program for you. Thanks to this drawing program, artists can do more than just paint pretty comic figures, balls, or other objects on virtual paper; they can also animate these objects. If required, the tool imports bitmap images or photos for use as backgrounds.

Pencil2D is primarily intended for cartoon artists, but the software also lets you quickly create animated illustrations or diagrams. All you have to do is add a little of your own artistic talent. An impressive YouTube video [2] shows what professional animators have created with Pencil2D. The program is licensed under the GPLv2; the source code is available from GitHub [3].

Some distributions have Pencil2D in their repositories. Arch Linux users will find the tool in the pencil2d package in the Arch Users Repository (AUR). On current Fedora systems, you can fetch and install the package by typing:

sudo dnf install Pencil2D

Debian and Ubuntu users install the pencil2d package at the command line with:

sudo apt install pencil2d

If the animation program is missing from your distribution's software manager, or if you only find an older version stored there, you can use a Flatpak or AppImage package – most current distributions now support both formats. Pencil2D's Flatpak package is available from the Flathub repository. To retrieve and install it from Flathub, use the first two commands in Listing 1; the third command starts the animation program.

Listing 1

Installing the Pencil2D Flatpak

$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
$ flatpak install flathub org.pencil2d.Pencil2D
$ flatpak run org.pencil2d.Pencil2D

The AppImage is available directly on the Pencil2D website [1]. Click on Download, and then select the Current Stable Version. Below the penguin icon, select the version that matches your distribution. Then make the downloaded file executable (Listing 2) and launch it.

Listing 2

Installing the Pencil2D AppImage

chmod +x pencil2d-linux-amd64-<Version>.AppImage

Start Drawing

When launched, Pencil2D opens the main window shown in Figure 1. In the center, you can see the empty drawing area. In the top left corner, you'll find the drawing tools. The pencil draws thin lines; the brush makes thicker lines.

Figure 1: On the left below Options, you will find additional settings for the selected tool (e.g., a brush's stroke width).

If you need a straight line, select the Polyline tool, the button that resembles an "M" (Figure 2). The first mouse click defines the starting point; clicking again adds a section. Double-click to end the drawing process. The eraser does pretty much what you would expect; the index finger smudges the area under the mouse pointer when you press the mouse button. The garbage can clears the complete drawing area without prompting.

Figure 2: You do not need to navigate the menus to enable the painting and editing tools – all you have to do is press a shortcut key.

When painting, a grid can be placed over the drawing area using View | Raster. You determine the size of the individual boxes under Edit | Preferences | General | Grid section. To zoom in or out of the drawing, use the mouse wheel, or hold down Ctrl while pressing the up or down arrow key.

In the Color Box window, you can define the drawing color (Figure 3). First select the base color from the wheel and then choose the brightness from the inner square. Alternatively, click RGB and use the sliders to mix the three basic colors (red, green, and blue). To avoid having to define a color time and time again, you can add the color by pressing the plus symbol next to the Color Palette. Pencil2D automatically gives the color a name, which you can change by double-clicking on it. You can then select a color from the palette with a single click.

Figure 3: The A slider defines transparency. Translucent objects are especially important when using layers.

Moving Images

Using the timeline at the bottom, you can breathe life into your drawing. Pencil2D relies on the flip-book principle. An animation consists of a sequence of individual images that the tool somewhat inconsistently also refers to as keys. The following example of a ball dropping demonstrates how quickly an animation can be created in Pencil2D in this way.

First draw a circle at the top of the drawing area. We now want the ball to slowly drop. To do this, create a new frame by selecting Animation | Add Frame or by pressing the F7 key. You will now see a new empty drawing area, while the vertical red mark moves one position to the right in the timeline.

Using the . and , keys allows you to jump back and forth between the existing images. In the top line of the timeline, Pencil2D numbers the images consecutively. If you click on a number there, you are taken directly to the matching single screen. The Zoom slider lets you expand the timeline's width on screen and thus simplify navigation. In any case, the red bar marks the image you are currently viewing and editing in the drawing area. Make sure Pencil2D displays the second frame you just created and the new empty drawing area.

Onion Skin

To drop the ball, draw another circle slightly below the first one. This is not so easy since you can't see the ball from the first picture. To change this, you can press O, go to View | Onion skin | Previous, or click on the second button from the right in the top line under Display (see Figure 4).

Figure 4: You can see two frames, which Pencil2D will play back one after the other. The black circle resides in the second frame; the circle in the first frame is bright red.

Now, the first image appears, colored light gray, in the drawing area. Pencil2D refers to this image as the onion skin. To make it more obvious that this is the ball from the previous image, you can color it red by clicking on the icon with the red box under Display. Now draw a new ball slightly below, which is colored black, as shown in Figure 4.

Repeat this procedure until the ball arrives at the bottom of the drawing area. To make your work easier, click on the Select tool (with the dashed rectangle) and draw a frame around the ball. You can grab the selection using the handles at the corners.

Select Edit | Copy to create a new frame. The selection rectangle should appear automatically. Move the mouse pointer into the rectangle until it turns into a circle. Now move the box a little to the right using drag and drop. Then use Edit | Paste to insert the copied circle at exactly the position shown in Figure 5. You can unselect by clicking anywhere on the drawing area.

Figure 5: The Select tool helps you copy and move objects across multiple frames.

When fine-tuning more complex animations, you will often need a preview of the following image. To do this, simply click on the second symbol from the right in the bottom line on the left side under Display. The following images are now displayed as grey shadows. To help distinguish them, you can color them light blue, as shown in Figure 6, by clicking on the blue square icon under Display.

Figure 6: This figure shows a single frame selected from the middle of the animation. The previous circle is bright red, the current circle is black, and the three following circles are light blue. This makes it easy to follow the animation process.

Run It

Pencil2D always displays the onion skins of the last or next five images. To change this, go to Edit | Preferences and select Tools. To define how many previous images Pencil2D displays, add a number for Number of previous onion frames shown; similarly you can define the Number of next onion frames shown. (Pencil2D automatically extends the timeline up to 10,000 frames.)

You should now have created several frames where the ball slowly drops from the top to the bottom. To view the animation, select the first frame. Then press Ctrl+Enter or click the right arrow triangle in the timeline. Depending on how many images you have created, the animation may be over fairly quickly. This changes if you enable the curved arrow in the timeline or select Animation | Repeat. During playback, Pencil2D will repeat the animation until you press the corresponding button or Ctrl+Enter to stop it again.

The playback speed can be controlled using the fps input box on the timeline's right side. By default, the animation runs at 12 frames per second (fps). You can experiment with lower or higher values for your ball. Then make sure that your last frame is visible on the drawing area.

Transparency Report

Many scenes consist of several objects (e.g., the ball could fall on a wall). Pencil2D supports layers so that you do not have to repaint the background in each single image. Layers work like slides, which the tool simply superimposes on top of each other.

To create a new layer for the wall, choose Layer | New Grid Layer and assign a name such as Background. Pencil2D now adds a new line to the timeline. Click the Background layer. Everything you paint from now on is assigned to this layer.

Use the Polyline tool to draw a line under the ball from left to right. If you play the animation now, the ball drops onto the line. To include a photo of a real wall, use File | Import | Image to load an image on the currently active layer.

In the timeline, you will find several small boxes, each representing a single image. Pencil2D displays each of them until a new frame follows in the line. Try this out by selecting the middle of the animation with the . and , keys and then creating a new frame with F7. Paint a yellow sun with the brush. The sun will appear in the second part of your animation (Figure 7).

Figure 7: Here the first frame of the background would be seen for four frames. Then Pencil2D switches to the single image with the sun.

To delete a single frame, select the corresponding layer on the timeline, then select the corresponding frame, and select Animation | Remove Frame. Unlike clicking on the trash can icon, Pencil2D deletes the entire image rather than just clearing the drawing area.

Stackable

Pencil2D superimposes the drawings in the layers in the order in which they appear in the timeline. In Figure 7, all drawings in the Background layer would appear above the ball. You can change the order of the layers by dragging the name of a layer up or down to the desired position. During fine-tuning in particular, it can sometimes help to hide a layer. Simply click on the dot in front of a timeline name.

Thus far in my example, I've worked with bitmap images (i.e., with pixels). Pencil2D also has vector layers. One vector layer is automatically created by Pencil2D; others can be created by selecting Layer | New vector layer. These layers work like the image layers, but you can only draw lines and geometric shapes. In return, all objects can be moved and distorted individually later. To do this, click on the respective line with the Move tool. The object can be scaled using the handles that then appear and moved to another position using drag and drop (Figure 8).

Figure 8: The triangle in the vector layer can be compressed and stretched using the handles.

If you want to share your animation, create a video by selecting File | Export. The Movie sub-item saves the animation as an MP4 file; alternatively, Pencil2D supports exporting to an animated GIF.

Conclusions

Pencil2D helps users to quickly create small animations. Compared to its competitors, however, the tool still lacks numerous convenient functions, such as circle and rectangle tools. On the other hand, the range of functions is manageable, which means that you can achieve results more quickly. If you are looking to create an animation for the first time, take a look at Pencil2D. The Pencil2D showcase [2] demonstrates what the program can do in the hands of capable artists.