Outils pour utilisateurs

Outils du site


issue129:inkscape

Ceci est une ancienne révision du document !


This time, we’re going to move on to the final batch of new LPEs in 0.92, starting with one that’s both simple to use and potentially very useful: Perspective/Envelope. One significant limitation of SVG, from an artistic point of view, is that it allows for only affine transformations. These are transformations that preserve straight and parallel lines, limiting Inkscape to rotation, scaling and skewing. Non-affine transformations allow the source image to be more radically changed, introducing curves or distortions that let parallel lines converge. They would be a great addition to SVG – especially to allow text to be distorted into logos whilst retaining accessibility – but unfortunately it seems to be an enhancement that’s of little interest to the SVG Working Group. The Perspective/Envelope LPE provides a couple of non-affine transformations, though there’s still no accessibility gain to be had as text must be converted to paths first. In short, they allow you to distort a path (or group of paths) to follow the shape of a bounding quadrilateral. Changing the positions of the four corners of the bounding shape causes the path to be distorted accordingly.

The effect has a simple UI: the spinboxes at the bottom display the coordinates of the four handles and can largely be ignored as it’s easier to just move the handles on the canvas using the Node tool (F2). The two “mirror” checkboxes are self-explanatory – though there’s no point checking both at once as that will limit you to affine scaling that could be done with Inkscape’s usual transformation tools. The Overflow Perspective checkbox allows the algorithm that calculates perspective transformations to go beyond its usual bounds, allowing for some outlandish distortions that probably have little use in the real world. The “Type” popup lets you choose whether to use Envelope or Perspective deformation. You can freely switch between them to see which gives the best result for your particular image but, broadly speaking, Envelope is a simple distortion of your shape to fit the outline, whereas Perspective allows more complex distortions to provide a sense of depth. You can see the difference in this example – note the more constant thickness of the letters from left to right on the Envelope distortion (top) compared with the Perspective version.

For even more wild distortions, the “Lattice Deformation 2” LPE lets you distort your path (or group of paths) by adjusting the position of 25 nodes in a 5×5 grid. The UI for this is self explanatory – but don’t be tempted to expand the “Show Points” section unless you’ve got a very tall monitor! It presents a long list of fields holding the coordinates for all 25 nodes and, unfortunately, the LPE dialog doesn’t resize back down again when you close the list, leaving you wrestling with a dialog that’s too big for many screens. Here’s an example of the kind of transformation that is trivial to perform with this effect: The next couple of effects allow you to create via an LPE the sort of symmetry tricks that would have previously required manually setting up some mirrored or rotated clones – as described way back in part 29 of this series. Starting with the Mirror Symmetry effect, once again we have a simple UI that can produce some rather complex results.

This effect simply creates multiple copies of the input path, rotated around a common center. The “Number of copies” field defines the number of copies that are created (the original is lost in the process), whilst the “Starting” and “Rotation angle” fields are used to define the angle at which the first copy is placed, and the angle between each copy, respectively. The rotation angle is ignored if the “360° Copies” box is checked – in which case the copies are spaced evenly over a whole circle. In this image, you can see two stylised sun images – the former has the box checked to create a whole sun, whilst the latter uses a smaller rotation angle and different starting angle to produce a sunrise or sunset shape. The rotational center for the effect can be manually set using the corresponding fields or, more practically, by dragging the handle that appears in Node editing mode. There is also a second handle for adjusting the starting angle – though oddly there’s no third one for setting the rotation angle. The “Fuse paths” checkbox determines whether overlapping paths in the output are kept as separate sub-paths, or fused together into a composite shape. The difference can be seen in the following example, where the shapes in the left hand image are kept separate, whilst those on the right are fused:

If you do fuse the shapes, don’t be surprised to see the output somewhat truncated. Try moving the rotation start using the on-canvas handle to gradually expose more of your original shape. The mesmerising effect as you dynamically do this is similar to a kaleidoscope – indeed the original name for this effect was Kaleidoscope! It’s worth noting that, whether you fuse the shapes or not, the result of the LPE is (as always) a single path. The effect of this is clearer when a fill pattern is used on the original path – the entire output path takes on the fill pattern as one, it is not rotated with the individual shapes. If you want the fill to rotate with each copy you’ll need to use real duplicates or clones rather than an LPE. The second of the symmetry effects, Mirror Symmetry, does a similar trick to Rotate Copies, but using reflective symmetry rather than rotational. The UI also has a few similarities:

Whereas rotation takes place around a single point, reflection requires a line; the pop-up offers several different options, including reflection about the horizontal or vertical center line of the page, but by far the most useful option is (at least in my installation) labelled “Free from reflection line” - where I think “free from” is a typo for “free form”. In this mode, a mirror line appears on the page which can be moved using on-canvas handles via the Node tool. The two end handles are used to scale and rotate the line, the center one to move it without changing its orientation. If you choose the “X from middle knot” option in the pop-u,p the line becomes vertical and can be dragged via the center handle to set its distance from the original path; there’s also a corresponding “Y” option for a horizontal mirror line. The “Discard original path?” option is pretty self-descriptive – it removes the original path leaving only the reflection. If the original and its reflection overlap, the “Fuse paths” checkbox behaves the same as the corresponding one in the Rotate Copies effect: by definition this implies that the original object straddles the mirror line; the “Opposite fuse” option lets you switch which side of the line is kept and which is discarded when the fuse takes place. There’s no option to keep both sides, which seems like something of an oversight.

Although the Mirror Symmetry effect allows only a single mirror line to be used, you can, of course, add multiple copies of the LPE, each with different settings, in order to mirror an object in multiple directions – such as in both the X and Y directions to create four shapes from the original one. We’re now down to the last three LPEs that have been introduced with 0.92, and, quite frankly, they don’t warrant their own article, so I’ll finish with a whistle-stop tour of “Bounding Box”, “Ellipse by 5 Points” and “Attach Path”. What can I say about the Bounding Box LPE, other than “I couldn’t get it to work”? It’s supposed to let you add the effect to a sacrificial path, then link another path to it – at which point the sacrificial path is replaced by a rectangle that surrounds the linked path. That much seems to work – at least for simple examples – but the new rectangle is also meant to follow any transformations that you perform on the linked path, and in my testing this simply did not happen. The release notes suggest that this effect could be used to add a background color to a PNG export, but I think I’ll stick to drawing a rectangle of my own and putting it at the bottom of the z-order.

The Ellipse By 5 Points effect has no UI whatsoever. All it does is replace your input path with an ellipse that passes through the first five points of your path. It has no effect if your path has less than five points – or they’re arranged in a way that can’t form an ellipse – and it simply ignores any beyond the first five. I’m sure it will be useful to someone, but if you just want an ellipse in your drawing and don’t have a mathematical requirement for it to pass through five specific points, it’s more efficient to simply draw one with the Ellipse tool and then size and rotate it as necessary. The final LPE, Attach Path, lets you join one path to another by creating an additional line segment from the start of the path with the LPE to an arbitrary point on a linked path. You can also do the same from the end of the path, allowing a single path to potentially be attached to two others, should you wish. The position of the join on the linked path is set via the relevant position spinbox; a value of 0.00 will attach to the start of the linked path, whilst 1.00 will attach to the end of the first line segment, 2.00 to the end of the second, and so on. You can use fractional values as well, so that 2.50 would connect your line to a point halfway along the third segment of the linked path. These positions can also be set via on-canvas handles with the Node tool active. The new line segments can be curved at either end via on-canvas handles or the relevant Angle and Distance fields in the UI. To make the lines straight, set the distances to zero (it would be nice if a future release of Inkscape added shortcut buttons to do this for you).

This effect provides a workaround to another missing feature from SVG – the ability to have a path with a branch in it. By attaching paths together with this LPE, the connections will be maintained even if the original or linked paths are transformed or edited, making this a potentially useful effect for diagrams such as family trees.

issue129/inkscape.1517385860.txt.gz · Dernière modification : 2018/01/31 09:04 de d52fr