Jump to content
Search Community

Merging Double lines to Single line in SVG

Mishap test
Moderator Tag

Recommended Posts

Hello 

 

Not sure if I open a topic in correct place. 

I have a following challenge. need to have some tool with API to merge double lines to Single lines in SVG as shown on examples. 

I'm using some custom made library for it, but as you can see it not effective. 

 

I'm not sure but maybe GSAP can help with it ?

 

Thanks in advance for support 

Screenshot 2024-03-22 at 16.30.56.png

Screenshot 2024-03-22 at 16.31.20.png

Link to comment
Share on other sites

Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

Thanks for reply guys 

 

The goal is actually following: 

I'm converting simple image to SVG file and getting outer lines of it, as shown on screen.  then I calculate the length of the lines in total, however I also need to convert the double lines (actually the parallel lines in example, but in most cases lines wil not be 100% parallel) to single line and have in SVG format so that I can also calculate the length of it. 

 

Can you tell me if DrawSVG plugin can do it?

 

Thanks again in advance for your help 

 

Link to comment
Share on other sites

In the case of the O letter, yeah those are two different paths most likely, so you'll have to start both of them at the same time and be sure that they start point is basically the same so the lines are animated in the same direction and end at the same time as well.

 

I would recommend you to take a look at this tutorials by @PointC

https://www.motiontricks.com/cut-your-path-start-points-in-adobe-illustrator/

 

https://www.motiontricks.com/better-svg-exports-make-animations-easier/

 

With the assets in the right way, the DrawSVG Plugin will create the animation you are looking for. It might take a a few tweaks here and there (every project is different and has it's own peculiarities) but it could definitely be done.

 

Finally you can fork this codepen starter template in order to create a minimal demo that illustrates what you're trying to achieve:

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

 

Happy Tweening!

Link to comment
Share on other sites

If I'm understanding you correctly, you actually want to create an entirely different path that is visually in the "middle" of the outlines, right? That's definitely not something DrawSVGPlugin can do for you. You'll need to create the SVG path in the proper way. Asset creation is the key here, as @PointC shows in his articles. Once you have the path, DrawSVGPlugin will easily animate it. 

  • Like 1
Link to comment
Share on other sites

Hi @Mishap, this isn't something I would expect GSAP to do, since it's not animation, but it's something I often wish I could accomplish, myself. I use a pen plotter that draws strokes, not fills. How did you go about scripting the conversion of outlined letters into single strokes? Not good enough for your purposes, but maybe good enough for some of mine! 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...