2

Sometimes when tracing bitmaps in inkscape, I'll see a an object which has two or more disconnected curves, which automatically exclude each other.

For example tracing this image:

enter image description here

Results in this:

enter image description here

I can edit either path and the fill updates in realtime:

enter image description here

How can I set something like this up manually?

4

Let you already have a C-like path. Then you can reconnect points with the following simple procedure:

  1. Select 4 points near the future junction.

  2. Disconnect these points with enter image description here

  3. Reconnect them in the diffenent order with enter image description here

enter image description here

Or even simpler procedure:

  1. Create two objects.

  2. Flip the internal one horizontally or vertically enter image description here

  3. Combine paths (Ctrl K).

enter image description here

Both these procedures give you the dynamic boolean masked object just because it is the nature of combined paths in Inkscape:

enter image description here

0

It helps to understand what SVG thinks of as being 'inside'.

Starting outside at 0, you count how many times you cross the path in getting to the region you are interested in. However you count based on the direction the path is going as you cross it. +1 for left and -1 for right. (or vis versa, I'm not sure which is used, but it works out the same either way).

The resulting number tells you whether you are inside or outside. You can specify whether you want inside to be when the number is odd, or the number is non-zero. This setting is on the Fill tab of the Fill and Stroke dialogue.

For simple cases, you can think of the even/odd rule as meaning subpaths within a path cancel each other out while the non-zero rule meaning that subpaths going in opposite directions cancel. This gets much more complicated as you add more subpaths and as they start intersecting, which is why the counting method is used as it doesn't care about intersections. In terms of boolean operators, even-odd is effectively an exclusive or, while non-zero isn't boolean.

You can select the nodes of a subpath with the node tool and then Path -> Reverse to reverse that subpath.

For a simple demonstration, draw a shape, then draw a figure 8 shape on top,. Select both and Paths -> Combine. If you are in even-odd mode, you will have two holes, if you are in non-zero mode, you will have just one hole. Try switching the fill rule in the Fill and Stroke dialog. In non-zero mode, try selecting the nodes of the figure 8 and then reverse them and you should see the hole flip to the other side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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