ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

getting the length of a mask or shape path

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jack Bowler
getting the length of a mask or shape path
on Aug 29, 2018 at 1:33:52 pm

Hi guys,

I'm trying to create where I spawn the correct amount of particles based on the length of the path that the emitter is following. i.e if the mask length is 300 px, spawn 30 10px sized particles. However to get this to work i need to calculate the length of a bezier path. I know how to do this if it was just 2 points in a linear direction from each other however I'm at a loss as to how to do this with a bezier path made up of more than 2 points.

Any help is greatly appreciated.


Return to posts index

Dan Ebberts
Re: getting the length of a mask or shape path
on Aug 29, 2018 at 6:46:19 pm

It's tricky. You can approximate it using line segments if you have the latest version of AE:


path = content("Shape 1").content("Path 1").path;
len = 0;
steps = 100;
p0 = path.pointOnPath(0);
for (i = 1; i <= steps; i++ ){
p1 = path.pointOnPath(i/steps);
len += length(p0,p1);
p0 = p1;
}
len


Increase the steps variable to get better resolution (at the cost of slower performance).


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]