shrinking path or average between 2 paths

Post questions on how to use or achieve an effect in Inkscape.
User avatar
DynV
Posts: 7
Joined: Sat Apr 20, 2013 5:48 pm
Location: Montreal, Canada

shrinking path or average between 2 paths

Postby DynV » Sat Apr 20, 2013 6:15 pm

Straight off, I was going to ask how to get an effect like Gimp selection Shrink effect but actually the path I'm working on come from Gimp ; I'll get back to that at the end. I used a popular map site to make a route, getting the direction between 2 locations then took a screenshot and made a path along the road border. It end with slightly different version of the same path, close that a resized version of the other are almost parallel, attached at their extremities.
path-117.png
problematic path showing nodes
path-117.png (29.95 KiB) Viewed 4124 times

I'd like the middle of the 2 parallel paths along the curves ; perhaps their average. I could always make a new path and click between every turn of the road but that would be long and imprecise ; there's 140 nodes. is there a way to automate the process?

Here's the current file:
path-117-ends_fixed.svg
path of the road border
(6.13 KiB) Downloaded 239 times


Thank you kindly

I made a color selection of the route color in Gimp, filled missing parts using Quick Mask, then saved it to a path and finally exported it. I imported the SVG after right-clicking Inkscape path list.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: shrinking path or average between 2 paths

Postby brynn » Sun Apr 21, 2013 4:23 am

Image
Welcome to InkscapeForum!

I'm not familiar enough with GIMP to understand your process there. But I could suggest something that might work for Inkscape. You'll have to disconnect the 2 paths for this technique. (And note that there may be other or even better techniques, and this is just what comes to mind for me.)

1 - Select the nodes to break apart, one at top, the other at the bottom (hold Shift key for multiple selection).
2 - Click "Break path at selected nodes" button on Node tool control bar.
3 - Path menu > Break Apart
4 - Deselect all then select 1 path, doesn't matter which one (this is very important) Path menu > Reverse.
5 - Extensions menu > Generate from Path > Interpolate. Set dialog like this:
--- Exponent = 0.0
---Interpolation steps = 1
---Interpolation method = doesn't matter
---Duplicate endpaths = checked or unchecked, depenging on your needs (sometimes it's nice to have a duplicate of the original)
---Interpolate style = unchecked

I've done those exact steps on your file, and it works beautifully! You may notice a couple of places where the new path seems not to be quite centered, especially in the sharpest turns in the road. I guess you could experiment between Interpolation Method 1 or 2. I've never been able to notice a difference, but I still usually try both, hoping someday to see what the difference is, lol. Inkscape does it's best to interpolate, but the sharper turns make it tricky. I guess you could do a tweak or 2 on the nodes here and there. I'd probably leave it be, but of course you know more about what you need :D

User avatar
DynV
Posts: 7
Joined: Sat Apr 20, 2013 5:48 pm
Location: Montreal, Canada

Re: shrinking path or average between 2 paths

Postby DynV » Sun Apr 21, 2013 7:27 am

Awesome! :D That was sure better than doing something alike a node at a time.

That was exactly what I was looking for. I made
path-117-interpolated.svg
road center
(13.21 KiB) Downloaded 311 times
with your instruction. There might be a better solution but it was as I was expecting it to be.

I have a question and a correction. What does Path menu > Reverse in #4 ? #5 should start with: Select the paths to interpolate then.

Thanks again brynn

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: shrinking path or average between 2 paths

Postby brynn » Tue Apr 23, 2013 12:23 pm

Oh right, sorry about that. Indeed, you do need to select the 2 paths, before you run the Interpolate extension.

If you try it without reversing one of the paths, the interpolation doesn't work -- it just goes wacky. I can't remember why, but the direction of the 2 paths is important, for the interpolation to work properly. I guess for Inkscape to be able to choose the proper placement of the new path(s), both paths have to go in the same direction.

If node #1 on one path is at the top, and node #1 on the other path is at the bottom, Inkscape will have to place node #1 for the new paths somewhere in between, and in that case, it's not in between the 1 paths, but in between the top and the bottom (for these specific 2 paths in your file). Sorry, I wish I could state it more clearly. But I'm only guessing anyway :D

User avatar
DynV
Posts: 7
Joined: Sat Apr 20, 2013 5:48 pm
Location: Montreal, Canada

Re: shrinking path or average between 2 paths

Postby DynV » Tue Apr 23, 2013 1:20 pm

Oh! I didn't think about the 1st node. It was indeed mentioned in Inkscape tutorial: Interpolate, identified with a green dot. I noticed its importance with rotations.

I was going to ask you a question but I found the answer on that page:
To find the starting node of a path, select the path, then choose the Node Tool so that the nodes appear and press TAB.


Thanks again :)


Return to “Help with using Inkscape”