Jump to content
Search Community

Morph 2 SVG paths into 1 circle

craigib
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posted

Hi everyone, 

 

I've been playing around with Greensock the last couple of days and just wondered if it's possible to morph / animate 2 paths into a single path? 

In the codepen, you'll see I form a square but the way I've done it is with 2 paths. Just purely so I could animate it in the sequence I have. "Up, Right, Diagonal, Right & Up" I couldn't achieve this with a simple square SVG or at least I don't think so. 

 

What I want to do next is morph the 2 paths that make a square into a circle is this possible? 

 

Hope this makes sense. 

See the Pen QBrLjY by craig_codes (@craig_codes) on CodePen.

Posted

Hi @craigib :)

 

Welcome to the forum.

 

The short answer is no. The morphSVG plugin works path to path so if you morphed those two into the circle they would each morph into their own circle. Probably not what you want.

 

You can fake it though. At the end of the timeline you can hide the two paths that draw your square and swap in a new square which could be morphed into a circle. Something like this:

 

 

See the Pen WKJzZr by PointC (@PointC) on CodePen.

 

Hopefully that helps. Happy tweening.

:)

 

  • Like 6
  • Thanks 1
Posted

Thanks for that, I thought it might be the case that I need to hide the 2 and create a new one.
 

  • Like 1

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...