Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Animate lines of various lengths at same speed so smaller lines finish first

New Here ,
Jul 06, 2025 Jul 06, 2025

Okay, first time doing a post like this, so please go easy on me everyone. I have been banging my head against this roadblock for the last few days

 

I have multiple lines that need to have a trim effect that comes out from the edge of the screen. They are all of various lengths and angles. What I am after is a way that all the lines emerge at the same speed, so that the shorter ones finish first while the longer ones finish last. Trim path seems to be the way to go, but that only works on a percentage, and I haven't found another way to get this to work. I figure an expression might be the way to go, but nothing I have tried has worked 

TOPICS
Expressions , How to
135
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 08, 2025 Jul 08, 2025

I think to do it, your expression has to calculate the length of the path. This is an iterative expression for the Trim Path's End property that will give you the approximate length, which you can then use to calculate the current End percent:

spd = 100; // trim speed (pixels per second)
path = content("Shape 1").content("Path 1").path
numPts = 100;
accum = 0;
p1 = path.pointOnPath(0);
for (i = 1; i <= numPts; i++){
  p0 = p1;
  p1 = path.pointOnPath(i/numPts);
  accum += length(p0,p1);
}
(spd*(
...
Translate
Community Expert ,
Jul 07, 2025 Jul 07, 2025

I'd be really tempted to not use Trim paths for this and use the linear wipe instead.  Or use a mask or track matte for the layer to do the same thing. 

But you may have more things going on on your shapes.  

You could have a trim paths in each shape group, so that you have multiple keyframes to deal with.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2025 Jul 08, 2025

If the lines were all going in the same direction, that would have been an option for me, but I have lines on all sides of different angles and lengths between points, and go towards the center. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2025 Jul 08, 2025

I think to do it, your expression has to calculate the length of the path. This is an iterative expression for the Trim Path's End property that will give you the approximate length, which you can then use to calculate the current End percent:

spd = 100; // trim speed (pixels per second)
path = content("Shape 1").content("Path 1").path
numPts = 100;
accum = 0;
p1 = path.pointOnPath(0);
for (i = 1; i <= numPts; i++){
  p0 = p1;
  p1 = path.pointOnPath(i/numPts);
  accum += length(p0,p1);
}
(spd*(time-inPoint)/accum)*100

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2025 Jul 10, 2025

Thanks I will give it a try and report back

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2025 Jul 10, 2025
LATEST

This was what I was after. Thank you so much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines