Outils pour utilisateurs

Outils du site


issue181:inkscape

Ceci est une ancienne révision du document !


Although it’s not yet out as I write, by the time you read this article Inkscape 1.2 will have been released. This version is a major update that contains a huge number of changes and additions, and will likely provide plenty of topics for this column for many months to come. But let’s not get ahead of ourselves – we haven’t even finished looking at all the new Live Path Effects (LPEs) that were added to 1.0 and 1.1 yet!

Corners (Fillet/Chamfer)

Consider two perpendicular lines meeting to form a 90° corner. Often that sharp transition from one line to the other is exactly what you want. But sometimes a design calls for something more gradual: an intermediate straight-line segment at 45°, or a rounded section that seamlessly joins the two lines. Creating such gradual corner transitions is known as chamfering or filleting, respectively, with the newly inserted path being referred to as the chamfer (for straight path segments) or fillet (for curved lines). Unsurprisingly, the “Corners (Fillet/Chamfer)” LPE is the tool to use when you want to quickly add such shapes to your paths.

As always, let’s take a look at an example of this effect in action. Of course that means we’ll need a suitable path to work on, such as this shape which has a selection of obtuse, acute and right angles so you can easily see how Inkscape applies the LPE in these different cases.

Adding the effect to a path like this probably won’t produce an immediately obvious result, but that’s just down to the values the parameters have by default. Let’s take a look at the UI and examine each of the parameters individually, as usual.

The Unit pop-up is pretty self-explanatory, though there is one omission that we’ll come back to shortly. The Method pop-up allows you to explicitly determine whether fillets are rendered as arcs or Bézier curves, should you care about that distinction. Most people won’t, and should probably just leave this as “Auto”.

It’s the Radius field that is the first really important one. While this is set to zero you won’t see any filleting or chamfering effect, so the first thing to do is to crank this up to a suitable value for the result you want. If you’re using a mouse with a scroll-wheel (which I contend is the best control device for serious Inkscape work), click in the field to focus it then roll the wheel to adjust the value in integer steps. By doing this you can watch the effect change the path on the canvas in real-time, making it easy to adjust the strength to the value that gives the right appearance. Here’s our test shape with a radius of 15px.

The filleting effect is obvious on the right-angled corners at the left, and completely rounds off the acute angles at the right. The obtuse angles at the top and bottom right, however, are barely rounded at all. This makes sense due to the radius being set to a specific value: as the two sides of the angle approach 180° so the tangent points get closer and closer, and the curving effect is less pronounced. This can be seen more clearly by adding circles with a radius of 15px to each corner of our shape, to demonstrate how the fillet shapes are constructed.

If you want a smoother transition in your obtuse angles there are several solutions. The first is simply not to use a radius defined in explicit units at all, but make it vary based on the geometry of the path around each corner. This is what the “Radius in %” checkbox is for. Enable this and… nothing happens. A common problem with this and other LPEs is that some controls don’t immediately trigger an update on the canvas. In this case the easiest option is to nudge the Radius value up by one, then back down by one, using the plus and minus buttons at the end of the field. With that refresh forced, our shape now looks like this.

Clearly the obtuse angles are a lot smoother now, though the acute ones have become sharper, with a smaller radius. This raises the obvious question as to what “Radius in %” actually means. Percentage of what? It’s clearly not the same thing being used for all the corners, so it can’t be “percentage of bounding box width” or anything like that. Is it based on a percentage of the segment length? The angle at which the lines meet? The price of Bitcoin? Who knows!? I certainly don’t, and the tooltips aren’t giving any insight.

One thing I do know, however, is that the percentage option tends to be more resilient to design changes. Consider what happens when you scale your shape up or down: if you’ve set a specific radius in pixels or millimetres, the LPE will change the output path in order to maintain that defined size. In the case of our example shape this causes the “prongs” to become longer or shorter. Conversely, when using the percentage option you’ll find that scaling the path results in no significant changes to its shape. For this reason alone, unless you have a specific requirement that demands a fixed value radius, I suggest enabling the “Radius in %” checkbox.

Remember that I said that there was an omission in the Units pop-up that I would come back to? It’s simply this: why isn’t there an entry for “%” in the pop-up, instead of also having this checkbox? With the UI as it stands, it would be very easy to misread the parameters as indicating a fixed radius rather than a percentage, by overlooking the checkbox. As often seems to be the case with Inkscape’s LPEs, some of the parameters and and their positions do rather leave me scratching my head.

If you switch to the Node tool (F2) while your path is selected, you’ll see a pair of handles for each node. On my setup they are rendered as particularly small shapes, so you may want to increase the size of the handles throughout the whole Inkscape UI via Edit > Preferences > Interface. These specific handles are referred to as “knots” in the Corners LPE interface. They can be hidden by enabling the “Hide knots” checkbox, so if you don’t see them when switching to the Node tool, double-check to see if that box is enabled. These are also, presumably, the knots referred to in the label for the “Use knots distance instead [of] radius” checkbox – though I’m not certain because the behaviour of that control is less than obvious, and I’m not even convinced that it’s needed at all!

Checking that box (and nudging the Radius control up and down) modifies the shape once again. The positions of the knots move, and with it the curvature of the various fillets change. The thing is, you can actually drag the knots on the canvas in order to manually adjust the curvature for each fillet – and this works regardless of the state of the checkbox. I’m therefore at a loss as to what this checkbox is meant to achieve, so my advice is to simply leave it un-ticked, enable the “Radius in %” option, and manually adjust any fillets you need to.

It’s worth reiterating the fact that you can change each pair of knots individually. This is the first LPE to support storing per-node data, allowing different parameters to apply to different nodes within the path. This allows you to not only set a different radius or knot position for each corner, but also to mix-and-match between fillets and chamfers, as we’ll see later, all with just a single instance of the LPE. Compare this with the need for multiple LPEs each with its own blacklist or whitelist that we had to use to achieve something similar with the Measure Segments LPE, and I’m sure you’ll agree that the new method is a lot more straightforward to use.

Now that you know how to set the fillet radius on a per-node basis, you should be able to reproduce a pair of corners like these.

The top corner has a radius of zero, whereas the bottom corner’s radius is set to a much larger value simply by dragging one of the knots. It’s important to note the distinction between a zero radius node and one with a radius greater than zero as we take a look at the next two checkboxes in this LPE.

Here we have another pair of controls that are, in my opinion, practically useless. When we first began to apply fillets to this shape we increased the radius value and all the corners responded. Suppose, however, you’ve manually reset some of them to a radius of zero, and don’t want them to be affected by further changes. Unchecking the first box will mean that any changes you make in the LPE interface won’t affect those zero radius corners. In other words, if you want to keep your square corners square while adjusting all the others then uncheck this box.

The problem is what happens if you do want to adjust the square corners as well. Obviously you need to have this box checked, but that’s not really enough. As soon as you nudge the radius parameter up, those corners cease to be zero radius corners, so that checkbox no longer applies. This is where the second checkbox comes in: with this checked your changes also affect non-zero corners. Unchecking this would mean that your changes only affect the zero radius corners, which is almost never what you want – especially if it’s the radius parameter you’re playing around with. My advice, therefore, is to always leave these two checkboxes ticked. If you want to protect your sharp corners from changes, there’s a better way to achieve that which I’ll describe shortly.

Personally I think these two parameters should be collapsed into a single checkbox labelled “Protect zero radius corners”. When checked, the tight corners would be left unmolested by any changes to the parameters, but in its unchecked state your changes would affect all of the corners, as usual. In reality even this probably isn’t required, given the next checkbox in this dialog.

What if you don’t want to affect all of the corners, but perhaps the ones you want left untouched already have a non-zero radius? We’ve seen that the radius can be adjusted on a per-corner basis using the knots on the canvas, but what about the other parameters? The checkbox labelled “Change only selected nodes” is the option for you. With this enabled any changes you make to the LPE’s parameters will only be applied to corners that you’ve selected. This renders the previous checkboxes rather redundant. If you want to modify all the corners then just ensure that all of them are selected. Want to leave the zero radius ones untouched? Just make sure they’re not selected (but the other corners are) when you make your modifications. Importantly, however, you can also choose any subset of corners to adjust at once, regardless of their current radius.

In the unlikely event that you’re not familiar with selecting nodes in Inkscape, here’s a quick recap. First, you need to be using the Node tool (F2). You can click on individual corner nodes to select them, or on a path segment to select the nodes at either end. You can also drag the mouse over multiple nodes to select them (a so-called “marquee” or “rubber band” selection). Holding the Shift key will let you add nodes to, or remove nodes from, an existing selection. Most usefully, Ctrl-A will select all the nodes in the path, providing a quick way to alter all the nodes at once. The Escape key will deselect them all, should you wish to start again with a fresh selection. If you have difficulty seeing the path nodes due to the placement of the LPE’s knots, don’t forget that you can check the “Hide knots” control while you make your selection. With those basics at your fingertips you’ll soon find that it’s quick and easy to select exactly which corners should be affected by your LPE changes at any time, without having to consider their existing radius or other attributes.

Now we know how to apply parameter changes to specific nodes, but so far all the examples we’ve looked at have been fillets. What about chamfers? It doesn’t take a genius to figure out that’s what the buttons at the bottom of the LPE parameters are for.

Depending on the state of the “Change only selected nodes” checkbox, clicking on one of these buttons will change either the selected nodes, or all nodes, to the appropriate type of join. For chamfers and inverse chamfers the “Chamfer steps” parameter also plays its part, dictating how many straight line segments should be used to make up the connecting shape. Note that when this is set to 1 there is no visual difference between a chamfer and inverse chamfer. Here’s an example of how the different types of join are rendered with our test shape.

In conclusion, I think this is a very capable and useful LPE that is only let down a little by offering too many non-intuitive options in the UI which don’t seem to really provide much benefit. My advice is to enable the “Radius in %” checkbox, both the “Apply changes…” checkboxes, and the “Change only selected nodes” checkbox. That will give you an LPE that behaves predictably when you resize your objects, and which allows you to trivially alter all of the nodes, or just a subset of them, depending on what you select on the canvas.

issue181/inkscape.1653673545.txt.gz · Dernière modification : 2022/05/27 19:45 de d52fr