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

how to write expression in such case -15 (trim path looping randomly)

Enthusiast ,
Aug 29, 2025 Aug 29, 2025

Hi,

 

I want to loop the start and end of trim path but randomly for each line.. like line 1 start it's loop at 2 second, line 3 at 4 second. and none of them will overlap with one another's animation timing, I mean suddenly line 2 start its loop and line 3 and line 1 are not looping, again when line 1 looping line 2 and 3 not animating. . they will happen solo at their own time. And I want this to continue for as long as the main comp goining on, say 20 second, each line will be in a loop but different timing... . How can I write the expression? Thank you.

 

trim path.gif

TOPICS
Expressions
176
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 , Aug 29, 2025 Aug 29, 2025

Here's an example. It's probably not exactly what you're after, but it might be close enough to get you started. Add a null, name it "Controls" and add a Point Control named "Line and Percent". Add this expression to the Point Control:

minLine = 1; // minimum line number participating
maxLine = 3;  // maximum line number participating
runDur = 1; // duration of animation time

seed = Math.floor((time-inPoint)/runDur);
seedRandom(seed,true);
curLine = Math.floor(random(minLine,maxLine + 1));
curP
...
Translate
Community Expert ,
Aug 29, 2025 Aug 29, 2025

Here's an example. It's probably not exactly what you're after, but it might be close enough to get you started. Add a null, name it "Controls" and add a Point Control named "Line and Percent". Add this expression to the Point Control:

minLine = 1; // minimum line number participating
maxLine = 3;  // maximum line number participating
runDur = 1; // duration of animation time

seed = Math.floor((time-inPoint)/runDur);
seedRandom(seed,true);
curLine = Math.floor(random(minLine,maxLine + 1));
curPct = (((time-inPoint)%runDur)/runDur)*100;
[curLine,curPct]

For each of the line shape layers (named in the format "Line n") add this expression for the Trim Path's Start parameter:

ctrl = thisComp.layer("Controls").effect("Line and Percent")("Point");
curLine = parseInt(ctrl.value[0],10);
curPct = ctrl.value[1];
if (curLine == index){
  ease(curPct,20,100,0,100)
}else
0

and this for the End parameter:

ctrl = thisComp.layer("Controls").effect("Line and Percent")("Point");
curLine = parseInt(ctrl.value[0],10);
curPct = ctrl.value[1];
if (curLine == index){
  ease(curPct,0,30,0,100)
}else
0

You may need to fiddle with the numbers.

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
Enthusiast ,
Aug 30, 2025 Aug 30, 2025

Thank you so much. I needed this guidance. Thank you.

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
Enthusiast ,
Aug 30, 2025 Aug 30, 2025
LATEST

You are the GOAT of all the GOAT of entire universe... I just applied it and its exactly what I needed. I cant stop being happy. Thank you so much. 

GOAT= Greatest of All Time

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