Ceci est une ancienne révision du document !
Right on schedule, Inkscape 1.2 was released last month with a lot of new features, and updates to the existing UI. I will be covering everything in detail in this column, but not just yet. In the meantime, if you want a good overview of the headline features, I strongly recommend taking two minutes out of your day to watch the very professionally produced official release video: https://www.youtube.com/watch?v=1U4hVbvRr_g
For now, these articles are still working through the many new Live Path Effects (LPEs) that were added with Inkscape 1.0 and 1.1. The topic for this instalment is a pair of new LPEs – “Power Clip” and “Power Mask” – which I first mentioned back in part 101. That article detailed the use of the new “Inverse Clip” and “Inverse Mask” menu entries, with little more than a scant reference to the fact that they’re actually implemented as LPEs. Now it’s time to dig into the effects that back these capabilities in a little more detail.
Power Clip
I won’t sugar coat this: I think the name of this LPE is making a very bold claim that is far from matched by reality. As far as I can tell, this effect usefully does one and only one thing, and doesn’t really deserve the “Power” prefix at all. The only practical use for this LPE is to create inverse clipping paths.
Adding this effect to a path works a little differently to almost every other LPE. You can’t simply select a path and add the Power Clip effect from the usual dialog. If you try, you’ll just find that the option is disabled (as is Power Mask, for similar reasons).
A clipping path requires one other element to act on – the thing you’re trying to clip. That single element could, of course, be a group consisting of several other items, which allows complex designs to be easily clipped. But the clipping path itself is applied to only one element or group.
With this in mind, you might think that this LPE will become available if you have two items selected. In practice, however, the Path Effects dialog itself will chastise you with an “Only one item can be selected” message, and the “+” button will be disabled to prevent you even opening the Live Path Effects Selector dialog. How, then, do we apply this LPE in the first place?
There are actually two methods: • The first is to apply it directly using the Object > Clip > Set Inverse (LPE) menu entry that I discussed in part 101. • The other is to apply a normal clip, either via the context menu or using the Object > Clip > Set menu entry, then use the Path Effects dialog to add the LPE as usual.
Yes, if you have an already clipped object selected, only then will you be able to add this LPE in the normal manner.
Whichever approach you take, this LPE really, really wants to create an inverted clip. If you add it directly via the menu entry, then that’s what will happen, as you would expect. Adding it via the dialog to an already clipped object, however, will immediately invert the clip that you’ve already applied – which might be a little more surprising if you’re not expecting it.
As a reminder, a normal clip preserves everything inside the path, and hides the content outside. An inverse clip, therefore, hides everything inside the path but preserves anything outside, per the image below.
If you really want a normal clip, then you can uncheck the “Inverse clip” option in the LPE’s parameters – though doing so raises the obvious question of why you want to use the LPE at all in that case. Perhaps the “power” in this LPE actually comes from the other two parameters? Well, the “Hide clip” option simply modifies the clipping path to remove the nodes that actually do the clipping – again, raising a question about why you wouldn’t just remove the clip entirely. As for “Flatten clip”: this is another entry in my box of LPE mystery parameters that appear to do something, but it’s not entirely clear quite what that something is. My own experiments with various combinations of objects and groups, primitives and paths, have failed to present me with any situation in which it does something useful. As usual, if you have any idea of how it’s meant to be used, please do get in touch.
One final important note about this LPE is how to go about removing it. If you only want to temporarily stop it being applied, then the usual approach with an LPE is to toggle the visibility icon (the “eye” image) in the Path Effects dialog. This may not, however, work as you expect. It will remove the inverting effect of the LPE, but still leave your object with the non-inverted clip applied. If you really want to see the object with no clip at all, then you’re back to using the “Hide” option in the LPE’s parameters. This feels a little awkward to me, as it requires users to understand too much about the implementation of clipping masks in SVG to fully appreciate why the normal visibility toggle doesn’t work the way they might expect.
Permanently removing this effect is even worse. Should you be foolish enough to delete the effect from the Path Effects dialog, as you might usually do, then you’re likely to find that your clipped objects disappear as well – almost certainly not what you wanted! Instead you have to release the clip using the Object > Clip > Release menu entry, or the context menu alternative. Even that comes with a sting in the tail: your original clipping path will also be deleted, so if you wanted to retain both that path and the object being clipped, you’re out of luck.
With that exhaustive examination of this “power” LPE, I’ve come to the conclusion that it serves only one useful purpose: to simplify the task of punching a hole in another object using a clipping path. To be fair, I think this is an exceptionally useful ability. I’m just not sure it warrants the “power” prefix, rather than simply being called “Inverse clip”. As useful as it is, do be aware of the problems and limitations that come with it. If you’ve got enough experience with Inkscape to be able to make your own inverse clipping paths, as I described way back in part 13, perhaps sticking with the old-fashioned approach is still the safer option.
Power Mask
Masks are often thought of as a more “analogue” version of clipping. Whereas clips provide hard edges and a binary visible/hidden state for each part of the clipped object, masks allow for gradients and blurs, with every part of the masked object having its opacity determined over a continuum according to the colors used in the mask. But when it comes to the Power Mask LPE, the behaviour and usage compared with the Power Clip effect is quite different in many ways.
I prefer to keep my masks in shades of gray to provide clear control over their effects. A typical mask would use white for those areas that are to remain 100% opaque, black for those that are to become completely transparent, and intermediate shades for levels of opacity in-between. Any transparent areas, including those outside the mask shape, are also rendered as transparent once the mask is applied. With that refresher done, here’s the shape and mask we’ll be experimenting with today.
When applied as a normal mask, the white center to the design should ensure that the middle of the star remains solid, while the gradient out to the black edge will fade out the points of the star long before we reach their ends. Selecting both the star and the mask, then using the “Set Mask” context menu entry (or Object > Mask > Set) does, indeed, give the result we would expect (shown against a chequerboard background so you can see which parts are translucent).
What would you expect the result to be if, instead, we use Object > Mask > Set Inverse (LPE)? Based on the behaviour of the Power Clip effect, you might imagine that the middle will be punched out of the star, leaving the points in place but fading towards a large central hole. That’s certainly what I expected the first time I used this effect, but the actual outcome is somewhat different.
Let’s take a closer look at the LPE’s parameters to work out exactly what’s happening here.
Interestingly, despite having selected “Set Inverse (LPE)”, the “Invert mask” option is not checked. Instead all the hard work is being done by the “Add background to mask” checkbox, and the color picker below it. This has the effect of adding a flat colored background to your mask, which covers the bounding box of the element you’re masking. In this case, it adds a white background which combines with our original mask to produce an effective mask that looks like this.
With that in mind, the end result is a little more understandable. But it’s not exactly what I would expect from a menu entry that bills itself as an “inverse mask”. Perhaps if we enable the “Invert mask” option, we’ll get something closer to our expectations…
Hmm… not really. The problem now is that we’ve inverted every part of our mask – swapping black for white, light gray for dark gray, and so on – but that also includes the color of the background we’ve added. Now, therefore, the mask looks like this:
Again this explains the output we’re seeing, but it’s still not really what we had expected from an inverse mask. What we need is the hole in the middle from this version, but with the points of the stars still being visible, as we had in the previous one. In other words, we want a black center fading to a white shape that continues to fill the whole bounding box. The way to achieve that is to change the background color to black, so that the “Invert mask” checkbox has the effect of converting it to white. With that change, we finally get the look I was expecting from the outset.
To summarise, in order to create what I would consider to be the inverse of my mask, I had to do the following: • Draw the mask • Apply it to the object using Object > Mask > Set Inverse (LPE) • Open the Live Path Effects dialog to access the parameters • Set the “Invert mask” option • Ensure the “Add background” option is checked • Set the background color to black
That really is a lot of work, and it’s clear that the “Set Inverse (LPE)” option didn’t really do much to help us out. My advice, therefore, is to skip this LPE entirely, and just construct the mask you need with the right colors from the outset. Here’s what I would actually do to achieve the same result: • Draw a white rectangle that covers the star • Draw a black circle in the middle • Blur the circle, or give it a black-to-white gradient to create the soft edges • Group the circle and rectangle to create the final mask • Select both the mask and the star, then use Object > Mask > Set
Admittedly it’s barely any fewer steps, but I’ll wager that this approach is a lot more intuitive to anyone with even a little experience using Inkscape.
And there you have these two new “power” LPEs which, on the surface, promise so much, yet deliver so little in reality. The Power Clip is potentially useful, but may create problems when you want to release the clip later. The Power Mask just doesn’t do anything that you can’t achieve by hand almost as easily, if not moreso. They’re both useful tools to know about, though – if only so that you understand how to achieve the same results without having to get the LPEs involved at all!