Ceci est une ancienne révision du document !
Last month, I took a look at the new Shape Builder tool in Inkscape 1.3, which offers a very convenient way to perform various Boolean operations. Unfortunately, it also tends to create a lot of extra nodes, so for some workflows, there’s still a benefit to using the suite of Boolean operations under the Path menu. For users who wish to use those tools, I’m happy to report that Inkscape 1.2 and 1.3 both extended them a little.
Before I proceed too far, a note for the pedants: I’ll refer to all these tools under the umbrella of “Boolean operations” for convenience. Technically speaking, the true Boolean operations are those that are based on Boolean algebra – a branch of mathematics named after George Boole, who formalised it in 1847. Only a few of the tools in the Path menu actually work in a strictly Boolean manner. But given that those tools are concerned with creating new shapes by combining and removing overlapping parts of multiple paths, it makes sense that other tools which achieve similar goals are grouped with them in the same menu. So for the purposes of simplicity, all the shape manipulation tools under the Path menu are Boolean operations as far as this column is concerned.
This month, we’ll look at the first new addition, which was introduced in Inkscape 1.2: Path > Split Path. This is a little like the existing Path > Break Apart feature, except that it breaks paths apart in a way that probably makes more sense – and will be more useful – to most people. Let’s start with a very simple example: here I’ve used Path > Difference to cut one circle out of the center of another, creating a donut shape. I’ve then duplicated the donut, and used Path > Combine (or Path > Union) to convert the whole arrangement into a single, complex path. As a quick reminder, I use the term ‘complex path’ to refer to any path which is made up of multiple sub-paths.
With the Node tool active, you can see from the image that there are four sub-paths, one for each dark-red circle, and each consisting of four nodes. Let’s suppose that a little later we decide that it would be better to separate these objects in order to move them around independently. In previous versions, a naive user might reach for Path > Break Apart, only to be rather disappointed with the result.
Break Apart reduces a complex path to a collection of individual simple paths, by breaking each sub-path out into a separate object. In this case, we end up with four separate path objects, but because the larger paths no longer have a hole in the middle, their fill obscures the fact that there are a couple of smaller paths behind. Sending the outer circles down in the z-stack makes things a little more obvious – this screenshot leaves the left-hand circles untouched, but moves the large right-hand circle to the bottom of the stack.
That may have made it a bit clearer what has happened, but it doesn’t really get us to the result we wanted – two separate donuts. For that, we have to select the two circles on the left and use Path > Combine, followed by doing the same to the two circles on the right. Finally we have two complex paths, each representing a single donut, which can be moved independently.
In this particular case, a user who is already familiar with the behaviour of Break Apart might have chosen to duplicate the original and cut half the content out from each copy using direct node editing, or some other Boolean technique that involves creating a quick sacrificial cutting shape. But for a more complex shape with lots of sub-paths, those approaches can quickly become unwieldy. Whichever approach you take, there’s no doubt that it’s a lot of steps just to split two visually separate objects into individual complex paths.
Now let’s try the same thing using Path > Split Path. Starting with our complex path containing four sub-paths, applying this function gets us directly to the desired outcome (the same as the previous screenshot), with no additional fuss. Perfect!
Of course Inkscape isn’t able to read your mind to determine how you want it to split your four sub-paths, and there are still cases where Break Apart might be the better option, so it’s important to understand the logic used within this new feature. Quite simply, it breaks your path based on whether the sub-paths overlap or not. Any group of overlapping sub-paths will be split out into a new complex path. An individual sub-path that doesn’t overlap with any other sub-path will be split out into its own new simple path. The net result is that a previously complex combination of shapes will be broken up into independent objects, based (broadly) on how visually separate they are.
An example with two donuts makes for a good introduction, but when would you actually want to use this feature in a real design? Perhaps the most common situation is when trying to split text (which has been converted into a path) into individual glyphs. In typographical terms, some characters have ‘counters’ – the closed shape in the middle of an ‘o’ or ‘p’. These don’t fare so well when Break Apart is used.
Use Path > Split Path, however, and the result is a lot closer to what you probably wanted.
Be aware, however, that it’s not perfect. Inkscape doesn’t know that this path represents characters, and Split Path just separates out the non-overlapping paths, so any glyph that is made up of non-overlapping parts will result in more than one path being created. You can see this with the ‘i’ or the ‘!’ which are each split into two separate paths and need to be re-combined manually (with Path > Combine or Path > Union). It’s still a lot less post-processing than with Break Apart, but don’t think that the new feature is a complete panacea.
Another gotcha with this feature is Inkscape’s notion of what constitutes a non-overlapping path. Consider this variation on our earlier donut, this time with an additional ‘island’ in the middle.
What do you think Path > Split Path will do in this case? It’s pretty clear that the nodes for the island are all inside the outer sub-path, and therefore can be considered to be overlapping. Sure enough, Split Path has no effect on this shape at all. But what about this one?
This time the outer shape has a tiny gap in it on the right-hand side. The thick stroke disguises it somewhat, but it’s there. To the human eye, you might still consider the island to be ‘inside’ the shape, but, mathematically speaking, it’s not. Inkscape goes with the mathematical definition, so using Split Path results in two objects, not one.
Now let’s extend that example a little further by moving the ends of the broken shape so that they cross.
From a human perspective the island is most definitely inside the shape this time. But, again, in mathematical terms, the two paths are not overlapping, so Split Path results in two separate objects. All of which is to reinforce the fact that this feature is more likely to give the desired result than Break Apart, but it still needs to be treated with care to ensure it has split things the way you want, especially when there are features that could end up as separate objects even if they give the appearance of being inside a larger shape.
I really wish this tool had been available a few years ago, when I was writing a weekly comic strip for my local newspaper. I created it in collaboration with Vince, a far more artistically competent friend. In order to turn the strips round quickly, he would draw the various elements of each comic separately on a sheet of paper, and I would then scan the entire sheet and trace it with Inkscape. Here’s an example of a typical character sheet, after scanning and tracing.
The problem here is that Inkscape’s Trace Bitmap feature produces a single complex path for the entire traced image. In this case the path consists of over 15,000 nodes! Part of my job was therefore to create numerous duplicates of the traced image, each overlaid with a different cutting path. Path > Intersection was then used on each pair, removing all the parts that were not covered by the cutting path in each case. The final result was a separate complex path for each character or part on the sheet.
So how does Path > Split Path fare when faced with a task like this? Not at all badly, it turns out.
The first three images are perfectly cut out, and ready to go. The last one on the top row requires a small amount of re-combining to ensure that the shadow and the movement marks all remain with the character. The bottom row did a little worse, though it’s hard to see from this screenshot. For each head there are some small elements – a wart here, an eye there – which have been split into separate paths. These are all due to the fact that the neck is not closed off, resulting in what Inkscape sees as an open shape, much like the broken circle I presented earlier. A little re-combining fixes the issue, but in reality we would have quickly learned that, while drawing, Vince should close the end of the shape in such situations, reducing the problem going forwards. Across dozens of character sheets and pages of props and backgrounds, Split Path would have saved me many, many hours of manual path tweaking.
If you frequently work with complex paths, text-as-paths, or bitmap traces, I hope you can see how this feature might be a game-changer for your workflow. Compared with the alternatives, it will often do a better job with less complexity and confusion. Even in those cases where the results aren’t perfect, they’ll probably be more understandable to most users than the confusing mess that Break Apart often appears to make of things.
Next month, I’ll continue this theme, to take a look at the new Boolean operations that were added with Inkscape 1.3.