Ceci est une ancienne révision du document !
In researching last month’s article, I found that Inkscape’s default behaviour when adding an LPE to a clone, or when using the Edit > Clone > Clone Original Path (LPE) option, has changed from adding the “Clone original path” effect, to using the “Fill between many” effect instead. On the surface, this brings an obvious regression: it’s no longer possible to move the clone independently of the original object. So why was this change made? In order to explain that, you have to understand what this LPE does in normal day-to-day use. Something that is often misunderstood about LPEs (though hopefully not by readers of this column, as I’ve pointed it out previously) is that the output from an LPE is just a single path. It might be a complex path, containing sub-paths, but it’s still a single path from the perspective of styling. It can have only a single stroke color and style, and a single fill. When you use something like the Power Stroke LPE (see part 47), or the new Taper Stroke LPE (see below), it doesn’t somehow imbue Inkscape with the magical ability to create variable width strokes (a feature that the underlying SVG 1.x format doesn’t allow). Rather, it creates a filled shape that happens to follow your original path, and gives the appearance of being a variable width stroke. But in taking this approach, the ability to fill the original shape is lost – any fill you apply now applies to the stroke-like path that is output from the LPE.
En faisant des recherches pour l'article du mois dernier, j'ai trouvé que le comportement par défaut d'Inkscape quand on ajoute un LPE à un clone, ou quand on utilise l'option Éditer > Cloner > Cloner le chemin original (ECI) a changé, utilisant l'effet «Remplir dans les nuées » en remplacement de l'effet « Cloner le chemin original ». En surface, ceci apporte une régression évidente : il n'est plus possible de déplacer le clone indépendamment de son original. Aussi, pourquoi cette modification a-t-elle été faite ? De façon à expliquer ça, vous devez comprendre ce que fait ce LPE dans une utilisation quotidienne.
Une chose, qui est mal comprise à propos des LPE (sauf pour les lecteurs de cette colonne, car j'ai attiré votre attention précédemment), est que la sortie d'un LPE est un unique chemin. Celui-ci peut être compliqué, comprenant des sous-chemins, mais en termes de style, il reste une un chemin unique. Il peut avoir aussi une couleur et un style de ligne uniques, et un seul remplissage. Quand vous utilisez quelque chose comme le LPE Contour dynamique (voir partie 47), ou le nouveau LPE Contour fuselé (voir ci-dessous), il n'imprègne pas en quelque sorte Inkscape avec la capacité magique de créer des contours à largeur variable (une fonctionnalité que le SVG 1.1 sous-jacent ne permet pas). À la place, il crée une forme remplie qui suit votre chemin original et donne l'apparence d'avoir une largeur de contour variable. Mais, en prenant cette approche, le capacité de remplir l'original est perdue - tout remplissage s'applique au chemin avec le semblant de contour qui est la sorti du LPE.
This is a particular problem for things like cartoons and comics, where an artistically varying stroke is a necessity, but you also want to fill areas with color. So the Clone Original Path LPE (also covered in part 47) was born, which at last allowed you to apply one LPE to your stroke, but then also clone the original shape via a sacrificial path with the LPE applied which could be independently filled. But it works with only one path at a time. And cartoon characters are often made of more than one – sometimes with artistically placed gaps in the outlines. Cue the return of “Frankie”, a character from my “Monsters, Inked” comics drawn by my co-creator, Vincent Mealing. This time, I’m presenting him having already manually traced the hand-drawn lines, and with some artistic gaps inserted for demonstrative purposes: Trying to fill a shape like this is a problem. It can be done manually by creating a separate object for the fill and adjusting its shape to suit. The Bucket Tool can help with this, but those gaps need careful plugging with temporary objects first. In either case, a tweak to the outline shape wouldn’t be automatically reflected in the fill. For that, we need a clone of some sort, but that interferes with our ability to add LPEs to vary the stroke width. The Clone Original Path LPE can’t help us either, as the shape we want to fill (just the face, for now) is clearly made up of more than one path. And this is precisely where the Fill Between Many effect comes to the fore.
C'est un problème particulier pour des choses comme les bandes dessinées et les comics, où un contour variant artistiquement est une nécessité, mais où vous voulez aussi colorier les zones. C'est ainsi qu'est né le LPE Cloner le chemin original (vu aussi dans la partie 47), qui vous permettait au moins d'appliquer un effet dynamique à votre contour, mais qui, ensuite, clonait aussi la forme originale avec un chemin à sacrifier sur lequel était appliqué le LPE et qui pouvait être rempli indépendamment. Mais ça ne marche que sur un seul chemin à la fois. Et les personnages de bande dessinée sont souvent faits de plus d'un chemin - parfois des zones effacées placés avec art dans le trait. Pour preuve, revenons à Frankie, un personnage de la bande dessinée « Monsters, Inked » dessinée par mon co-auteur Vincent Mealing. Ce coup-ci, je le représente avec les lignes « faites à la main » déjà tracées manuellement, avec des interruptions artistiques du trait pour les besoins de la démonstration :
Fill Between Many allows you to collect together several paths into a single LPE. The output is the result of creating a path that joins all of the constituent paths together into a single shape, by implicitly linking the end of each one to the next in the list, and the end of the last path to the start of the first. A trivial example should get the idea across: On the left are three paths – straight in this case for clarity, though curved works just as well. On the right is the result of creating a sacrificial path, adding the LPE to it, then adding each of the three paths. The result of the LPE was filled with orange, and had its stroke removed. It also automatically updates to match any changes that are made to the shapes of the original paths. Hopefully it’s pretty clear that this new shape is the result of drawing a path that follows each of its component parts, and joins their ends together with straight lines. Now that you understand the basic idea behind this effect, let’s go through a more detailed example by coloring Frankie. For clarity, I’ll start by changing the color and thickness of each path we’ll be adding to the LPE:
You may have noticed the purple scar on his face. Don’t worry, he hasn’t been in a fight. That line is the sacrificial path that the LPE will be added to, and it’ll disappear in just a moment. Selecting that path, and adding the Fill Between Many effect, results in this trivial UI: Now the hard work begins. We have to copy each of the source paths to the clipboard in order to add a link to it in this dialog using the button at the bottom left. Common sense would suggest that you could select all the paths and add them as a single operation, but, unfortunately, common sense would be wrong in this case. Instead, you have to add them one-by-one. To make matters worse, each time you select a path to copy, the sacrificial path becomes de-selected, so the UI above vanishes. You then need to re-select the sacrificial path before you can add the copied link. It’s not difficult, but it is time consuming. So, to add our first path (the top left of the face), here are the steps: 1) Create a sacrificial path, if you haven’t already done so, and add the LPE to it. 2) Select the first path to add and copy it to the clipboard. 3) Re-select the sacrificial path. 4) Click the button in the bottom left of the LPE dialog to add the link. Do all that correctly and you’ll end up with something like this.
There are a few important things to note at this stage. First you can see that the sacrificial path has disappeared, replaced with the output of the LPE. This takes the same shape as the attached path, but with the ends connected. It also adopts the style of the sacrificial path. If your first path is straight, it can be easy to lose the LPE output on top of it, so I strongly recommend using a contrasting style for your sacrificial path for this stage of the process. You’ll also notice that the path is listed in the LPE dialog, as “path918” in this instance. That’s fine for shapes with only a handful of paths, but you can quickly lose track of which is which as the complexity grows. This name is taken from the path’s label, which can be set via the Object Properties dialog on the object’s context menu. As will become clear, you may need to know which path is which, so setting labels can make life a lot easier – albeit at the expense of more work initially. Be aware that the list in the LPE dialog doesn’t update dynamically, so you have to set up the labels first. Repeating steps 2-4 for a few more paths gets us to this stage:
Things were going quite well, with the new path taking on the outline of Frankie’s head, right up until the point where I added the ear. When this LPE connects between the ends of paths it doesn’t join to the closest end, but rather from the end of one path to the start of the next. In this case, the ear path had been created “in reverse”, with the start at the bottom and the end at the top, resulting in the twist in the output that you can see in the image. Fortunately, there are a couple of easy solutions to this issue: you can simply reverse the direction of the source path using Path > Reverse or, better still in most cases, you leave the source path alone and reverse it within the LPE by checking the Reverse box in the effect dialog for the appropriate path. Now you can see why it’s useful to have proper names for your paths. Whilst we’re on the subject of editing the output path in this way, it’s worth noting that the dialog also has buttons for removing a selected path from the list (multi-selection is not allowed), and for moving the selected path up or down, thus changing the order in which the paths are joined to generate the output. Continuing to add the remaining paths, and reversing a few along the way, produces this result:
As you can see, the result isn’t perfect. The fact that the ends of the nose and mouth extend inside the outline results in a shape with crossed lines, and reversing these paths only makes things worse. Breaking the nose and mouth paths into smaller pieces would have allowed me to produce the desired result but, once filled, this shape only actually leaves a small gap at the end of the mouth that can be visually patched up with another path, which I consider to be an acceptable compromise. So now I can fill the resultant path, lose its outline, send it to the back, and add in a small patch to cover the hole. And revert the original paths back to thinner black lines as well. It’s worth pausing at this point to really appreciate what we’ve just achieved. Although the end result appears to be similar to that produced by manually drawing an outline, or filling some gaps then using the Bucket Fill tool, there is one substantial difference: this shape is live. A change to Frankie’s nose, or the curve of his ear, is accompanied by an instant change in the fill shape. If we need to make more radical changes, it’s possible to add, remove and reverse paths accordingly. And ultimately that is the reason why this effect is now used by default when adding an LPE to a clone. Unlike the Clone Path effect, the Fill Between Many LPEs is more flexible, but still serves a similar purpose if it is used on a single path. Unfortunately, as discussed last time, the inability to move the resultant paths does make it useless for some applications, so there’s definitely still a place for Clone Path in your toolbox.
To finish Frankie in style, we can apply yet other LPEs to the original lines: Power Stroke is a classic option for cartoon-style pieces that lets us change the stroke width arbitrarily, but, most of the time, just a little tapering in and out of the width is all that’s required. For that, the new Taper Stroke effect is a far simpler option. Rather than fiddling around with additional node types on the canvas (the approach taken by the Power Stroke effect), this LPE simply lets you set the stroke width for the non-tapered part of the line, and two offsets representing the distance from each end that the stroke reaches that width. Set an offset to zero and that end gets a normal square cap with no tapering; otherwise larger numbers generally mean longer tapers. Now there are a couple of caveats here: firstly the taper can only progress as far as the first cusp node; secondly, I have no idea what sort of units are used for the offsets. In practice I tend to just roll my mouse wheel over each field and watch the path on the canvas to set a value that gives the artistic result I’m looking for. These values can also be set by switching to the Node tool, and moving the on-canvas handles, if you prefer to work that way.
The Taper Smoothing control effectively sets the shape of both tapers, but can give some odd results at extreme values. I tend to stick to about 0.5, which gives a reasonably linear taper that suits the comic style I’m working with. The Join Type and Mitre Limit controls have the same effect as those in the Fill and Stroke dialog, except that the LPE also offers an “Extrapolated” join type which can be better for some particularly tight angles. I’ll be honest, some of these new LPEs are still a little buggy at times. I found that to be the case particularly when trying to combine the Fill Between Many and Taper Stroke effects in order to complete my Frankie trace. In the end, I had to resort to some manually drawn paths, or “fixing” some of the LPEs by using Path > Object to Path, in order to get the results I expected. Still, even with those compromises, this take on Frankie is one of the best yet.