Andy Zhuang

How to morph shapes dynamically in Canvas2D

Recommended Posts

I want to draw 2D path (line, rectangle, curve, etc.) dynamically with mouse moving in Canvas2D. And can also modify the path's end points in the future.

I have found how morph mesh in 3D space dynamically.  But it seems that can be applied to Canvas2D's shapes.

Now I remove the old shape and  create a new one when need morph the old shape. But I am not sure it has performance issue, especially when morph path containing many vertexes. 

My code: http://www.babylonjs-playground.com/#NF6H0S

Any better ways for this? Thanks.

Share this post


Link to post
Share on other sites
On 08/05/2017 at 10:56 PM, Deltakosh said:

Not a big deal. This is ok but you may want to create a merged Lines2D object at some point in time (instead of multiple Lines2D)

Yes @Deltakosh  

When one line's endpoint snap to another line's endpoint, I want merge them at the joint point. Any ideas for this? Thanks.

Share this post


Link to post
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.