Allow clip/mask set inverse

Bug #412928 reported by Davjdag
98
This bug affects 20 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Jabiertxof

Bug Description

If you didn't understand immediately, the attached image should clear things up...
Also here: http://i709.photobucket.com/albums/ww97/Daghead/Clipmaskwithinverse.png

In instances where the resulting object would otherwise be infinitely large, it could be trimmed down to, say a 16th wider and taller than the area of the original objects (this would be a great feature of the Fill tool as well).

I swear this ability would be extremely helpful, especially when working with images (though I'm not going to strain to recall an example).

Tags: clipping
Revision history for this message
Davjdag (davjdag-deactivatedaccount) wrote :
jazzynico (jazzynico)
Changed in inkscape:
importance: Undecided → Wishlist
Luca Bruno (lucab)
Changed in inkscape:
status: New → Triaged
Revision history for this message
Pablo Trabajos (pajarico) wrote :

> I swear this ability would be extremely helpful, especially when working with images
Could you elaborate why it could be so helpful with images? In the work I do most of the time what I need is to clip (or mask, but usually clip) the image like it does already. Clipping paths are used to enclose a particular region of the image.

Revision history for this message
Davjdag (davjdag-deactivatedaccount) wrote :

I'm sorry- by "when working with images", I meant: " when using mask with raster images". In one project this would have prevented me from having to copy and then invert an image in another program to get mask to do what I want. And then there are cases when I want to easily compare the results to decide what I prefer.

Maybe it really was a stretch of me to say it would be extremely useful for most people, regarding clip in particular. Anyway for me there have been times in the past when this would have made it easier to make blurred edges for defining regions in a drawing. (think the bottom row of the attached illustration, but square)...

Thanks for the feedback :)

Revision history for this message
Davjdag (davjdag-deactivatedaccount) wrote :

I mean "think the TOP row" :P

Revision history for this message
Raphael Campos (optgeek) wrote :

I also find this an extremely important feature. I just found this page after looking for a way to make an inverse clipping.
What I'm currently trying to do is to make an object "cut" the objects below, and as far as I know this isn't possible yet. Hope we get this feature soon, I'm planning to use Inkscape on some professional work.

Revision history for this message
Raphael Campos (optgeek) wrote :

By the way, about my last comment - It would be like using the "Difference" function (Ctrl + -), but working as clipping.

Revision history for this message
Rena Kunisaki (i-am-inuyasha) wrote :

Yes. This would be extremely useful for me. The image I'm working on right now has one big shadow on it, which has much heavier blur in one place than others. That means it has to be two objects. Trying to line up the edges of two blurred translucent objects so they look like one is nigh impossible. It'd be much easier to just use a duplicate of one as an inverse clipping mask for the other.

I find myself wanting to do this quite often; the usual solution is to create a big blob around the two and cut out of it. But inverting a clip mask would be much cleaner and easier.

su_v (suv-lp)
tags: added: clipping
Revision history for this message
v1nce (vincent-pennec) wrote :

after http://www.inkscapeforum.com/viewtopic.php?f=5&t=12065

I didn't find this bug report so I duped it as https://bugs.launchpad.net/inkscape/+bug/998022
(please someone close this)

When I want to draw hole in a complex shape I do this

1) Create base shape (or group)
2) Draw a rectangle that encompasses the base shape. [Set it to no fill and give it a stroke you can see.]
3) Draw the "hole".
4) Select the rectangle and the hole, then Path > Difference to create the clipping path.
5) Select the base path and the group, then Right Click > Set Clip.

So applying an inverted mask would require inkscape to automatically do step 2 & 4.

Revision history for this message
nesthib (nesthib) wrote :

I totally agree, this would definitely be very useful and much easier by just masking the desired part of an object instead of having to try to encompass the entire object.

Revision history for this message
flyingfisch (flyingfisch) wrote :

definately would like this feature

Revision history for this message
Ted Janeczko (janeczko-ted) wrote :

This would definitely be a very useful feature, especially when used in combination with path cloning to create shading. I don't know if it would make it into Inkscape since there's not really an exact SVG 1.1 equivalent (or an SVG 2.0 equivalent currently, although different compositing modes could be used to achieve the same result and the spec is still a draft).

That being said, I've created a patch using r11949 which adds a "Set Inverse Clip" option to the context (right-click) menu of an object. When clicked, the top-most path is turned into a clip path as normal, but a new "inkscape:inverse" attribute on the "clipPath" element is set to "true", and essentially anything contained within the clip path is composited out when rendered. Again, I'm not sure if this could, or even should, end up in Inkscape, but this patch may be helpful to anyone who is looking to use an inverse clip mechanism.

jazzynico (jazzynico)
Changed in inkscape:
assignee: nobody → Ted Janeczko (janeczko-ted)
status: Triaged → In Progress
Changed in inkscape:
assignee: Ted Janeczko (janeczko-ted) → nobody
Revision history for this message
insaner (insaner) wrote :

Are there actually any objections to this patch making it into trunk?

Would it also require any file using this option to be marked as requiring a minimum version of inkscape?

Revision history for this message
Liam P. White (liampwhite) wrote :

I object.

No other program will be able to render inverse-clipped items correctly.

Revision history for this message
v1nce (vincent-pennec) wrote :

I don' understand your objection

It's only a matter of doing automatically what you could do by hand

1) Create base shape (or group)
2) Draw a rectangle that encompasses the base shape. [Set it to no fill and give it a stroke you can see.]
3) Draw the "hole".
4) Select the rectangle and the hole, then Path > Difference to create the clipping path.
5) Select the base path and the group, then Right Click > Set Clip.

So applying an inverted mask would require inkscape to automatically do step 2 & 4.

And the svg would still be perfectly legit.

But I don't know if this is what the patch is really doing

So if the patch is just setting a custom attribute to tell the inkscape renderer to invert the clip path then I agree it's not the way to go

Revision history for this message
su_v (suv-lp) wrote :

On 2015-03-01 14:45 (+0100), v1nce wrote:
> But I don't know if this is what the patch is really doing

@vince - please read Ted's initial comment [1] - he explained in plain language what the patch does, and that is not conforming to the current SVG 1.1 specification nor to draft versions of the SVG 2.0 specification.

Objecting to commit the patch (as is) to trunk, too.

--
[1] https://bugs.launchpad.net/inkscape/+bug/412928/comments/11

su_v (suv-lp)
Changed in inkscape:
status: In Progress → Triaged
Revision history for this message
v1nce (vincent-pennec) wrote :

I vote aginst too.

Revision history for this message
insaner (insaner) wrote :

What about a similar approach to what inkscape is already doing with text -> path, where it keeps a copy of the text object so the path can then be converted back to a text object, edited, and back to a path? For inverse clipping, all you would do is, not even needing the encompassing rectangle, but just some path form of the object (I tried with a linked offset -- clones don't work, since they are not paths) being internally created to perform the path->difference, and then using that new path as the clipping object, but it remains internally linked to the original object, such that the original object can be edited, and when this happens, the clipping path is automatically updated. So the functionality to the user would be identical to clipping, but now they can do an inverse clip, while still having an SVG spec compliant doc.

Revision history for this message
v1nce (vincent-pennec) wrote :

Do we need a copy ?
As invertedclip = rect + MoveTo + baseclip, getting the baseclip would just be a matter of dropping the start of the path.

Revision history for this message
Christopher Kyle Horton (christhehorton) wrote :

Comment #8 is very useful to me, as this is exactly what I needed for creating glow/shadow assets for SVG buttons without the buttons themselves. I'm somewhat surprised that Inkscape still doesn't support this functionality.

Revision history for this message
Matthew Duhamel (dualhammersw) wrote :

Pretty surprised this isn't supported. I need to properly layer strokes, to create the illusion of occlusion without a fill.

Jabiertxof (jabiertxof)
Changed in inkscape:
assignee: nobody → Jabiertxof (jabiertxof)
Revision history for this message
Jabiertxof (jabiertxof) wrote :

There is a Live Path Effect (LPE) PowerClip and PowerMask that allow it. Also in last commit r.24e870081a allow gaussian blur for inverse. For IMages you can grup it and apply the LPE to group.

Changed in inkscape:
status: Triaged → Fix Committed
Max Gaukler (mgmax)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.