Outils pour utilisateurs

Outils du site


issue210:inkscape

Ceci est une ancienne révision du document !


The last change in Inkscape version 1.3 that I’m going to cover in these articles is described as follows in the release notes: “The Filter Editor has been overhauled and is now easier to use!” Well, it’s definitely been overhauled. As to whether or not it’s easier to use… I’ll just describe the functionality and let you decide that for yourself.

I first covered the Filter Editor dialog back in part 48 of this series (FCM #108). I then spent a further 9 issues detailing each of the individual filter primitives. Despite the overhaul in the Filter Editor’s UI, those details still mostly apply – so if you want to revise your filter knowledge, I suggest reading those articles as well. That first article described how to create a simple filter chain for a drop shadow effect so, at the risk of repeating myself over 100 issues later, I’m going to do the same with the new editor.

In practice, I recommend using the Filters > Shadows and Glows > Drop Shadow… dialog for creating drop shadows on a day-to-day basis. The end result is a slightly different filter chain to the one we’ll be creating here, but it’s a quicker, easier, and more flexible option for most purposes. However, with the knowledge gained from creating your own filter chain from scratch, it will be easier to tweak Inkscape’s built-in offerings via the Filter Editor dialog, should you need to.

A filter is applied to one or more objects, either individually or contained within a group. It’s important to understand the difference: when a filter is applied to a group, it’s as though the entire contents of the group is flattened down to a single object before the filter is applied. This image shows the same shapes with the same drop shadow applied, but the pair on the left are separate elements, whereas the pair on the right are grouped together, with the filter being applied to the group.

Of course you’re free to mix things up further, applying filters to objects before grouping them and adding another filter to the group itself, for example. Sometimes there are good reasons for creating such complex arrangements, but do bear in mind that filters come at a cost. They are calculated ‘live’, which gives you the advantage of being able to tweak their parameters later, but which can chew up computing power very easily once too many, or too complex, filters are applied to the drawing. For our simple drop shadow example, however, speed isn’t likely to be too much of a concern.

Since a filter is applied to an object or group, we’ll first need to create something. Following the example in my old article, I’m going to work on a bold and colorful text object. First a reminder of how the Filter Editor dialog was arranged in earlier versions of Inkscape.

And now the new layout, in version 1.3. There’s also an alternative layout which is automatically used if your dialog is wide enough, but, in my opinion, it puts the panels in the wrong order (the parameters for the selected primitive on the left, and the filter chain containing the list of primitives on the right – breaking the usual left-to-right flow of a parent-child relationship in the UI). Therefore, I’ll stick to the vertical layout in this article.

Neither of these is particularly intuitive, but the old dialog at least had the benefit of a fairly large button labelled ‘New’ to hint at your starting point. The equivalent in the new design is the much smaller ‘+’ button towards the right of the top row of controls. Good luck if you’re using the symbolic icons, where this looks even less obviously like a button!

Clicking that ‘+’ button creates a new filter with an automatically generated name (‘filter1’ in this image), and activates a little more of the UI. The text on the bottom panel becomes slightly more helpful, telling us to add an effect from the search bar. The search bar in question is the drop-down with the magnifying glass icon and the ‘Add effect’ placeholder text.

This search bar actually works in two different ways, which can be a little confusing at first. For most users, I recommend opening the pop-up by clicking the down-arrow at the right. The result is a categorised array of the filter primitives, each with a small icon that sort-of represents what it does. The icons aren’t always of much use in determining which primitive is which: the ones that I mix up the most (Blend, Merge and Composite) all share the same icon! But I find it’s useful to see all the primitives at once to help reassure myself that I’m picking the right one amongst all the options.

The second mode kicks in if you type into the field. This presents a vertical list of primitives, filtered by the text you type. If you absolutely know you want the Gaussian Blur primitive, for example, typing ‘blur’ or even just ‘ga’ will be enough to restrict the list to the one you want.

Whichever approach you take, select the Gaussian Blur primitive to add it to your filter chain. The main panel will now be updated to show the primitives in your chain (just the one, so far), while the bottom panel shows the parameters for that primitive.

Although the controls in this section will vary depending on the primitive, they all share the three icon buttons that are shown next to the name. Clicking the first opens a small pop-up, which contains some additional information about the primitive. The other two will duplicate or delete the primitive, respectively. In the older editor, these existed only on the context menu in the editor pane (where they can also still be found). It’s good that these have been more obviously surfaced in the UI, though my build does not show tooltips for either of them: although the icons make their function fairly obvious, it’s still reassuring to be able to see a textual representation of their purpose.

At this point, we have a valid filter chain, but our text still looks as un-blurred as ever. This was a shortcoming of the old editor as well, but it would have been nice if the new redesign had gone so far as to automatically associate the filter with the object we had selected when we created it. To make this association, we have to manually click the checkbox next to the word ‘Filter’ on the top line – and voila, we have blurred text.

The old dialog showed a list of all the filters in the document on the left, with a checkbox to indicate which one applied to the selected object, and a count of the number of objects in the document which use that filter. Changing the name of a filter was done by double-clicking on it to edit it in-place, and there was a context menu for duplicating and deleting filters.

The ‘Filter’ pop-up in the new dialog offers the same options, now with more obvious buttons (still with no tooltips though). Renaming just requires a single click on the filter name to enter editing mode, and the currently active filter is shown more correctly using radio buttons rather than checkboxes.

The ‘check’ or ‘tick’ button is worth drawing attention to specifically. The lack of a tooltip had me puzzling over its purpose, since it didn’t seem to assign the selected filter to the current objects as you might imagine from its visual association with the checkbox in the main dialog. What it actually does is the exact opposite: given a selected filter in the pop-up, it selects all the objects on the canvas that use the filter. This is a great addition that I’ve wanted for years, to aid with de-duplication of filters in complex drawings – it’s just a shame that it’s got an ambiguous and nondescript icon with no tooltip.

At this point, you can rename your filter to something more descriptive (“Blur”, or “Drop shadow” as that’s where we’re going with it), and you can play around with the sliders in the bottom panel to adjust the amount of blur applied to the text.

Inkscape veterans may be wondering where the old ‘Filter General Settings’ tab has gone to. This is used to set the maximum size of the filter area, and sometimes has to be adjusted to stop filters being clipped. It now lives behind the cog icon at the right of the top row of controls, but can probably be left set to ‘Automatic Region’ unless you have a specific clipping issue.

Also missing for old-timers are the various sources listed to the right of the main editing panel, with only ‘Source Graphic’ and ‘Source Alpha’ being visible by default. The other options are still available, and can be toggled with the button next to the Search Bar. But to be honest, they’re either tricky to use or downright broken in Inkscape – and always have been. Much as I would love to see the underlying issues addressed to make these more useful, hiding them by default is definitely the best option for most users. In fact I would have gone a step further, and had the toggle button inside the ‘cog’ pop-up, where it would be less likely to tempt unsuspecting users.

The actual details of creating a filter chain haven’t really changed, unfortunately. We’re still stuck with a list-based view of the filter primitives which feels restrictive and archaic compared with the ‘node editor’ approach that is common for similar tools in other products. There’s no technical limitation with SVG that prevents Inkscape having such a UI but it would be a huge undertaking – so unless some intrepid developer with lots of free time wants to give it a go, I think we’ll be looking at minor variations on this list for a long time to come.

Given that this part of the UI remains mostly the same, I’m going to rattle through the remaining steps of our drop-shadow filter quite quickly. See those older articles if you need a slower introduction.

For the basic sort of drop-shadow we want, the shadow needs to be a blurred version of the object with a black fill, not the bright color we’re currently seeing. The classic answer to this, in filter terms, is to drag the handle from the triangle next to the Gaussian Blur filter, over to the right, dropping it on the Source Alpha column. That causes the input to our blur to be taken from the transparency of the object which, in practice, means that filled pixels in the source end up as black pixels in the alpha. It’s a quick way to turn our red blur into a black blur.

Since this blurred version will be the shadow, we need to move it from its original position. This is done by adding an Offset filter primitive to the chain by selecting it via the effect search bar. My brain always wants to click the ‘+’ button, but that adds a whole new filter, not just another primitive. Remember that in the new UI, the act of selecting the primitive also adds it – there’s no confirmatory step required. Compared with the old UI, this makes it impossible to read the info text about a primitive until after you’ve added it (furthering my confusion between Blend, Merge and Composite). At least there’s now a more obvious button to delete it when you realise you’ve picked the wrong one.

If the new primitive isn’t automatically linked to the one above, drag from the triangle on the Offset primitive up to the Gaussian Blur, then release the mouse button to create a visible connection. You can adjust the sliders for the Offset primitive to your taste. Remember that filters are ‘live’ and you can always re-adjust them later, so don’t get hung up on guessing the right values now. On the canvas you should see your blurred, black text move around as you change these values.

The final step with a drop-shadow is to put a copy of the original object back on top. This is most easily done with the Merge primitive, which literally just layers things on top of each other in the order in which they’re linked. Again, add it using the effect search bar. If it’s not automatically connected, drag from the triangle up to the Offset primitive. A second triangle will be created below the first, which you should drag to the Source Graphic column to the right. Basically we’ve just told it to merge together two images – the output from the Offset primitive on the bottom, overlaid by the original object on top. Our filter is complete.

In this image (top right) I’ve edited and resized the text, and edited the name of the filter itself, to give the final result – and a picture of what your filter chain should hopefully look like.

issue210/inkscape.1729963647.txt.gz · Dernière modification : 2024/10/26 19:27 de auntiee