Outils pour utilisateurs

Outils du site


issue209:inkscape

Ceci est une ancienne révision du document !


As I write this, the third beta for Inkscape 1.4 has just been released, primarily fixing some Windows issues. I encourage any readers who are so inclined to download the beta versions, try them out, and report any issues they find. If you’re not a programmer, it’s perhaps one of the best ways to contribute back to Open Source software, helping to ensure that the quality of the final release is as high as possible.

Despite version 1.4 looming large on the horizon, there are still a couple of features from 1.3 for me to cover. This month, I’m going to look at some new on-canvas controls that have been added. As has often happened with Inkscape, these controls don’t actually provide any new functionality, but they do expose existing features in the UI in a way that might make them more discoverable, or easier to access, when you need them.

The first of these is on-canvas editing of corners for paths and other shapes. In other words, the ability to turn sharp corners into fillets (curved corners) and chamfers (angled corners) directly on the canvas. This brings Inkscape somewhat up to parity with other applications which often offer such functionality, but there’s a good reason why it wasn’t present previously: the SVG file format.

SVG doesn’t support filleted or chamfered corners, other than through them being drawn as real path segments. Inkscape often gets around such limitations through the use of Live Path Effects (LPEs). These are a means by which Inkscape can store the ‘original’ path or object data in its own custom fields, while also creating a version of the shape using ‘normal’ SVG paths, so that other applications can still render the result. Those applications won’t have the same editing capabilities as Inkscape, but at least the end result can still be displayed and used, even if some of the Inkscape-specific editing options are lost.

LPEs have been exposed as on-canvas tools before: if you draw a Spiro path using the Pen tool (aka the Bézier tool) or the Pencil tool, Inkscape automatically adds the Spiro LPE to produce the effect. Creating a BSpline similarly adds the BSpline LPE, while selecting a shape for the path (e.g. Ellipse or Triangle In) adds the Pattern Along Path or Power Stroke LPE. These effects stack, so drawing a Spiro path with the Triangle Out shape adds both the Spiro and Power Stroke LPEs.

This approach does a good job of hiding the complexity of the main LPE dialog, while still allowing more advanced users to edit the LPE parameters directly, or flatten the path to remove the overhead of the LPE calculations. In the same manner, the new on-canvas editing of corners exposes the Corners LPE in a more intuitive way, while still allowing access to the LPE parameters if necessary.

To begin, let’s use this feature on a simple path drawn using the Bézier tool. Here’s how my semi-random shape looks with the Node tool selected (F2).

With the Node tool still selected, we can add the Corners LPE simply by clicking a button in the tool control bar (outlined in red in this image). Note that clicking it a second time removes the LPE, losing any changes you’ve made, though Edit > Undo (Ctrl-Z) should save you if you click it by mistake.

Note that the button doesn’t appear as a visible toggle: it doesn’t change state when the LPE is applied. The most obvious way to tell, however, is just to take a look at your path, which will have gained a new handle by each node (the small round circles in this image).

Drag any of those handles to set the fillet radius for the corner. As you do so, the single circular handle will be replaced by two triangular handles, allowing further tweaks to the radius to be made from either side of the underlying node. Dragging a few of these handles makes it very easy to turn our sharp, spiky shape into a mixture of spikes and curves.

Holding Control while clicking on any of these handles will cycle the corresponding node through the various types of corner that the LPE offers: fillet, inverse fillet, chamfer and inverse chamfer. The latter two appear identical at this point, just cutting off the corner with a straight line, but we’ll do something more interesting with them in a moment. For now, here’s what the same corner looks like in each mode.

At this point it’s worth noting a small bug when using anything other than a normal corner or fillet. If you copy and paste, or duplicate your shape, the LPE sometimes loses track of the type of corner you had selected, so inverse fillets, or either type of chamfer, are converted to normal fillets in the new object. The behaviour is a little erratic so this is just something to keep an eye out for, though you may get lucky and never be affected by it.

For setting the position of the corner handles there’s a useful trick that can save a lot of time with complex paths. If you have any nodes selected, their handles will also be modified to match the same relative position of the one you’ve dragged (whether the drag handle is on a selected node or not). This makes for a quick way to set all corner handles to the same relative position by pressing Ctrl-A to select all the nodes before dragging. Unfortunately, Ctrl-Clicking to set the corner type still only works on the clicked handle, regardless of any selected nodes. It is possible to set the type for all nodes, or all selected nodes, at once via the main LPE controls. See part 121 of this series (FCM #181) for more details about the controls and parameters available via the LPE dialog.

Shift-Clicking on a handle opens a small dialog that allows you to set various parameters for that specific corner:

This is an alternative way to set the corner type, or to accurately position the handle (labelled as ‘Knot distance’ in the dialog), but it also offers one other field to set the ‘Chamfer subdivisions’. Increasing this beyond 1 reveals the difference between a chamfer and an inverse chamfer. This image shows each type of corner, with 1, 2 and 3 subdivisions.

So far we’ve looked at using this feature on paths, but it also works on 2D shapes. Squares, rectangles, and the shapes created with the Star/Polygon tool, seem like obvious candidates, due to their sharp corners, but you might be surprised to find that this feature can also be useful on circles and spirals. This image shows a spiral, rectangle, star and circle, with the corners LPE applied and edited on-canvas to give you an idea of the sort of effects you can now easily achieve.

As well as the on-canvas editing of corners, Inkscape 1.3 also introduced some on-canvas handles for editing blurs. You may already be aware that blurs in Inkscape are implemented using SVG’s Gaussian Blur filter primitive and can, of course, be added via the Filter Editor dialog. This is a rather tricky part of the UI for beginners (and many experts) to understand, but because blurring an object is a pretty common requirement, Inkscape has always offered a shortcut in the form of the slider at the bottom of the Fill & Stroke dialog.

The slider in this dialog is fine for most cases where you simply want the object to be blurred in all directions. But the UI in the Filter Editor actually splits the blur into separate controls for the amount of blur in the horizontal and vertical directions. Usually the little ‘chain’ button next to the controls links both sliders so that the values remain identical, giving the same effect as the slider in the Fill & Stroke dialog. But toggle that button and you can set each slider separately – ideal for ‘motion blur’ effects which only occur in one direction.

The new on-canvas UI provides the best of both options: separate controls for the horizontal and vertical blur, but with the ability to easily set both to the same value. The only tricky bit is getting the controls to appear in the first place!

This feature appears only when the Node tool (F2) is selected. But unlike the Corners LPE, there’s no button in the toolbar to make the handles appear. Instead they are only visible if the object you’re editing already has the blur effect applied. This does make the handles a little redundant, in my view, as you’ll have already had to interact with the Fill & Stroke slider, the Filter Editor, or one of the predefined blur filters, in order for the on-canvas controls to appear. They’re possibly useful for fine-tuning the blur in the context of the rest of your drawing, but it would be nice if there was a toolbar button to add and remove a simple blur filter in the same way as the Corners LPE can be toggled on and off.

Your first step, therefore, is probably to select your object and open the Fill & Stroke dialog. There are various ways to do this, from the Object menu or keyboard shortcut (Ctrl-Shift-F), through to my preferred method, which is just to click on the Fill or Stroke color swatches at the bottom left of the window, below the palette. Or you may be the sort of person who always has it open in a sidebar and just needs to make sure the right tab is active. Whichever approach you take, you then need to nudge the Blur slider up a little. I recommend just a single click on the ‘+’ button at the right,: that’s enough to add the effect, but not so much that it has a significant effect on Inkscape’s redraw speed.

Now switch to the Node tool, if it’s not already selected, and you should find that the object has an additional pair of circular handles, just outside the bounding box. In this screenshot, I’ve put my object over a black background to make the white handles stand out a little more:

The handles will always be perpendicular to each other, with one at the top and the other at the right for newly created objects. If you’ve rotated the object, however, they may not appear in this orientation. The handles give an indication of the direction that the blur will take (if you don’t have a uniform blur in all directions), so can act as a flag that you might not be blurring in the direction you want to! A quick tip in that case is to remove the blur from the object itself (set it to zero in the Fill & Stroke dialog), then group the rotated object – it’s fine for it to be in a group of its own, with nothing else in it. If you add a blur to the group, you’ll now find that the blur is back to the default orientation, while your object remains rotated. Another tip, if you do need to work with rotated blurs, is to remember that Inkscape can now rotate the canvas during editing. See part 98 of this series in FCM #158 for details.

With the handles visible, it’s rather obvious how you can adjust the blur on-canvas. Dragging either handle will adjust the blur in that direction. Hold the Control key at the same time to adjust both handles to the same value – you’ll usually want to do that unless you specifically require an asymmetric or motion blur effect.

You can also hold both Shift and Control to adjust the handles proportionally. That is, if the handles have different values then dragging one will cause the other to move by an amount that is proportional to the difference between them. In other words, use this if you have an asymmetric blur and want to preserve the overall direction while adjusting its strength. There is a big caveat to this feature, however: if the handle has a value of 0 when you start dragging then Inkscape’s maths can sometimes go awry, sending the other handle zooming off towards infinity and blurring the object so much that it might even disappear from view, replaced by a slight smudge on the canvas. The solution is to nudge the handle above zero first with no modifiers held before trying to drag it proportionally with Ctrl-Shift.

These new additions to on-canvas editing definitely improve the usability of Inkscape, especially in the case of the Corners LPE. One concern, however, is that Inkscape is stacking up ever more handles on the canvas, leading to potential confusion about what feature any given handle corresponds to. Just take a look at this image of my random shape from earlier, once I’ve added a pattern fill, changed the type of some of the nodes, and added a little blur. That’s too many handles for me to make sense of – and I know what each of them are for! Could we end up in a situation where each of these additions, intended to make the program more user-friendly, actually combine to scare new users away from the complexity they see on the canvas?

issue209/inkscape.1727540267.txt.gz · Dernière modification : 2024/09/28 18:17 de auntiee