Ceci est une ancienne révision du document !
This month, we'll conclude our tour of LPEs by looking at the two new additions to Inkscape 0.91: Power Stroke and Clone Original Path. One limitation artists often find with Inkscape is its inability to produce variable thickness strokes. There are ways to fake it, which pretty much all rely on the “stroke” actually being a filled path in its own right. That inevitably leads to the follow-up problem of how to fill a shape drawn using such fake strokes. These two LPEs are Inkscape's answer to those problems.
Ce mois-ci, nous allons conclure notre tour des LPE en étudiant les deux nouveautés d'Inkscape 0.91 : Contour dynamique et Cloner le chemin original. Une des limitations que les artistes trouvent à Inkscape est son incapacité à produire des contours à épaisseur variable. Il y a des façons de le simuler, qui s'appuie beaucoup sur un « contour » qui est à proprement parler un chemin rempli à part entière. Ceci conduit inévitablement au problème qui en découle : comment remplir une forme tracé avec de tels faux contours. Ces deux LPE apportent une réponse à ces problèmes.
Power Stroke This effect lets you vary the width of your path by adjusting “stroke knots” along its length. For cases where you might otherwise use PAP to provide some variability to the stroke width, Power Stroke will often achieve a similar effect but with more flexibility. Let's start with the simple example of applying this LPE to a straight line: The top line, in red, represents the original skeleton path. On applying the LPE the first result you'll see is that the skeleton is replaced by a closed path that encloses the original shape. The closed path takes on the attributes of the original skeleton path, so, in this case, it has a red stroke and a transparent fill, resulting in the second shape in the image. Usually you'll want your Power Stroke to be filled with no outline, so in the third image I've changed the style to a black fill with no stroke. You would be forgiven for thinking that we've just gone through a convoluted way to produce a slightly thicker black line with rounded end caps, but the fourth image shows the real secret to Power Stroke: this is the same as the third object, but with the Node tool selected (F2), revealing not only the normal start and end nodes, but three additional pink or purple colored handles (the “stroke knots”) sitting on the periphery of the shape.
Contour dynamique
Cet effet vous permet de faire varier la largeur de votre chemin en ajustant des « points de décalage » le long de sa longueur. Dans les cas où vous auriez utilisé à la place l'effet Motif suivant un chemin pour donner de la variabilité à votre largeur de trait, le Contour dynamique réalise un effet similaire mais avec plus de flexibilité. Commençons avec un simple exemple en appliquant ce LPE à une ligne droite : La ligne du haut, en rouge, représente le chemin squelette d'origine. A l'application de ce LPE, le premier résultat que vous verrez est le squelette est remplacé par un chemin fermé qui enferme la forme originale. Le chemin fermé prend les attributs de la forme squelette d'origine ; dans le cas-ci, elle a un trait rouge et un remplissage transparent, donnant ainsi la deuxième forme de l'image. Habituellement, vous voudrez que votre Contour dynamique soit rempli sans avoir de bord ; ainsi, dans la troisième image, j'ai changé le style pour un remplissage noir sans trait. Vous seriez pardonner de penser que nous avons juste trouver une façon détournée de produire une ligne noire un peu plus épaisse avec des embouts arrondis., mais la quatrième image montre le vrai secret du Contour dynamique : c'est le même que le troisième objet, mais avec l'outil Nœuds sélectionné (F2), révélant non seulement les nœuds de départ et d'arrivée, mais aussi trois poignées additionnelles roses et violettes (les « points de décalage ») situés à la périphérie de la forme.
The effect automatically adds these nodes at the start and end of the path, and somewhere towards the middle. Using the Node tool they can be dragged perpendicularly to the skeleton path to set the stroke width at that point, but can also be dragged along the path to change the location at which the thickness changes. Taking the previous example; dragging the handles around a little lets us easily produce this result: As you can see, the thickness of the line is set by each of the nodes, with sections in-between ramping linearly from one node to the next. Looking at the LPE's UI you'll notice a pop-up menu for the Interpolator Type. This is what is producing the linear change; pick another value to alter the way in which the width of the path is modified from one node to the next. You can't fail to have noticed the rounded ends to the line. They weren't present on the original skeleton path, so where did they come from? A quick scan of the effect UI will show that several of the controls from the Stroke Style tab of the Fill and Stroke dialog are replicated as part of the LPE. From there, you can set start and end caps (the source of the rounded ends in this case), as well as the join type and miter limit for paths with angles in them. These all operate in a similar way to the equivalent controls in the Style and Stroke dialog, except that the LPE offers more options.
L'effet ajoute automatiquement ces nœuds au début et à la fin du chemin, et quelque part vers le milieu. En utilisant l'outil Nœuds, ils peuvent être tirés perpendiculairement au chemin squelette pour régler l'épaisseur du trait à cet endroit, mais ils peuvent être aussi déplacés le long du chemin pour modifier l'endroit où l'épaisseur change. Prenons l'exemple précédent ; en déplaçant un peu les poignées, nous produisons facilement ce résultat : Comme vous pouvez le voir, l'épaisseur de la ligne est réglée par chacun de nœuds, avec les sections intermédiaires qui croissent linéairement de l'un à l'autre. En regardant l'interface utilisateur de ce LPE, vous noterez un menu déroulant pour le Type d'interpolateur. C'est ce qui détermine la modification linéaire ; prenez un autre valeur et la façon dont la largeur évolue d'un nœud à l'autre est modifiée.
Vous ne pouvez pas avoir omis de noter les terminaisons arrondies de la ligne. Elles n'étaient présentes dans le chemin squelette d'origine ; mais d'où viennent-t-elles ? Un coup d’œil rapide sur l'interface de l'effet montrera que plusieurs contrôles de l'onglet Style de trait du dialogue Remplissage et contour sont répliqués dans ce LPE. De puis celui-ci, vous pouvez régler les terminaisons de début et de fin (la source des terminaisons arrondies dans ce cas), aussi bien que le type de raccord et la limite de raccord pour les chemins comportant des angles. Ils opèrent tous de la même manière que dans le dialogue Remplissage et contour, sauf que le LPE offre plus d'options.
With three handles for manipulating the Power Stroke, you can already produce some useful results, but the real power comes when you add even more handles. Unfortunately, this is done via a rather clunky approach that can sometimes be a bit unstable, particularly on more complex paths. The first step is to select your path and switch to the Node tool, so that the handles are visible. Next you have to hold the Control-key whilst clicking on a handle. This will create a second handle, directly on top of the first one, which you can then drag to its new location. If you do experience problems, such as the handle becoming detached from the path and having no effect, undo your changes, and then try again, duplicating a different handle instead. Our simple line with three handles quickly turns into something more bumpy once a few more are added: To delete a handle you have to click on it whilst holding the Control and Alt keys. There's no way to select multiple handles in order to move or delete several at a time. You've probably noticed that you can drag handles past one another with ease – that's thanks to the Sort Points checkbox in the effect's UI. Uncheck that for a different behaviour in which the shape is drawn from handle to handle based on their original ordering rather than their final position along the line. It's useful for some effects, but generally it's better to leave the box checked. With all that background out of the way, let's take a look at this LPE when used on a more complex path. It's time to return to my efforts to manually trace “Frankie” (see parts 16-21 for my previous attempts at this): The parts of the path that stretch inside the outline – the mouth, nose and ears – were particularly fiddly to get right. In practice it's probably faster to just use a simple path for the outline, then draw those parts separately. But you can clearly see how the LPE allows the path to thicken and thin to give more of a dynamic feel to the character than a simple fixed width line could achieve.
Clone Original Path Our final LPE follows on directly from those efforts to manually trace Frankie. One problem with the Power Stroke or PAP effects is that they draw strokes as filled paths, so setting a fill color on them actually changes the color of the “stroke”, not the area inside it. To clarify, if I were to select the Power Stroke path in the Frankie example and set its fill color to red, the result would just be a red Power Stroke, not a black Power Stroke with a red fill inside the face area. Previously, I've shown you how to work around this limitation using the Bucket Fill tool or by manually drawing a second path that you can fill and then send below the outline. Neither of these solutions is ideal, and both can take a lot of manual tweaking to get right. Wouldn't it be easier if you could just fill the original skeleton path with a different color, without affecting the fill that's used for the Power Stroke? Effectively that's what the Clone Original Path effect lets you do. There are a few ways to use this effect, but we'll start with the long-winded method, to give you a better understanding of what's happening. First you'll need a sacrificial skeleton. Don't worry, we're not heading into Voodoo territory, but rather you'll need a skeleton path that will completely disappear once you use the LPE. Its only purpose is to serve as an object to apply the effect to, so a simple straight line will suffice. Select the path and add the Clone Original Path LPE to it, then gasp in amazement as… nothing happens. There are a few more steps to go through before the effect has any visible impact.
Having applied the effect, you next need to select your Power Stroked path, then copy it to the clipboard. Re-select the sacrificial skeleton and use the first button in the effect's UI to paste the path from the clipboard. Your skeleton will disappear, and it will seem that the Power Stroked path has been selected instead. Appearances can be deceptive, however – use the arrow keys to move the selected item and you'll realise that you've actually got a clone of the skeleton path used in the Power Stroke. Fill it with a color and send it back in the stack and you've achieved in seconds what would have taken several minutes to do manually. You can fill your clone with a gradient or pattern, if you prefer, or change the stroke style. In principle you can also apply other LPEs – although they don't always chain as well as you might hope. And because it's a clone, you can change the shape of the original skeleton path (the one used for the Power Stroke), and your filled version will automatically update to match it – comic creators rejoice! No more does every tweak to an outline have to entail a corresponding manual update to the fill shape! With the cloned path selected, the second button in the UI will select the original – though the classic Shift-D shortcut or Edit > Clone > Select Original menu entry both also work. Cloning a path in this way isn't restricted to the Power Stroke LPE, so if you need a copy of the skeleton that you used with any other effect, just follow the same steps.
You can streamline the creation process a little by copying the Power Stroke path to the clipboard before you create your sacrificial skeleton rather than afterwards. But the Inkscape developers are nicer than that, and have added an option that will automatically create an infinitesimally small sacrificial path that has just a single node, add the Clone Original Path effect to it, and connect it to your original path, all from a single menu entry. Just select the Power Stroked path, then use Edit > Clone > Clone Original Path (LPE), and then set the fill and stroke you want for your clone. The only way it could be any faster is if there was a keyboard shortcut for the menu option. But wait! Inkscape 0.91 does include a keyboard shortcut editor. Click on the Edit > Preferences menu item, then in the dialog, drill down to Interface > Keyboard Shortcuts. Expand the Edit section of the pane on the right and you should find Clone Original Path (LPE) in the list. Click in the Shortcut column for that entry, then press the new keyboard shortcut you wish to use (I went for CTRL-ALT-SHIFT-D to keep it in line with the other cloning shortcuts).
There's one final trick up the sleeve of this LPE. Back in part 30, I introduced the use of “unset” fills and strokes to allow different clones to have different styles and colors. This effect offers another way to achieve a similar result. You can either select an original object that you wish to clone, and then use the Edit > Clone > Clone Original Path (LPE) menu option, or you can select a clone that you've already created and just click the “+” button in the Live Path Effects dialog. Now you can change the color and style of your clone with impunity, safe in the knowledge that changes to the original shape will still be reflected. For obvious reasons this works only where the parent object is a path or can be trivially converted into one – so it does work with stars, spirals and even text objects, but doesn't work with groups or bitmap images. It's worth noting that this approach does result in a second copy of the path data being stored in the clone's XML (see part 43 for details), unlike a normal clone which just hold a reference to the original. This means that not only is the file size a little larger, but any edits made to the original outside of Inkscape won't be reflected in the LPE clone, whereas they would with a “real” SVG clone. One advantage of this approach, however, is that you don't have to unset the fill and stroke on the original, so you won't be left with a black shape that you might have to hide under another object or by placing it off the side of the page.
Conclusion The Power Stroke and Clone Original Path LPEs are worthy additions to Inkscape 0.91. For a comic artist they could be reason enough to upgrade from an older version. Using little more than these two effects produced the best manual trace of Frankie so far: We've now reached the end of our tour of LPEs. There are more being added to the development builds all the time, so do check out the dialog with each future version of Inkscape. They represent perhaps the most common way in which the developers have broken through the limitations of the SVG format in order to add functionality that far exceeds what any normal SVG editor could offer. It's true that the UI for some is confusing, they're sometimes a little unstable, and that they often don't chain as well as they should, but it's well worth spending some time to play around with them as they can open a path to drawing possibilities that would be impossible or, at least, impractical to produce any other way.