gotcha

Author Topic: Can I extract part of a path  (Read 659 times)

February 26, 2019, 09:51:16 AM
Read 659 times

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
I have a complicated project -- complicated in the sense that it involves an enormous path with thousands of nodes. It emerged from a simple, clean-edged .jpg image of sunflowers that I want to enlarge ~5X for printing and I need clean edges. (See attached file) I also want to change a few colors. Each color area is bounded by coloring book style black lines.

I tried tracing the bitmap in Inkscape. Maybe I need to work on defining color for tracing a little more, but the result was a mess, so I opened the file in GIMP and selected all the black. From that selection I created this mammoth path bounding the space creating the black lines. Since GIMP's path tools are lame and working with a file that size was unbelievably slow, I exported the path to .svg and opened it in Inkscape. Meanwhile, the path created from the selection formed from an image that had acquired significant jpg artifacts had serious irregularities I want to smooth out.

So far, so good. I went through all that to give you the background for my question.

This path forms a square with maybe 500 "holes". Those holes need to be filled with about 70 colors to form the final image. I can put the image back in GIMP and use the bucket fill tool, but again, GIMP is SLOW! Inkscape's bucket leaves margins. If I'd thought ahead, I could have left less margin between the shapes and used a .5 pixel stroke on the top image to cover those margins, but it's late for that now.

I tried creating a demo path easier to experiment with that included shapes inside a rectangle. I combined those four elements into a single path, then placed a colored rectangle beneath it and used Dfference to create a new path with the shapes floating inside the rectangle. This final step resulted in a path with the same properties as the one I'm working with.

So far the only way I've found to isolate an area inside that path (a "hole") and convert it to an independent shape is to delete all other nodes. With a file the size I'm working with, that's not doable. I've tried cutting and dividing ... nothing I've found works. Am I missing anything? I'm attaching my demo file to make it easier to understand the question and perhaps do your own experiements.

I'm fine with moving it back to GIMP, but would like to keep the color shapes scalable for possible future use in other projects at some future time. Thanks in advance for your help!
  • .092
  • Windows 10 Home

February 26, 2019, 11:17:24 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I'm not completely sure if I understand your question.  I think you're looking for some kind of substitute for the Paint Bucket tool - a way to fill a space with color, when it's not a distinct closed path?

Inkscape's Paint Bucket tool can be configured not to leave a gap.  Likely you would still need to manually tweak some of the color paths.  But Inkscape's Paint Bucket tool should work.

Look on the control bar (directly above the horizontal ruler) for the Grow/Shrink spinbox.  It depends on the thickness of your black lines what you'd want to set it for.  But you can experiment and figure out the best value.

After you apply colors, if you see any areas where there are gaps, you can select that color and switch to the Node tool (or use the Node tool to select it).  Then just grab the node and drag it behind the black line.  Or possibly you might need to only move a handle.

Edit
I think I finally understood your question, in case you still can't use the Paint Bucket tool.  What you did so far with Difference is fine.  After that, I think what you're looking for is Path menu > Break Apart.  That will make each shape an individual path.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 27, 2019, 06:49:21 AM
Reply #2

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
 :ty1: Brynn!

I appreciate that you did decipher the question. It was not an easy one to describe.

I had not noticed that grow/shrink function. It's perfect! Maybe I was stuck here because each of the few fill tool discussions I've seen emphasize the margin and how this tool is not appropriate for precision work. I am excited to see that this tool creates a new shape for each of the fills and that's a HUGE advantage over the GIMP bucket tool. Now I'm pondering ways to help get the word out to make this tool more useful to others.

I'd thought of the Break Apart function, but my outline shape is so massive it hangs Inkscape when I try that. Or, maybe since it originated in GIMP from a selection, the path lacks some crucial Inkscape definitions that would allow it to be broken apart. If a complex path does not begin with the usual combinations of shapes, there may not be anything recognizable to break apart.

I did try importing my posted Path Demo 1.svg file into GIMP and it was a total mess. Something about the path function transformations I'd used must not speak GIMP. I tried importing both an Inkscape svg and a plain one. Same problem each time.

Simple paths import perfectly into GIMP. Before I pursue that question though, I need to precisely document the steps.

ADDITION: The fill does not precisely follow the shape of the empty space, so the trick to perfection is to slightly overfill, moving the new fill shapes while keeping the outline on top.



« Last Edit: February 27, 2019, 09:11:56 AM by ImaGeek, Reason: Additional information »
  • .092
  • Windows 10 Home

February 28, 2019, 03:19:46 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Maybe I was stuck here because each of the few fill tool discussions I've seen emphasize the margin and how this tool is not appropriate for precision work.

Oh, what you read is right!  It definitely is not good for precision work.  It can be used for precision work, if the user doesn't mind doing the tweaking of the nodes that is required to make it precise.

Also for your specific use, filling spaces between wider borders, is exactly what it was designed for.  Depending on how wide the borders are, it doesn't need to be precise.  As long as the edges are hiding underneath that border.

Now I'm pondering ways to help get the word out to make this tool more useful to others.

What kind of work are you doing this for?  Or what community of users do you want to tell about this?  I just want to be sure we're all on the same page, so to speak.  It's possible that it still might be better to use a traditional vector fill (by making a closed path for each space that you want to fill).

For example, if this is going to be used with a digital cutter of some kind, I would say you'd be better off with making a closed path for each space.  I think that's what you were trying to figure out.  I'm just a little confused why Break Apart was hanging Inkscape, when you did the Difference operation just before, that should have hung it up as well.

Could you share the actual file?  There might be a problem with it, which we could help you identify.  I'm not very faimilar with GIMP so I'm not sure what you meant about something originating as a gimp selection.  So it makes me wonder if there's something unexpected in the file.

Or if you can't share the actual file, could you make a test file using the same process you used?

I did try importing my posted Path Demo 1.svg file into GIMP and it was a total mess.

I'm just curious about this part.  How did you try importing it into GIMP?  As I said, I'm not very familiar with GIMP, and when I  tried opening the SVG, it opened fine, but it doesn't look like it opened as vector paths.  Or at least, when I used the Paths tool, I can't seem to edit that file.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

March 03, 2019, 11:42:15 AM
Reply #4

Spazmelda

  • Sr. Newbie

  • Offline
  • **

  • 2
One thing you could do, if you do need the fill to be precise, is overfill, as mentioned above using grow/shrink.  Then duplicate the outline object and use it to >path >difference from the fill objects.
  • 0.92.4
  • Windows 10