13.1 Path Effects

Path effects are an easy-to-use (for the end user) yet powerful (for the developer) mechanism for implementing modifications of the visible shape of the path—for example, rounding all corners, roughening it, blowing or pinching it. No matter which path effect you apply to a path, the original path before the effect can still be viewed and edited—and after you edit the original path, the visible path is automatically recalculated from it and from the effect parameters.

Thus, path effects in Inkscape are another example of the basic principle of vector graphics: Instead of making some permanent and destructive change, leave the original object unchanged and just record the way this change is to be applied. After that, both the original object and the parameters of the change applied to it can be edited separately at any time.

Path effects, despite the name, apply not only to paths but also to shapes (Chapter 11) which remain shapes and are still editable as such, using the handles or numeric parameters in their shape tools. Path effects don’t, however, apply to text objects, clones, or bitmaps. A path effect can be applied to a group, which gives the same result as if the effect was applied to all paths and shapes in the group combined (i.e., made subpaths of a single path).

The Sketch effect () applied to a path (left) and to a 3D box (right)

Figure 13-1. The Sketch effect (13.1.6 Sketch) applied to a path (left) and to a 3D box (right)

When a path effect is applied to an object, the only aspect that changes is the visible shape of the object; if you want to change its style in a nondestructive way, try filters instead (Chapter 17). Path effects can be stacked on top of one another, so that the output of one effect is an input for the next one.

To assign one object’s path effect to any number of other paths or shapes, copy the source object (), select the target, and use the Paste Path Effect command (). Inkscape comes with a number of sample SVG files (in /usr/share/inkscape/examples on Linux, <inkscape-dir>\share\examples on Windows), some of which demonstrate various path effects; you can use this copy/paste trick to reuse the effects from any of these sample files in your documents.

When you combine (12.1.1 Subpaths) shapes or paths, the result will have the path effect of the topmost object, if any. Breaking apart a path with a path effect causes the effect to be applied to all resulting new paths.

To clear away the path effect and return to the original path, use the Remove Path Effect command in the Path menu. If, however, you want to preserve the result of the effect and forget the original path, use the Object to Path command (); this will not change the way the path looks, but the effect will be gone.

With the Node tool, you are editing the original path, not the visible path after the effect. Since the path you’re editing is not visible by itself, it is convenient to highlight it using the corresponding toolbar button (Figure 12-17); most effects will enable this highlighting automatically for you.

The Path Effect Editor dialog (, see Figure 13-2) is the main control hub of path effects. It lists all path effects supported by Inkscape (this list expands with each new Inkscape version) and lets you choose those to apply to your selected path, shape, or group. When an object with one or more path effects is selected, you can use this dialog to view its stack of effects, add or remove effects, and adjust the parameters of the selected effect.

The Effect list in the dialog lists all the effects applied to the selected object. They are listed top to bottom; that is, the first effect applied to the source path is the topmost one, its output is passed to the second one, and so on until the last listed effect whose output is displayed.

A new effect you add is placed at the end of the stack. You can move any effect in the stack up or down by the arrow buttons below the list. The eye icon before each effect’s name allows you to disable an effect, forcing Inkscape to bypass it (the Is visible? checkbox in an effect’s parameters has the same function). To delete an effect from the stack, use the button with the minus sign.

Parameters of an effect can belong to several types:

A link parameter displays a row of four buttons:

Edit button

Copy button

Paste button

Link button

Apart from the numeric controls in the dialog, some path effects allow you to edit their parameters visually by on-canvas handles accessible in the Node or shape tools. We will see examples of this as we discuss specific effects.

The Pattern Along Path and Bend effects are very similar. They both take one path (called the pattern) and bend and/or stretch it along another path (called the skeleton). This is very similar to “skeletal paths” in software such as Microsoft Expression, typically used for freehand drawings (see Figure 14-11).

As usual with path effects, both the skeleton path and the pattern remain editable at any time, with the result updated live. This is a great way to create easily editable vector brushes—for example, you can start by creating a drawing with the Pen or Pencil tools, and then try applying various patterns to all its paths, adjusting the widths for the best result.

Aside from the ability to repeat a pattern, the main difference between the Pattern Along Path and Bend effects is which path is the skeleton and which is the pattern:

Both effects allow you to change the width of the pattern. This width can be measured either in the units of the original width of the pattern or in the units of the skeleton length:

The Pattern Along Path effect can use one of the following repeat modes:

Single

Single, stretched (default)

Repeated

Repeated, stretched

Spacing (only for repeated modes)

Normal offset

Tangential offset

These offsets and spacing parameters are, by default, in absolute px units. By checking the Offset in units of pattern size checkbox, you can express them as multipliers of the pattern size—for example, a tangential offset of 0.5 will shift the pattern along the skeleton by half of the pattern’s width.

By default, the original of the pattern is considered to be horizontal—that is, the pattern is aligned on the skeleton by the pattern’s horizontal axis. By checking the Pattern is vertical (for Pattern Along Path) or Original path is vertical (for Bend) checkboxes, you can rotate the pattern by 90 degrees so that it’s aligned on its vertical axis, as shown in Figure 13-12.

The surprisingly useful Stitch Sub-Paths effect works only for paths with two or more subpaths (12.1.1 Subpaths). It replaces the source path with a lattice of paths connecting equispaced points on the subpaths; you can set the number of the connecting paths via a parameter. With this effect, you can create all kinds of hair, fur, lattices, moiré patterns, or “power fields”:

The connecting lines need not be straight, although that is the default. You can use the Stitch path link parameter to paste or link any existing open path to serve as the stitches, or you can edit the lines with the Node tool. The Scale width parameter scales the stitch path in the direction perpendicular to its start-end direction (the value of 1 gives it its natural width). The Scale width relative to length makes the width of each stitch depend on the length of this stitch, as shown in Figure 13-15.

Finally, a group of randomization (variance) parameters allows you to shuffle the attachment points of the stitches, both along the path (spacing) and perpendicular to it (edge), separately for the beginning and end of each stitch:

This effect breaks a path into subpaths, creating gaps between them where the path (or a group of paths) self-intersect. It can turn a stroked path with self-intersections into a Celtic knot:

The only numeric parameter for this effect specifies the width of each gap in px units. On canvas, you can control each intersection individually. Select a path with the Knot effect, switch to the Node tool, and notice that one of its self-intersections has a diamond-shaped handle and a green circular indicator which is open on one side. Click that handle; the indicator flips to the other side and the gap now affects the other line at the intersection. Click it again and you close the intersection removing any gaps; the indicator is now a solid circle. You can cycle through these three states of an intersection by clicking the handle. To control another intersection on your path, just drag the handle and drop near the intersection you need.

Sketch is a complex artistic effect that turns a path into a sketch-like drawing with multiple strokes, as if hand-drawn by an artist who was trying to find the best shape:

To make sense of the plethora of parameters of this complex effect, remember that the sketch consists of two types of artifacts: approximating strokes and construction lines. The approximating strokes cover the entire path; they are typically curvilinear, more or less parallel to the original path (with certain tremor), and travel at some distance from it. The construction lines, on the other hand, identify and emphasize straight or almost straight parts of the path by drawing straight lines that extend on both sides.

For the approximating strokes, you can change:

For the construction lines, you can change:

Building paths with Bézier curves (12.1.4 Bézier Curves) has many years of tradition behind it. All modern graphics software worth its salt supports it in much the same way, and millions of users are familiar with it. The Bézier paradigm is, undoubtedly, extremely flexible and powerful. I think most people who have ever used it will find it difficult to name any major disadvantages specific to it.

And yet, once you try something better, these disadvantages become painfully obvious.

Spiro splines are a novel way of defining curvilinear paths, developed by Raph Levien. They take some getting used to, but for certain tasks (such as lettershape design) Spiros have a clear advantage over Bézier curves. Since version 0.47, Spiro splines are available as a path effect in Inkscape, which means you can use all the convenient Inkscape path tools (such as moving and transforming groups of nodes, node sculpting, etc.) on Spiro paths. The Pen and Pencil tools can produce Spiro paths directly (14.1.4 Modes).

A Spiro path is defined by a sequence of nodes. However, unlike a regular path consisting of Bézier curves, all Spiro nodes lie on the path, and there are no off-path handles. The curvature of the path is defined entirely by the positions of the nodes and their types. The path behaves very similar to a springy rod that is forced to pass through the given points and which uses the minimum possible curvature to satisfy the requirement:

Once you get the basic idea, the Spiro behavior will feel more and more natural as you’re getting used to it. More importantly, the resulting path is always very smooth—not just superficially smooth, as in having no cusps, but smooth at a deeper level, which you can only achieve with Béziers after a lot of laborious tweaking.

After a Spiro experience, it becomes clear that the main problem with Béziers is each node having not only a position but also its own intrinsic “direction” and “curvature,” as defined by its handles. So, whenever you move a Bézier node around, you also need to carefully adjust its handles so the curve still looks smooth and natural. With Spiros, you are freed of this requirement; just move the node wherever you want the curve to go, and the smoothness of the curve is taken care of automatically.

To create a Spiro path, select any path and assign the Spiro spline path effect to it. There are no parameters. Each node of your path becomes a point of a Spiro path, depending on the type of node (12.5.5 Node Types):

Probably the biggest problem with Spiro splines is that some configurations of points are unstable and produce wild loops and spirals instead of a smooth curve. Still, sensible sequences of points usually work fine; you just need to avoid sharp changes in direction between points to prevent such instability. Hopefully, the robustness of the algorithm will be improved in future releases.

When editing Spiro paths with the Node tool, the red highlight of the source path may be a distraction; you can turn it off with a toggle button in the controls bar.

This effect distorts a path or a group of paths by fitting them into a curvilinear envelope. After you apply the effect, the envelope is rectangular, and you can curve its sides one by one by the Node tool. The effect treats all four sides as separate helper paths (“bend paths”), which is slightly inconvenient: You need to click the Edit buttons for each side in turn to curve all four sides. The Copy and Paste buttons allow you to transfer the exact shape of the envelope from one object to another.

This fractal-like recursive effect takes the original path and repeats it twice (as subpaths) with shifting, scaling, and rotating; it then repeats the same operation on these copies, and so on for the specified number of generations. The transforming of the copies is determined by the configuration of three helper paths: a reference segment (initially, horizontally across the source path) and two generating paths (initially, horizontally across the two first-generation copies). These helper paths are two-node straight line segments (i.e., their curvature is disregarded); to edit them, you can use the Node tool and click the Edit path effect parameter button on its control bar once or twice; or, you can click the Edit button in the effect’s parameters for the corresponding helper path. Here are some examples: