ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Get Position of Stroke Offset

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nate Vander Plas
Get Position of Stroke Offset
on Jun 15, 2020 at 4:13:18 pm

Does anyone know how to get the position of the Start or End point of a stroke on a shape layer? I'm using Trim Paths on a rounded cap stroke to create a small circle that travels along the spline by animating the Offset. I basically have the Start set to "0" and End set to "0.01." I'm also animating the Path of the shape layer. The tricky part is that I want a trailing line that is dynamic and requires position data. I could just use a duplicate of my original Shape layer and extend the Start/End to make it longer, but when I animate the Path, that trailing line animates in an undesirable way. I could also copy the Path and paste it as Position keyframes on a circle layer, but since I'm animating the path, that doesn't work. My work-around right now is to precomp the offset animation, then track the motion, and apply that to my layer that I'm using for the dynamic trail. But it doesn't allow for easy changes to my animation. I'm open to any other ideas! Thanks!



Return to posts index

Dan Ebberts
Re: Get Position of Stroke Offset
on Jun 15, 2020 at 4:46:52 pm

This is a simple example that will track the End point of the Trim Paths:

L = thisComp.layer("Shape Layer 1");
p = L.content("Shape 1").content("Path 1").path;
pct = L.content("Shape 1").content("Trim Paths 1").end/100;
L.toComp(p.pointOnPath(pct))


Dan



Return to posts index

Nate Vander Plas
Re: Get Position of Stroke Offset
on Jun 15, 2020 at 9:36:09 pm

Thanks Dan! This almost works! It does find the point where the End of the Trim Paths would be, but it doesn't take into account the Offset, which is how I'm animating the circle along the path. I figured out how to get the Offset parameter into the expression, but I don't know what math to do to get it to adjust the End position. Thanks again for your help!



Return to posts index


Dan Ebberts
Re: Get Position of Stroke Offset
on Jun 15, 2020 at 9:51:15 pm

See if this works:

L = thisComp.layer("Shape Layer 1");
p = L.content("Shape 1").content("Path 1").path;
pct = L.content("Shape 1").content("Trim Paths 1").end/100;
offset = (L.content("Shape 1").content("Trim Paths 1").offset%360)/360;
L.toComp(p.pointOnPath(pct + offset))


Dan



Return to posts index

Nate Vander Plas
Re: Get Position of Stroke Offset
on Jun 16, 2020 at 10:47:11 am

Yes! Thanks so much, Dan!



Return to posts index

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