Ceci est une ancienne révision du document !
If the Page tool was the headline new feature for Inkscape 1.2, the equivalent for the recently released 1.3 version has to be the Shape Builder tool. It’s modelled on the same feature in Adobe Illustrator, but I don’t have enough experience with that program to be able to describe how the two tools might differ. Instead, I’ll describe its usage from the assumption that you have some experience with Inkscape, but without further reference to its proprietary counterpart. The Shape Builder can be thought of as a convenient way to perform certain Boolean operations between objects. There’s nothing that can be done with the Shape Builder that wasn’t previously possible with the existing tools, but anyone who has worked on complex designs using Boolean operations will be familiar with the need to plan multiple steps ahead, often duplicating objects that are otherwise removed as part of the operation. In many cases, the Shape Builder will greatly simplify such workflows.
Let’s look at the simplest of examples, in the form of a Boolean ‘intersection’ operation. For these first few examples, we’ll just use a couple of overlapping circles, to which I’ve given thick coloured strokes to make them stand out. Be absolutely clear, however, that all these operations are taking place on the areas bounded by those strokes, not on the strokes themselves. This same behaviour would occur with thinner strokes, or even with filled shapes that have no stroke at all. If we’re starting with an intersection operation, let’s first have a quick reminder of how to do this the Boolean way. • Select both circles. • Select the Path > Intersection menu entry. • What remains is the common area between the two shapes – the part in the middle: Notice that the resultant shape has adopted the style of the object on the bottom of the z-stack, resulting in a blue border. Now let’s do the same thing using the Shape Builder tool, which can be found near the top of the toolbar, just below the Node tool. The default keyboard shortcut for it is ‘X’.
As before, the first step is to select both objects that will contribute to the shape you’re building. If you have nothing selected, Inkscape will present a small warning message when you switch to the Shape Builder. It is possible to use the tool with only a single object – though doing so only really makes sense if that object is a self-intersecting path. More usually, you’ll want to select two or more objects before switching to the tool. When you do so, the original objects will be hidden and replaced with simple gray outline versions of the shapes. The rest of your drawing is also hidden, to avoid any confusion as to which objects are being used. Moving the mouse over the shapes will highlight each individual section, rather than whole objects. In this case, therefore, there are three areas that can be highlighted as the mouse moves over them, including the central piece we’re interested in. If you click on a section, it will change to a different shade of blue, indicating that it will be included in the final shape that you’re building. In this case, we want only a single part, so click the central section, then press the Enter key to confirm that you’re done. There’s also a confirmation button in the tool control bar, and switching to the Selector tool also has the same effect. In either case, we’re left with just the intersecting part of the original shapes.
One important thing to note is that the outline of the shape is red this time, rather than blue. The Shape Builder uses the style of the topmost element in the z-stack to set the styles of the resultant object, not the bottom element as was the case with the Boolean operator. Let’s try another Boolean operation: Path > Exclusion, which will leave us with a shape consisting of the left and right parts of the two circles, but not the section where they overlap – essentially the exact opposite of Intersection. This time I’ve added some fill colors to the circles, to emphasise what actually remains. Our final result is a path that consists of two sub-paths. That fact may not be entirely obvious, but it is possible to disentangle these two small moons from their kiss (e.g. with Path > Break Apart). The Boolean operation has done a very good job of cleanly removing the central part without introducing many new nodes.
Doing the same thing with the Shape Builder is simultaneously both extremely simple, and rather complex. You see, for such a basic operation, there are actually several ways to proceed, depending on exactly what you want to be left with. The most obvious is to hold Shift while clicking on the central section in order to remove it from the final result, rather than adding it: • Select both circles. • Switch to the Shape Builder tool. • Shift-click on the central section. • Press Enter to accept the shape: Well, it’s kind-of the same thing. Except we don’t actually have a single path this time, but rather our two original paths have both had a section cut from them. Instead of Shift-clicking to remove the central section, an alternative approach is to click on both the left and right sections, leaving the middle one un-selected so that the Shape Builder view looks like this: But, when you hit Enter, you’ll find that you end up with exactly the same two objects as above, each with a section cut out.
Suppose you really, really want to end up with a single complex path (i.e. one with sub-paths), but have an aversion to using Path > Combine for some reason. The Path Builder can actually produce a single path, but it requires a slight change of operation. Instead of clicking on each segment, you have to drag from one to another. • Select both circles. • Switch to the Shape Builder tool. • Click and hold in the left-hand section. • Drag the mouse to the right-hand section (avoiding the middle section). • Release the mouse button. • The two sections will be selected. Press Enter to confirm. The result this time is that the selected sections have been combined into a single path, looking more like the Boolean version.
Looks can be deceiving, however. Switch to the Node tool, and you’ll see that the Shape Builder has a tendency to create a lot of additional nodes. And I do mean a lot. This problem is already on the developers’ radar, so hopefully version 1.3.1 might improve matters – but I still wouldn’t be surprised to see more nodes from this tool than from the Boolean operations. There’s another interesting point to note when combining segments like this. Look at the result if I drag from the right segment to the left one, rather than left-to-right. Looks rather more red, doesn’t it? This provides us with another rule of Shape Building: when combining multiple segments, the style of the final result will be taken from that of the first segment selected.
The difference in behaviour between clicking segments and dragging over them means we can also use the Shape Builder to emulate the behaviour of another stalwart of the Boolean operations: union. • Select both circles. • Switch to the Shape Builder tool. Click and hold in the left-hand section. • Drag the mouse through the middle to the right-hand section, selecting all three. • Release the mouse button. • Press Enter to confirm. The result is that all the selected segments are combined into a single path. But although the results may look visually similar, again the Shape Builder leaves us with a lot of unnecessary nodes. This image shows the result of using the Boolean union (top) compared with the Shape Builder (bottom):
Given this obvious difference, you may be wondering what is the advantage of the Shape Builder when compared with the traditional Boolean operations. For simple operations that require only two objects, I think the Booleans, and related operations, are still the best way to go. But once you start combining multiple objects in complex ways, it’s hard to argue against the simple click and drag approach of the Shape Builder. One thing to be aware of as you work with more complex shape combinations is that you can use Ctrl-Z while in the Shape Builder tool to step back through your selections. This can be useful if you accidentally select or remove a segment you didn’t mean to, and spot it immediately. If you don’t see the error until you’ve made other selections, however, you’re out of luck: there’s no way to undo the selection or removal of an arbitrary individual segment. If you really aren’t happy with the selections you’ve made, the Escape key, or the cancel button on the tool control bar, will abort the Shape Builder operation entirely. If you accept the shape, but you’re not happy with the end result, a quick Ctrl-Z will revert your objects back to how they were previously. Finally, if you really want to get a feel for the power and flexibility of this new tool, why not use the File > New from Template… menu entry which opens a new page template dialog that includes a ‘Shape Builder’ tab filled with some complex overlapping paths that are ideal for experimentation.