Converting two closed paths into a single closed path

Post questions on how to use or achieve an effect in Inkscape.
ryan1234
Posts: 5
Joined: Sat Nov 21, 2009 1:18 am

Converting two closed paths into a single closed path

Postby ryan1234 » Sat Nov 21, 2009 2:06 am

Hello,

I'm new to Inkscape and love it. However, I've been struggling terribly the last couple of days trying to resolve an issue.

I've been given the task of converting some bitmap images (line drawings) to SVG. I'm doing this by loading the bitmap image in a layer and then trying to trace over it (on another layer) with the pen.

I've been trying to make the tracing a single path so that it will be easier for me to 'pull' and 'push' the lines into the correct place and shape. The difficulty is that I cannot figure out how to make it all a single path. Here is an example of what I'm trying to trace.

recliner.png
recliner.png (1.39 KiB) Viewed 3783 times


What I've been trying to do is trace a closed path and then connect other closed paths together so that they have a common 'wall' or line between them.

Another way of thinking of this is, say I have two closed path squares right next to each other and I want them to share a common 'wall' (essentially, making it a wide rectangle with a vertical line splitting the rectangle into two squares). How would I do this so that it's a single path so I can tweak the shared wall and make it curved or S-shaped while still having it be the common wall for both squares?

After creating the image I need to be able to fill it with a color (which shouldn't be too hard once I have the paths figured out).

Thanks,

Ryan

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Converting two closed paths into a single closed path

Postby druban » Sat Nov 21, 2009 3:41 am

hi Ryan!

I'm sorry to tell you that there is no way to do quite what you want but several ways around it. I like to think of paths as lengths of string the ends of which may or may not be joined (open and closed paths). However, joining two open paths results in a single longer open path and two closed paths can't be joined (think of two rubber bands, to mix similes). This is not an Inkscape specific restriction but the very nature of vector paths.

However, your problem has simple solutions that you will probably be satisfied with.

One is to draw the overall outline of the shape as a black-filled shape, draw white-filled shapes on top, and then select all the shapes and perform a paths/combine operation on them. You now have one object for most purposes.

Another method is draw several closed or open paths that are stroked but not filled that follow the lines of your source. Once you get them to the desired thickness and positioned (overlapping if necessary) the way you want them perform a stroke to path operation, followed by a union. You once again have a result that is a complex but editable path.

Keep in mind that there are other methods involving dynamic offsets etc. that you might not to want to try as a beginner.
Good luck.
D
Your mind is what you think it is.

ryan1234
Posts: 5
Joined: Sat Nov 21, 2009 1:18 am

Re: Converting two closed paths into a single closed path

Postby ryan1234 » Sat Nov 21, 2009 4:30 am

Hi D,

Thanks so much for your suggestions. Knowing that I can't join/connect two closed paths at least gives me the freedom to leave that thought behind and move on to different solutions.

Your suggestions make sense and I will give both of them a try.

Thanks,

Ryan

billstei
Posts: 5
Joined: Fri Jun 06, 2008 2:19 am

Re: Converting two closed paths into a single closed path

Postby billstei » Mon Jan 04, 2010 8:27 am

This is undoubtedly the feature that I would like the most, and I complained about it long ago:

viewtopic.php?f=28&t=1090&start=0

Take for example this image of George Jetson:

Image

If you look at his ear (part of the face), it makes the most sense to put it in front of the hair, with the hair drawn so that it under-laps the ear. That way the ear can be moved, and the hair corrects itself (maybe). Now look at the hair above his forehead. Here it is better to think of the hair being in front of the face (and ear). That way the hair can be adjusted (maybe), as long as the face under-laps the hair sufficiently. So, which should I pick, face in front of hair, or hair in front of face? What I really want is a common path shared by two areas, and each enclosed area with it's own fill color.

Not being familiar with SVG specs, is this capability there in SVG but just not implemented yet in Inkscape?

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Converting two closed paths into a single closed path

Postby druban » Mon Jan 04, 2010 9:54 am

billstei wrote:This is undoubtedly the feature that I would like the most, and I complained about it long ago:

if you look at his ear (part of the face), it makes the most sense to put it in front of the hair, with the hair drawn so that it under-laps the ear. That way the ear can be moved, and the hair corrects itself (maybe). Now look at the hair above his forehead. Here it is better to think of the hair being in front of the face (and ear). That way the hair can be adjusted (maybe), as long as the face under-laps the hair sufficiently. So, which should I pick, face in front of hair, or hair in front of face? What I really want is a common path shared by two areas, and each enclosed area with it's own fill color.


What you are actually asking is for something to be in front of and behind another object at the same time! :shock: there are a number of workarounds to get what you want, but really an implementation of this ''feature" would make no programming sense. :?
Take the example you provide. This was originally drawn on one or more pieces of celluloid that were then stacked on top of each other to shoot the animation frame. If the hair and face had been on different cels - perhaps in order to animate the hair or face independently, although i don't recall hanna-barbera's animation as being that elaborate ;) - then the hair would have to be on a level above the face or below in the cel stack. The only way to get both would be to paint two objects with the same fill so they would look like one but be independent (you can go with this option in IS pretty easily -cut your object in two, move one half up in the z-order and then group them together so they move like one object but are on separate z-levels)
IS 0.47 allows the clipping mask to be accessible without releasing the clip so you could try this method as well if you did not like the previous one...
Your mind is what you think it is.

llogg
Posts: 443
Joined: Tue Mar 11, 2008 7:30 am

Re: Converting two closed paths into a single closed path

Postby llogg » Mon Jan 04, 2010 11:33 am

In the Jetson example you should probably draw a path for the face, then in front of this a path for the hair, and finally an open path for the ear in front of the hair. If you really don't like having the third path simply use that path to do a difference operation with the hair path.

billstei
Posts: 5
Joined: Fri Jun 06, 2008 2:19 am

Re: Converting two closed paths into a single closed path

Postby billstei » Tue Jan 05, 2010 5:21 am

Just to be clear, I am not wishing for one object to be simultaneously in front of and behind another object. I am wishing for one object to have two (or more) fill colors.

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Converting two closed paths into a single closed path

Postby sas » Tue Jan 05, 2010 5:56 am

billstei wrote:What I really want is a common path shared by two areas, and each enclosed area with it's own fill color.

Not being familiar with SVG specs, is this capability there in SVG but just not implemented yet in Inkscape?

No, a path in SVG can't have more than one fill colour. (That doesn't necessarily stop Inkscape from simulating this sort of thing, however.)

billstei
Posts: 5
Joined: Fri Jun 06, 2008 2:19 am

Re: Converting two closed paths into a single closed path

Postby billstei » Tue Jan 05, 2010 6:28 am

I guess I'll just have to wait:

http://www.w3.org/TR/SVG2Reqs/#req-graphics

Specifically in section 4.2-1.-3. "The set of new segments may include general splines, mathematical functions, or a reference to another path element (allowing shared borders on elements). Path segments may also allow defined points (providing common vertices for path elements). Path data may be extended to support constraint features [SVG 2.0]"

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Converting two closed paths into a single closed path

Postby druban » Tue Jan 05, 2010 10:10 am

billstei wrote:Just to be clear, I am not wishing for one object to be simultaneously in front of and behind another object. I am wishing for one object to have two (or more) fill colors.


Well, you can't do this in Inkscape. Illustrator has something like it, where you can apply 'multiple fills' to the same object, but really when I looked at it it seems what they're doing is just making linked clones with the fill unset and layering them.... all of it automatically and behind the scenes, of course, very slick :D )
Your mind is what you think it is.

User avatar
c-quel
Posts: 68
Joined: Thu Dec 31, 2009 2:13 am
Contact:

Re: Converting two closed paths into a single closed path

Postby c-quel » Thu Jan 07, 2010 2:41 am

Ryan, I'd like to propose an alternative solution, based on the two-square example you provided.

If you don't mind working primarily with Strokes, I might suggest building the "common wall" entirely out of a continuous-running Stroke. For the central wall dividing the two squares, this can simply be the same stroke overlapping itself twice (once to go down, and again to return to its starting position).

The drawback is that this would not yield two closed square paths, but rather one large closed path that is simply fooling the viewer into thinking its divided into two separate parts. Moreover, if you want to bend the central "wall", you have to move two separate Strokes, not just one.

Nevertheless, this might suit your needs. Feel free to check the attached example and let me know if this sounds reasonable. :)
Attachments
interlapping_strokes.svg
Example SVG
(2.71 KiB) Downloaded 199 times


Return to “Help with using Inkscape”