Ceci est une ancienne révision du document !
I first described the Taper Stroke LPE in part 67 of this series (FCM#127). Back then, it was in the context of manually tracing an image. As an example, I took the ‘Frankie’ cartoon character, originally drawn by Vincent Mealing for our “Monsters, Inked” comic series, and traced over a scan of the original artwork using a variety of techniques. The Taper Stroke effect was used as a quick-and-easy way to produce more interesting outlines, without going to the full extent of using the Power Stroke LPE. Here’s a screenshot that appeared in the article, showing the result of using the effect in the drawing, and the UI for the LPE as it was at that time. With Inkscape version 1.1, several new additions were made to the Taper Stroke parameters – enough to warrant a quick update in this series. Here’s how the UI appears now: The first change is that the Taper Smoothing control has now been split into two parameters, governing the start and end smoothing respectively. In this context, smoothing refers to the shape of the taper, from a very rounded taper (smoothing: 1.0) to a straight line (smoothing: 0). You can see both of these used on the image below, which shows some of the effects that can be produced with this LPE when used on exaggeratedly thick lines. The Left-hand line displays the sensible limits of the smoothing parameter (1.0 at the top, and 0 at the bottom), while the rightmost line shows the effect of setting these to more extreme values (+/- 10.0 in this case).
This image also shows the other addition to this LPE: the ability to alter the direction of the taper. The second and fourth lines use the default “center” direction, but the first and third have their start and end directions variously set to “left” and “right”. These are the only three options available – it’s not possible to have a taper that terminates only slightly left of center, for example. It’s worth noting that the “left” and “right” designations are relative to the direction of the path. Imagine walking along the path from start to finish to determine which side of it is which. In the image below, the left-hand line has its directions set to “left”, and the right-hand line has its directions set to “right”, yet they both appear the same. The difference is that the former was drawn from bottom to top, and the latter from top to bottom. This also means that using Path ‣ Reverse on a shape with this LPE applied will flip the visible directions of the tapers, so watch out for that one if you’re forced to reverse the path for other reasons! I’ve left the leftmost line selected in order to show the handles that are visible when the Node tool (F2) is active. As has always been the case, you can drag these handles to adjust the length of the start and end tapers. A new addition, however, is that you can now shift-click on them to cycle between the three direction values, making it quick and easy to experiment with this upgraded capability. With that, we’ve reached the end of the new Live Path Effects added in Inkscape 1.0 and 1.1 (I’m skipping the experimental LPEs for the reasons mentioned last time). But these releases also brought with them some new extensions, which I’ll describe below, and next month. These can all be found under the Extensions menu, of course, and I’ve included the relevant submenu at the start of each section title.
Render > Frame Let’s start with a simple extension. This one draws a “frame” around each selected object in your image. I’ve put the word “frame” in quotes because it suggests something far more impressive than the result this extension produces. You might imagine an ornate picture frame, a Celtic knot style border, or perhaps something sweeping and calligraphic. Instead, what you actually get is what appears to be a rounded rectangle around each selected object. Except it’s not even a rounded rectangle – it’s a path – so there’s no easy way to change the corner radius after the fact. Drawing a rectangle that exactly hugs the outside of an arbitrary object is a little tricky in Inkscape. But it’s not exactly rocket science either. The simplest approach I know of is to duplicate your object, select Object ‣ Objects To Guides, then draw a rectangle by snapping to the intersections between the guidelines. This extension reduces those few steps down to one, but doesn’t really offer many other advantages as it does so. Let’s look at it in action. We’ll begin by selecting multiple items on the canvas. In this case there are two selections – one single star at the top, and one group of two stars at the bottom. Now we’ll run the extension with some pretty standard values to get started: Position is set to Outside, the checkboxes are left un-ticked, the stroke width is set to 2px and the corner radius to 10. Finally the stroke color is set to black, and the fill (on the second tab) is transparent (alpha = 0). Here’s the result:
The Inside/Outside popup can be used to determine whether the frame is drawn inside the bounding box of the selected object, or outside it. The difference is most obvious when the stroke thickness is cranked up a little – to 10px in this example. The Clip checkbox determines whether or not the selected item should be clipped to the size of the frame. Often this will make little difference, but if your object has a thick border, for example, this can theoretically hide the portion that extends outside the frame. I say “theoretically” because I have not been able to get this feature to work reliably at all. Most of the time enabling the Clip option just results in the entire object being removed. I have seen it work correctly on one occasion, but I haven’t been able to reproduce that behaviour since. The Group checkbox, on the other hand, does seem to work. But all it does is group the selected object with its corresponding frame, saving you a small manual step if you need to keep the object and its frame together in this way.
The new frame is rendered on top of the selected object. Bear that in mind before setting the Fill tab to use an opaque color, as it will obscure the original element. You can change the stacking order after applying the extension, of course, but it’s another step to be aware of. I don’t really see the point in this extension. It would make some sense if there was a field in which to add a padding value, allowing for frames that don’t hug the content quite so tightly. If the frame could be rendered in the background as well, this would provide an easy way to add a box and background color for multiple items, turning them into buttons or icons, for example. As it stands, I see little benefit of using this extension over learning the small number of steps to perform this task manually, unless you have a very large number of objects that require tightly fitting rectangles around them for some reason. Ironically the next extension would have been a perfect example of a use for this feature, if it wasn’t for the fact that the output of the Frame extension is not at all in the right form for Export Layer Slices to use…
Export > Export Layer Slices Inkscape already has a native mechanism for exporting multiple items in a document as separate PNG files, via the Batch Export feature in the File ‣ Export PNG Image… dialog. This assumes that the items you want to export are individual elements, or are already grouped in the right way. You can get around this limitation by simply creating a layer on which to draw some rectangles (or other shapes) that mark out the sections of the page to export, then perform a Batch Export with those rectangles selected. Here’s a tip: if you don’t want the rectangles themselves to appear as part of the exported files, select them all and then hide the layer before you hit the Export button in the dialog – the Batch Export checkbox should still say “Batch export N selected objects”, where N is the number of shapes you selected in your slicing layer, but you’re not left with a visible stroke around the edge of each PNG. The Export Layer Slices extension essentially does the same thing. To use it you have to create a slicing layer, then draw rectangles to mark the areas to be cut out and saved as separate PNGs. The layer has to be at the top level (rather than being a sub-layer), and the rectangles must actually be rectangles (i.e. <rect> elements in the XML), not paths or any other shape. The Export dialog approach doesn’t have either of these limitations. When creating your slicing layer, you need to ensure that the name of the layer is the same as the name used in the extension’s UI. By default, this is “slices”, so the easiest approach is simply to give your layer the same name.
Set your export directory, and the DPI for the images, and hit the Apply button to create your PNG files. If you want fine control over the filenames, you can first change the ID of each rectangle via the Object ‣ Object Properties dialog (don’t forget to hit the “Set” button). And you probably also want to tick the “Overwrite existing exports” checkbox, otherwise the extension will refuse to replace any existing files with the same names. Unfortunately, this extension suffers from a major flaw, as far as I am concerned. Given that you have to create a whole separate layer to define the slicing regions, I would expect that layer to be omitted from the exported images. After all, it xists only to provide some dimensions, it’s not actually part of the drawing itself. But no, every exported image includes the rectangle’s stroke and fill as part of the PNG. The easy workaround is to hide the layer before running the extension; unlike the equivalent Export dialog workaround, there’s no need to select the rectangles first, but it’s still a bit of a pain having to repeatedly hide and unhide it, if you’re trying to fine-tune the sizes and positions of the slices. But perhaps you want the rectangle included, to provide a nice border for your exported PNG. You take the time to set the stroke width and color… only to find that your own choice of styles is replaced by the extension after the export. The rectangle’s stroke is removed and the fill is replaced with a shade of gray (file already exists and was not overwritten), red (file exists, but was overwritten), or green (file was created for the first time). If you want to try the export again, you’ll need to revert all those back to their original styles unless you really want a red overlay added to all your PNGs!
In my opinion, if you want to export multiple slices of your document defined by rectangles, you may as well just use the standard Batch Export approach, with an optionally hidden slicing layer. The benefits of the extension just aren’t great enough to make it a compelling new method of performing this task. This extension does offer one other trick, however: Icon mode. This is enabled via the checkbox of the same name, and while it initially appears useful, it’s also got a major flaw that makes it less than practical in a lot of cases. What this mode does is to ignore the DPI setting, and instead create a series of square images for each slicing region, using the pixel sizes defined in the “Sizes” text box. Unfortunately, it does this by stretching each image to fit the square aspect ratio. In short, your slicing “rectangle” in this case absolutely has to be a square, otherwise the content will be stretched out of proportion. A much better approach would have been to scale the content in proportion, and automatically center it in the square. This would work equally well for slices that are already square, and those of a different aspect ratio. But alas, the extension offers no such option. The image below shows the result of using Icon Mode on a single image from a character sheet. On the left you can see the original Inkscape drawing, complete with the slicing rectangle (in green, due to this screenshot being taken after the initial export). To the right, you can see the icons that were produced. Clearly not the result I would have liked or expected.
So there we have two of the new extensions. I hate to be cynical, but I can’t really see much benefit in either of them. The Frame extension could perhaps be useful if it allowed some padding to be specified, and created real rectangles instead of paths. The Export Layer Slices extension could be useful if it didn’t also include the slicing rectangles in the output, and if it didn’t stretch the images out of proportion in Icon mode. What’s most annoying is that these two extensions are frustratingly close to working well together. Imagine if the Frame extension’s default behaviour was to create real rectangles in a new “slices” layer (with optional padding, of course). Instantly, it becomes an easy way to create the initial slicing rectangles for the Layer Slices extension if you have a lot of elements to export. But instead, we get these two extensions, neither of which are great on their own, and which don’t work well together. What a shame.