Jump to content
Search Community

MotionPath and getLength

benoit test
Moderator Tag

Recommended Posts

Hi,

Close, but don't find how to get the length of a motionPath.

 

const rawPath = MotionPathPlugin.arrayToRawPath([{x:0,y:10},{x:50,y:1000}], {curviness:2});
const d = MotionPathPlugin.rawPathToString(rawPath);
console.log(DrawSVGPlugin.getLength(d)); // hum

 

Link to comment
Share on other sites

You have to use a path element for that.

 

const rawPath = MotionPathPlugin.arrayToRawPath([{x:0,y:10},{x:50,y:1000}], {curviness:2});
const d = MotionPathPlugin.rawPathToString(rawPath);
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", d);

// same thing
console.log(path.getTotalLength())
console.log(DrawSVGPlugin.getLength(path))

 

  • Like 4
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...