Realistic drawing with MyPaint

victoroancea, 123RF

victoroancea, 123RF

Pen & Paper

Using MyPaint and a graphics tablet, you can create or trace drawings with the feel of real pens and brushes. All the necessary tools are included.

MyPaint tries as much as possible to emulate the use of brush and pen in a classic drawing program. Of course, there are limits, but the program provides numerous features that are hard to achieve with analog materials. To fully exploit MyPaint's potential [1], don't operate it with a mouse; instead use a pressure-sensitive input device – typically a graphics tablet.

Modern Linux kernels provide pretty good drive support for Wacom tablets and similar models from other manufacturers, although the latter pale in comparison. The hardware should also be recent enough (maximum five years old) to support the graphics tablet successfully. A first indication of whether Linux supports the device comes with the call to xsetwacom (Listing 1).

Listing 1

List of Devices

$ xsetwacom --list devices
Wacom Bamboo Pen Pad pad        id: 16 type: PAD
Wacom Bamboo Pen Finger touch   id: 17 type: TOUCH
Wacom Bamboo Pen Pen stylus     id: 18 type: STYLUS
Wacom Bamboo Pen Pen eraser     id: 19 type: ERASER

The program comes from the xf86-input-wacom package or some similarly named package in another distribution. If the input device is recognized (it may even appear multiple times), "only" the normal configuration is available. I'll talk more about this in the next two sections.

The description of the device (e.g., Wacom Bamboo Pen Pen… ) may differ depending on your particular equipment. If you can't find the input device through the command, several possible error sources and associated remedies can come into play. The best solution is to seek out a forum for your distribution [2] and look for postings that might help you.

Tablet Setup

Setting up the graphics tablet takes several steps. The kernel needs to load and initialize the module, you define the basic properties in the desktop environment, and the applications need to set up special properties of their own. Getting the kernel to recognize the input device presupposes setting up and enabling its support. This requirement becomes evident when booting and connecting the tablet (Listing 2).

Listing 2

Connecting the Graphics Tablet

[ 104.396599] input: Wacom Bamboo Pen Pen as /devices/pci0000:00/0000:00:\
  1d.0/usb2/2-1/2-1.1/2-1.1.3/2-1.1.3:1.0/0003:056A:00D4.0003/input/input16
[ 104.398681] wacom 0003:056A:00D4.0003: hidraw2: \
  USB HID v1.00 Mouse [Wacom Co.,Ltd. CTL-460] on usb-0000:00:1d.0-1.1.3/input0
[ 104.398843] input: Wacom Bamboo Pen Finger as /devices/pci0000:00/0000:00:\
  1d.0/usb2/2-1/2-1.1/2-1.1.3/2-1.1.3:1.1/0003:056A:00D4.0004/input/input18
[ 104.399072] input: Wacom Bamboo Pen Pad as /devices/pci0000:00/0000:00:\
  1d.0/usb2/2-1/2-1.1/2-1.1.3/2-1.1.3:1.1/0003:056A:00D4.0004/input/input19
[ 104.399391] wacom 0003:056A:00D4.0004: hidraw3: \
  USB HID v1.00 Device [Wacom Co.,Ltd. CTL-460] on usb-0000:00:1d.0-1.1.3/input1

Once the kernel detects the input device, you can configure it using the tools of the desktop environment. In Gnome and Unity, the process is particularly easy. The Control Center has a special tool for configuring (Wacom) graphics tablets (Figure 1). The setup is similar with KDE.

Figure 1: Use the tools of your desktop environment – in this case Unity – to configure the basic graphics tablet settings.

Using the Mouse Tracking function, you can define how the tablet maps to the screen. You would normally use the Tablet (absolute) setting that causes the active area of the tablet to cover the entire screen. In this mode, the screen pointer position corresponds to the pen position on the tablet. Alternatively, you can use the Tablet (relative) mode, where the pointer isn't initially repositioned but moves relative to the pen. This mode works best with small devices and takes a bit more time to operate.

In Assign Screen , you can determine if the pen is supposed to work on selected screens or on all screens. This setting takes into account that graphic users like to have multiple screens open: for drawing, for tools, for settings, and other tasks.

The next step is to adjust the characteristics of the input device. Many Wacom pens come with a built-in virtual eraser. To avoid activating it accidentally, you can set a pressure threshold for it in advance.

The next two settings for the pen buttons are a bit ambiguous. Essentially, you're setting what happens when you press one of the buttons. In most cases, the default setting of emulating mouse button behavior is a good choice. However, you can attach other functions to these buttons. Doing so proves a bit confusing, in that programs such as MyPaint provide similar functionality that then takes over. This functionality might require some slow and methodical adaptive work.

Particularly important is the last slider that you use to set the pressure threshold of the pen, which determines characteristics such as how thickly lines are drawn (Figure 2). MyPaint again has an analogous function.

Figure 2: A characteristic of graphics tablets is that the pen pressure determines the thickness of a drawn line.

In the Terminal

An exception is the Xfce desktop that currently has no tool for configuring graphics tablets. It's therefore desirable to maintain the settings of the Gnome Control Center. This isn't currently the case (with Xfce 4.10), but there is a workaround [3].

Another approach is to use xsetwacom , where you can enter all the supported properties from the command line. To activate absolute mode, for example, you would enter the following:

$ xsetwacom --set "Wacom Bamboo Pen   Pen stylus" mode absolute

Substitute your particular device for the description in quotes. You can also use the keyword modetoggle to toggle between absolute and relative mode. You can define the curve for setting the pressure sensitivity using two anchor points; the keyword is PressureCurve followed by four space-separated parameters. The man pages (man xsetwacom and man 4 wacom ) describe the different configuration options. You can find further details in the Linux Wacom wiki and the Linux Wacom project homepage [5].

The third setup phase is carried out directly in the application using Edit | Settings in MyPaint (Figure 3). The first tab lets you set the pressure sensitivity curve. This function is directly related to the desktop environment setting, so reciprocal actions may occur.

Figure 3: MyPaint lets you configure the pressure sensitivity of the pen and the actions of the pen buttons.

The same goes for the key bindings on the second tab. If you set the default mouse emulation mode in the desktop environment, it's possible to use it here. However, MyPaint supports only key bindings with combined with modifiers such as Ctrl, Alt, and Shift for some keys.

Old and new

The MyPaint interface for the current version 1.1 is clearly structured and clean (Figure 4) with little distraction from the canvas. Because the tools are at the top edge, you can change brushes, characteristics, and line styles quickly (Figure 5). It takes only a few parameters to make the necessary adjustments. Also, MyPaint 1.1 allows using Gimp color palettes [6], which all major distribution repositories should now include.

Figure 4: The MyPaint interface assembles the tools at the top edge. The dock at the right edge shows information and lets you select colors, brushes, and layers.
Figure 5: The important MyPaint functions are easily reachable. You select the brush tips, set their behavior, and determine how the program interprets brushstrokes.

The layer concept has a special significance in MyPaint. The program supports an unlimited number of layers to manage the parts of an image separately. These layers are managed in a dock, where you can activate single layers with a mouse click. Clicking the eye icon hides the layer but does not delete it. MyPaint's layer concept is similar to that of Gimp, albeit with only a subset of the functionality.

By default, MyPaint has no dock on the right edge, but it is created automatically once you open a window through the buttons arranged on the toolbar on the right and "unhook" it from the edge (Figure 6). In this window, you can change colors, brushes, and layers.

Figure 6: The dock contains only certain tools, which become available throughout. You position the dock by pulling it from the right edge.

The brush tips are very special features of MyPaint. The program sorts them into various groups, which you can add to through subsequent packages. These groups combine properties that go beyond the usual form (Table 1). All brush tips support Gimp's "soft drawing" mechanism, which allows you to draw fine lines without any noticeable artifacts.

Table 1

Pen Tips

Group Characteristics>
Classic These tips simulate realistic drawing instruments, such as brushes, soft and hard pencils, markers, airbrushes, calligraphy nibs, or spatulas.
Experimental Differently animated tips that change shape in rapid succession during application.
Favorites User-selected tips that are dragged and dropped from other groups.
Lost&Found Tips for precise etching, painting, blurring, and many other functions.
Set#1 Similar pens.
Set#2 Various brushes.
Set#3 Special, mostly animated tools.

New to MyPaint 1.1 are the geometry tools that you select from Line Mode (Figure 5, on the right). With Lines , you can draw individual lines; with Line Seq , you draw a sequence of lines; and with Ellipse , you can create free-hand curves. These tools let you make use of pen pressure [7], which you can accomplish with the Line Pressure setting (Figure 5, below). In this same group, you'll find the tool for symmetrical drawing.

As with version 1.0, the newest release allows the use of keyboard shortcuts (see Table 2 for a summary). Also new is the ability to quick-save interim versions of your work in what are called "scraps." You can then use F2, F6, and F7 to toggle through them.

Table 2

Keyboard Shortcuts

Key(s) Function
Ctrl+N New image
Ctrl+N Open image
Ctrl+E Export image
Ctrl+Page-up New layer over current
Ctrl+Page-down New layer under current
Ctrl+C Copy layer to clipboard
Ctrl+V Paste from clipboard
Ctrl+Left-arrow Turn stepwise left
Ctrl+Right-arrow Turn stepwise right
Ctrl+S Save image as OpenRaster
Shift+Ctrl+S Save image as
Ctrl+Q Quit
Ctrl+Z Undo
Z Undo
Y Redo
Delete Empty layer
. and + Reduce view
, and - Diminish view
F2 Save image as scrap
F3 Open last image
F5 Undo
F6 Open previous scrap as image
F7 Open next scrap as image
F11 Full screen mode
A Reduce opacity
S Increase opacity
B Select brush
D Reduce brush
F Increase brush
G Select colors
I Mirror vertically
U Mirror horizontally
J Draw connected lines
K Draw lines and curves
L Select layers (dock)
O Draw circles
P Draw freehand
R Color pipette
Shift+I Symmetrical drawing

Conclusion

Once you complete the somewhat cumbersome installation and configuration of the graphics tablet, working with MyPaint can be fun. With a few clicks, you can set new layers, select brushes, switch colors easily, vary the thickness of lines, and use various pens. The layers feature allows you to trace pictures or practice drawing. Overall, the performance is pretty fast and requires few resources.