Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression: evolving loop

  • expression: evolving loop

    Posted by Christian Graupner on May 24, 2014 at 5:49 pm

    sorry I am new here, not really experienced with expressions and I use a quite of version of afx ( 7 !)

    A) the first simple (not for me) question is :
    is it possible to write an expression for a loop which is shifting with every repeat.
    example : first the movie runs from frame 0 to 12 , then from 2 to 14 , then 4 to 16 , 6 to 18 and so on. the segment length ( 12 in the example) and step width( 2 in the example ) should be adjustable.

    B) if yes, could somebody help me out and provide the code ?
    feel free to let me know your ‘conditions’

    thanks a lot in advance

    christian

    Christian Graupner replied 10 years, 5 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    May 24, 2014 at 6:49 pm

    If you have a time-remapped layer, and apply this time remapping expression, I think it will loop the way you have described:

    segDur = 13;
    segOffset = 2;

    f = timeToFrames(time);
    segNum = Math.floor(f/segDur);
    segPhase = f%segDur;
    framesToTime(segOffset*segNum + segPhase)

    Dan

  • Christian Graupner

    May 24, 2014 at 8:17 pm

    that works brilliant …. thanks so much . when you come to berlin I ll cook a meal for you 😉

    btw: would it work as ‘pingpong’ too?
    ( would run from 0 to 12, from 12reversed to 2 , then from 2 to 14 , back to 4 and so on)

    best
    christian

  • Dan Ebberts

    May 25, 2014 at 7:06 pm

    I think that would be something like this:

    segDur = 13;
    segOffset = 2;
    totalDur = segDur*2-4;

    f = timeToFrames(time);
    segNum = Math.floor(f/totalDur);
    segPhase = f%totalDur;
    if(segPhase < segDur)
    framesToTime(segOffset*segNum + segPhase)
    else
    framesToTime(segOffset*segNum + 2*segDur- segPhase – 2)

    Dan

  • Christian Graupner

    May 26, 2014 at 1:14 am

    of course it works ! in my eyes your are a genius! thank you so much..

    all the best

    christian

  • Christian Graupner

    April 5, 2016 at 6:16 pm

    Hi Dan

    Curious if you do see a possibility to make this evolving fwd<>bwd loop behave like a pendulum. I mean that it speeds up exponentially ( ?) to the middle and slows down in the extremes .

    in the box below I post your code for the evolving fwd / bwd loop with the straight speed …

    segDur = 13;
    segOffset = 2;
    totalDur = segDur*2-4;

    f = timeToFrames(time);
    segNum = Math.floor(f/totalDur);
    segPhase = f%totalDur;
    if(segPhase &lt; segDur)
    framesToTime(segOffset*segNum + segPhase)
    else
    framesToTime(segOffset*segNum + 2*segDur- segPhase - 2)

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy