Ceci est une ancienne révision du document !
En cours de traduction, ailleurs
In parts 42 to 47 of this series, I described, in some detail, each of the “Live Path Effects” in Inkscape at the time, culminating with the new LPEs added in 0.91. Since then, the release of 0.92 has seen the addition of many new effects, so I’ll spend the next few articles introducing each of them. I will assume, however, that you’re already familiar with the idea of LPEs, as well as how to add and remove them. There are also a few user interface conventions that are common to many of the effects, which I’ll also assume familiarity with. If necessary, you might want to re-read the earlier parts of the series to remind yourself of the details.
To begin with, we’ll take a look at a few LPEs that are also exposed through other parts of the Inkscape interface – the “convenience” effects that are bound to toolbar buttons in the Pencil (Freehand) and Bézier tools. Both tools previously offered the ability to create either regular Bézier paths, or to use the “Spiro” algorithm to easily create smoothly curving shapes. To this roster has been added a third option: BSpline paths.
Like Spiro shapes, BSpline paths are also smooth, with seamless transitions from one segment to the next. The difference, to the end user, is that Spiro paths are made of circular arcs defined by points that lay on the path itself; when you use the Node tool to edit the path, you simply change the position of the ends of each segment. BSpline paths, on the other hand, are defined by points that “pull” the path in their direction, with handles to set the “weight” or strength of that pull. This allows for tight, asymmetric curves that aren’t possible with Spiro paths.
Despite initial expectations, the handles that set the weight of each node can’t simply be dragged around – you have to also hold down the Shift key, for reasons that presumably made sense to the developer. In this screenshot, you can see a circular path that’s had the BSpline LPE applied in order to distort it into an egg shape. The general shape is set by the square node handles, but moving the circular “weight” handles has allowed the top to become more pointed, and the bottom more rounded (for reference, the equivalent shape using a Spiro path required twice as many nodes).
If you implicitly add the BSpline LPE by enabling that mode in the Pencil or Bézier tools, you have extremely limited control over the effect. In the Pencil tool, the value of the smoothing field will have an impact on the number of nodes that are placed – set this too high and you’ll get very few nodes, with a BSpline that doesn’t really reflect what you’ve drawn. In the Bézier tool, the only choice you have is to either click to place a normal node, or Shift-click to place a cusp, or corner node. The latter has a weight of zero, allowing for sharp transitions in your otherwise smooth path. If, however, you explicitly add the BSpline LPE to a path – or if you open the Live Path Effect dialog for a path that’s had it implicitly added – you’ll get a few options in the UI to let you tweak your shape.
As is often the case with the Path Effects dialog, the labelling and arrangement of the controls could definitely benefit from some improvement. For a start, the first thing you need to interact with is the last section of the dialog – the three checkboxes at the bottom. These dictate which of your nodes will be affected by changes to the upper half, and failing to set these correctly can result in too many, or too few, of your nodes being changed.
If the first checkbox is selected, any changes will affect only nodes with a weight of 0%. A better way of saying this is that the changes will affect only cusp nodes. The second checkbox does the same but for non-cusp nodes. Checking both allows changes to all nodes; checking neither will stop your changes affecting anything at all. The third checkbox further limits changes to only those nodes that are selected. The effects are cumulative, so if the just the first and third boxes are ticked, your changes will affect only the selected cusp nodes, and will not affect any non-cusp nodes, even if they’re also selected.
Moving to the top half, the Default Weight button sets the nodes to a weight of 33.333%. In other words, it positions the node handles a third of the way from one node to the next. Make Cusp, as you might imagine, turns the nodes into cusp nodes. It obviously makes sense to use this only if the second checkbox is also ticked.
Change Weight % lets you adjust the weight of all the targeted nodes. It should probably be labelled “Set Weight”, as putting a value in here sets an absolute value, not a relative one. For example, putting 25 in will set the handles to a quarter of the distance between the node and its neighbours – it won’t adjust their existing positions by 25%.
There is a convenience feature when changing the positions of the handles interactively on the canvas: if you hold down Ctrl rather than Shift, you can set the handles to pre-set positions. By default, these are at 0% (cusp node), 33%, 66% and 100%. Given that the two extremes are always possible, the “Steps with CTRL” option lets you define how many intermediate steps are available. Set this to 3, for example, to get steps at 25%, 50% and 75%. As for the “Helper size” control, your guess is as good as mine! As far as I can tell, it simply draws some circles on your path of the specified size. How these are meant to help you, I don’t know.
In practical terms, the controls available through the LPE dialog are of questionable benefit. For artistic purposes, you’re more likely to just adjust the node positions and weight handles on the canvas until your path is visually of the right shape. Personally, I find the BSpline option on the Pencil tool to be of little use, as it’s tricky to get the smoothing to just the right balance between too little effect and too much. On the Bézier tool, however, it makes much more sense. You can click-click-click to define the shape of your object, and an outline of the BSpline path is shown interactively as you do so, letting you more clearly see what the result will look like when you finish. With 0.92, this interactivity also extends to the Spiro option on the Bézier tool, which makes this mode much easier to work with too.
The Pencil tool has acquired another LPE shortcut, which is potentially far more useful: Smoothing. When drawing with the Pencil tool, Inkscape will tend to create lots of nodes, faithfully reproducing every jitter and bump your hand makes as you move the mouse or stylus around. Smoothing attempts to compensate for this by averaging out your movements to create a smoother – arguably more “vectorish” – path. By adjusting the amount of smoothing applied, you can find the right trade-off between faithful reproduction and oversimplification.
The trouble with this process in the past was that smoothing was applied only at the point of recording your movements. You would set the smoothing control and Inkscape would average your movements as you went along, completely replacing the original position data with its own calculated equivalents. If you set the smoothing control too high, there was no way to reduce it afterwards and regain some of your finer details.
Looking back to the toolbar image at the start of this article, you can see the smoothing slider after the BSpline button (note to the Inkscape developers: make this control a bit wider, and you could populate it with something more useful than “Smoo…”). Immediately after that is a new button that toggles between the previous smoothing method, and the new LPE-based approach. If the LPE Smoothing button is selected, an additional new button appears besides it, as shown in the screenshot, which looks like a pair of wonky spectacles.
With the LPE Smoothing button toggled off, the Pencil tool will behave as it always has (see part 18 of this series for a little more detail). In this mode, you set a smoothing value, then draw something and see it converted into a simplified version of your original path. Select it and check the status bar to see how many nodes it has: high levels of smoothing can produce paths with drastically reduced numbers. With the path selected, switch back to the Pencil tool and try modifying the smoothing value. You should see no change to your path, or the number of nodes it has – all you’re doing is changing the smoothness value that will be used for the next path you draw.
Now toggle the LPE button on, and repeat the exercise. As you draw, you’ll see the original rough path, which then gets converted into a smoother version when you finish. Switch to the selection tool to check the number of nodes; again you’ll see a low number, but this time it also says “path effect: Simplify”, confirming that an LPE is in play. Here’s the big difference though: return to the Pencil tool and change the smoothness value. Your path should move from rough to smooth and back in real-time as you drag the slider around. Did you set the value too high or low when drawing the path? Just change the value afterwards!
To achieve this feat, Inkscape actually stores the original path, as though you had set smoothness to its lowest value. It then automatically applies the Simplify LPE, which does the same job as the Path > Simplify option, except that it does so as a live (and reversible) process.
There’s no doubt that the added flexibility of the Simplify LPE can be a huge advantage, so why would you ever want to turn it off? Well, as you might expect, such flexibility comes with a cost: in this case, it’s the cost of processing the LPE every time the path is rendered or changed. For one or two paths it might not have much of an impact, but, as with filters, too many live effects can rapidly drag your PC to a crawl. There is, however, a compromise in the form of the wonky glasses button. Clicking this will “flatten” the path by replacing the original shape with the output from the Simplify LPE, then removing the effect completely. This fixes the smoothness so you can no longer alter it by adjusting the slider – but it also means that Inkscape no longer has to calculate it in real-time.
If you open the Live Path Effects dialog, you’ll find that the Simplify LPE has a few controls to let you tweak the effect.
The Steps value sets the number of times that the Simplify algorithm should be applied – it’s the live equivalent of selecting Path > Simplify multiple times in succession. The bewilderingly named ‘Roughly Threshold’ parameter is the value that gets changed when you move the smoothness slider in the Pencil tool’s controls. This sets the strength of each pass of the algorithm and is what primarily defines the amount of simplification that is performed. Unfortunately, it seems to operate over a peculiar range of numbers: it is rather non-linear, with the most effect occurring at really rather small values. Fractions down to hundredths or thousandths of a unit aren’t uncommon. This control would probably have been better as a slider, mirroring the smoothness control in the Pencil tool, and operating over a normalized range of values. As it stands, I recommend starting as low as you can (enter zero and Inkscape will set it to the smallest allowed value), then use your mouse-wheel over the control to adjust the value until you have the appearance you want.
The Smooth Angles control allows you to affect how the algorithm deals with cusp nodes. With this set at its maximum of 360, all nodes will be smoothed. By reducing this value, you can set a cut-off for the angle between the handles of a cusp node, above which the algorithm won’t change the node. Consider a right-angle in your path: by setting this value to 80, the right-angled cusp (where the handles make an angle of 90°) won’t be smoothed, and you’ll have a nice sharp corner. Set it to 90 or more, however, and the right-angle will be smoothed, softening your shape. If you have tight angles in your path that you want to keep sharp, play with this parameter. It doesn’t seem to work so well on acute angles, though.
Next is another Helper Size control. As with the one in the BSpline UI, this causes circles (and in this case also squares) to be drawn on the path – but I still have no idea how that’s supposed to help you! The Just Coalesce button below it is also a mystery to me: it seems to have some effect on the shape of the final path, but the details of what it’s doing are less than obvious.
That just leaves the Paths Separately button – for which I’m going to hazard a guess as to the function, based purely on the name. The Simplify LPE may be applied to a complex path – one made up of multiple sub-paths – or even to a group of path objects. Toggling this button on seems to apply the effect individually to each sub-path, or each path in a group. Leaving it off applies the effect to all of the paths or sub-paths as one. The distinction – and the effect it will generally have – is a subtle one, and probably not worth further consideration for most users.
This approach of exposing LPEs as buttons and options in other tools is, I think, a good one. It opens up these advanced capabilities to users who might otherwise be put off by the sometimes complex appearance of the Live Path Effects dialog, whilst still allowing advanced users access to the (sometimes bewildering) controls. But this article has barely touched on the LPEs added in 0.92, and the others aren’t so easily accessed. Next month, we’ll be taking a look at some of the other new effects, so if you do need a refresher on using LPEs, now’s the time to start reading those back issues of FCM that are sitting on your hard drive.