Outils pour utilisateurs

Outils du site


issue178:inkscape

Ceci est une ancienne révision du document !


This month, I’ll be continuing to look at the new Live Path Effects (LPEs) that were added in Inkscape 1.0.x and 1.1.x. Ellipse from points If you’re a frequent user of LPEs, you may already be familiar with the “Ellipse by 5 points” effect (covered in part 69 of this series). As the name suggests, this draws an ellipse that passes through the first five nodes of a path. This new LPE does the same thing, and much, much more. In fact, the name really doesn’t do justice to the capabilities it offers, as it not only allows for the creation of ellipses, but also circles, arcs, and segments. Whereas the old LPE provides no parameters to control its output, this new one comes with quite a few, not all of which are enabled at the same time. Despite all these extra controls, however, the basic functionality is still pretty intuitive, and benefits hugely from applying any changes to the parameters or path shape interactively, making it fun to play around with all the different options. Your starting point will always be a path to which the LPE is applied, although this effect cares about only the positions of the nodes, not the shape of the path segments. For demonstration purposes, however, all my examples will use straight line segments, and I’ll show the original path as a red line with diamonds marking the nodes (courtesy of the “Clone original” and “Show handles” LPEs). The black lines are the output from the LPE. Let’s start with the simplest case: a two-node line using the “Auto ellipse” method.

In this case, the effect draws a circle using the two nodes in the path as points at either end of the circle’s diameter. Drag one of the nodes around, and the circle will scale and rotate accordingly. Let’s see what happens if our source path has three nodes, rather than two. Again we have a circle, but this time it circumscribes the triangle created by the three nodes. Once more, dragging the nodes around the page will give you a good idea of how the size and position of the circle relates to the node positions. With three nodes, some of the LPE parameters start to become useful to us. When enabled, the “Arc” checkbox draws an arc connecting the three nodes, rather than closing the whole circle. Enabling the “Other arc side” checkbox instead draws the “other” arc which forms the remainder of the original circle. “Slice arc” can be used with either type of arc to render it as a segment (i.e. a pie-chart “slice”) rather than an arc, by adding straight path segments that join the end nodes to the center of the circle.

With three nodes, more of the options in the “Method” pop-up menu will also work. The first two (“Auto ellipse” and “Force circle”) just produce the result we’ve already seen. “Isometric circle” treats the path as having straight line segments, even if it hasn’t, and uses the first two segments to define the edges of an isometric rectangle into which it fits an ellipse that appears as if a circle is rendered in that isometric projection. That sounds complex, but if you do much work with isometric or oblique projections, you’ll know exactly what this is for: in short, draw your path with suitable angles (e.g. 120° for isometric, 135° for oblique), and it will render “circles” that are appropriately distorted for the projection. The last two options in the pop-up are thankfully easier to describe: “Steiner ellipse” draws an ellipse that circumscribes the triangle created by the three nodes, while “Steiner inellipse” draws one that inscribes it. The image below shows the “Isometric circle” output, followed by the two ellipses, for the same path that I used earlier. Adding a fourth node to our path is required for the remaining entry in the pop-up: “Perspective circle”. This treats your four nodes as defining a square in a perspective view, and renders a “circle” that fits within that square. This is perhaps most clearly demonstrated using a closed path arranged to give a classic perspective view.

With the red lines removed, we can now also see what the remaining checkboxes do. The “Frame (isometric rectangle)” option will draw a bounding box around your circle or ellipse. By default this will be a rectangle, defined by the size of the major and minor axes of the ellipse, but you can use the “Axes rotation” spinbox to rotate the box around the ellipse, resulting in it becoming a parallelogram if the ellipse’s axes aren’t perfectly aligned with the global x and y axes. The “Axes” checkbox simply adds two lines, joining the mid-points of opposite sides of that bounding box in order to divide it into four equal areas. When the “Perspective circle” method is used, however, two alternative options become available. The “Perspective square” checkbox draws lines marking the “square” in perspective space that the “circle” is inscribing: essentially this draws a shape connecting all of the four nodes, even if the original path wasn’t a closed shape. The “Perspective axes” renders a pair of axes as they would appear in perspective, leading to a rather different outcome compared with the plain “Axes” option, especially if you rotate them using the spinbox.

The image below compares the two types of bounding box and axes when used on the same perspective circle. The left shows the result of the “Frame” and “Axes” checkboxes, while the images on the right show the corresponding “Perspective” versions. In both cases, the top image shows a rotation of 0° whereas the bottom image shows the result of increasing that value to 15°. To complete our tour of the checkboxes, the “Source path” option does what you might expect: it renders a copy of the original source path as part of the output. Due to the nature of LPEs, the source path is drawn in the same style as the ellipse (and axes and bounding box, if used), so if you want it to appear differently – as I did in my examples – you’ll need to use a “Clone original” or “Fill between many” LPE on a sacrificial path in order to render it as a different object for styling purposes. For general use, however, enabling this option can make it a lot easier to see what’s going on with your ellipse as you interactively tweak it, even if you then turn it off again once things are positioned correctly.

Lastly, if we add a fifth node to our path (with Method set to “Auto ellipse”) we end up with the same result as the old LPE: an ellipse that circumscribes the five nodes. If you want full control over your ellipse, this is probably a better option than either of the Steiner methods. There’s one final thing to mention regarding this LPE: the developers should be commended for putting the effort in to produce really useful tooltips. For example, if you can’t remember how many nodes your path needs for each different method, just hover your mouse over the pop-up for a useful reminder.

Offset The Offset LPE is pretty straightforward, and does what its name suggests. You may be familiar with the Path > Dynamic Offset feature which puts a handle on your path that you can drag to adjust the amount of offset, letting you create a shape that insets or outsets the original path. In doing so, it modifies the original, unlike the Path > Linked Offset feature that creates a second path which maintains a live linkage to the original. The LPE falls somewhere between these two: there is a live link to the original path shape, but that path is not included in the final output, so, despite this link, the result still leaves you with only one path rather than two. In practice, therefore, this LPE is closer to the Dynamic Offset feature, only with more options. Let’s look at an example. Here I’ve created a crescent shape by performing a Boolean difference operation between two circles. I’ve also adjusted the nodes of the bottom point very slightly in order to demonstrate some aspects of the LPE later on. In both these cases I’ve made a copy of the original shape in blue, but applied an offset to generate the red version. The left-hand image shows the result of the Path > Dynamic Offset feature, while the right-hand version shows the LPE equivalent. As you can see, they look identical.

If that was all there was to this LPE, it might still be useful as part of an effect chain, but not so much as an effect in its own right. But once we consider the various settings that it offers, it quickly becomes clear that the LPE offset is a far more powerful beast than what went before it. Let’s look at the available parameters. Dealing with these out of order, the “Unit” pop-up should be pretty self-explanatory, setting the type of units used for the “Offset” parameter which, in turn, is used to set the amount of offset that is applied to the path. It can be a positive value for an outset, or a negative value for an inset – but, in practice, it’s usually more effective to switch to the Node tool (F2) and drag the small, red, circular handle on the canvas, to adjust the offset by eye. The “Force update” checkbox determines whether or not the path updates live as you drag the handle, or updates only when you release the mouse button. Usually you should leave this enabled, unless you have a slow machine or a complex path which makes the updates jerk and stutter.

The “Join” pop-up has the most effect on the shape of the path. In the previous image it was deliberately set to “Rounded” to reproduce the effect of the Dynamic Offset feature, but here’s a demonstration of how each entry appears with this particular shape. It’s worth noting that the result you’ll see is extremely dependent on the shape of your source path. In particular, look at the difference between the two pointed corners in the extrapolated joins, after making only minor tweaks to the nodes of the bottom point. As this shows, tight corners are a particular issue and increasing the “Mitre limit” value will allow some corners to appear that would otherwise be cut off. In the previous examples, increasing this value to 10, for example, allows most of the shapes to extend to give far more pointed ends. The main exceptions to this rule are the Beveled and Rounded types, which don’t take the mitre limit into account. The best option is usually to try each join type, and adjust the mitre limit and/or the individual nodes to get the result you want.

The Extrapolated Arc join types are particularly interesting. These try to follow the curves of your path to form a more natural join, rather than just projecting straight lines as a mitre does. When working with curved paths, these are well worth trying. If, however, you really want to project the pointiest of mitred corners regardless of the mitre limit, choose any join type other than Beveled or Rounded, and check the “Force mitre” option. Finally, it’s worth noting that this LPE also works with open paths, whereas the Dynamic Offset feature automatically closes them when you try to use it. These two LPEs both offer features that are head-and-shoulders above the options that Inkscape provided previously, and the developers should be applauded for continuing to push the boundaries of what path effects are capable of.

issue178/inkscape.1645897544.txt.gz · Dernière modification : 2022/02/26 18:45 de d52fr