1

I've a path which I want to overlay with a watermark pattern.

Since my path is filled only with white and the background is dark I want to make the watermark overlay pattern to switch color only if it's on top of my path from white to black (or the background color).

Something like that in the picture:

Even odd pattern

I read that I somehow could use the "Even-Odd" fill option but, I haven't figured it out with my setup when I have a watermark path and a other object which I want to combine.

Any idea, hints how to approach this in Inkscape?

2
  • When you say 'watermark' are you talking about the method of protecting against unauthorized use, like stock image websites add to their images, or just the effect in general? As a protective measure, it doesn't make much sense for vector graphics, since it is trivial to edit these kinds of files and completely remove it. And if you just need it for exported bitmaps, it might be easier to use something like Gimp to add an overlay.
    – Xrott
    Aug 24 at 12:21
  • Thanks for your comment. Just the effect in general. I know it's not a protective measure for SVGs but I would like to understand how I can create such an effect in Inkscape. Aug 24 at 12:42

1 Answer 1

3

Off the top of my head, I can think of three different methods to accomplish this effect:

The first is the one you already mentioned, which involves using 'Path → Combine' on two paths and setting the fill rule to even-odd. However, this likely won't work in a lot of situations, especially when using strokes or markers etc., and makes things a lot harder to edit.

The second involves a bunch of duplicating (or cloning) then clipping, but this adds a lot of unnecessary complexity and redundant data. It also makes things a little harder to change later as well.

The last, and the one I want to go into more detail on, uses filters. While it is probably the most advanced, may require some minor changes to the document structure and may not render correctly in a small number of viewers, the advantages of it are that it updates in real-time, works with multiple objects and even colors, and doesn't add redundant data. It's also – at least to me – the most interesting solution of the three.

First group all the objects together, that you want to add the overlay to, and move that group to a new layer. Hide that layer in the 'Layers and Objects' panel. By the way, for the best results, make sure there are no transform-attributes on any objects inside the group or on the group itself.

Next, to prepare the pattern, you could clone the repeating section a bunch, then group and clip it, but it's probably better to set up a proper SVG pattern here. To do that, select one repeating section and use 'Object → Pattern → Objects to Pattern'. This will convert your selection to a rectangle with the new pattern applied. You can now tweak the pattern with the new pattern-editor inside the 'Fill and Stroke' panel in the recent Inkscape 1.3 release:

New pattern editor in version 1.3 of Inkscape

With the 'Move patterns (in fill or stroke) along with the objects' (this button: Button in question highlighted) setting in the toolbar disabled, resize the rectangle to fit the whole canvas. Your canvas and document structure should look something like this:

Pattern across whole canvas

Layers and Objects panel showing layer structure.

Now you can open the 'Filters → Filter Editor...' (this panel has also been updated in the new 1.3 version), create a new filter, and apply it to the rectangle by clicking on the checkbox in the top left with it selected. Add an 'Image' effect, select the group ('g23' in my example above) and click on the 'SVG Element' button in the parameters. The 'Source of Image' input should now display the ID of the group (#g23). Next add a 'Composite' effect, connect one of the arrows to 'Source Graphic' and set the 'Operator' drop-down to 'XOR':

Filter editor with above described filter

And we're done! Here is the result, both black and white (transparent) and in color:

Result in black and white

Result with different colored objects and pattern

1
  • Xrott your answer is amazing! I learned so much from following along your detailed and clear steps and it turned out as I've expected it. Thank you, thank you very much! Aug 25 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.