Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Make a linear Loop

  • Make a linear Loop

    Posted by Claudio Franco on May 26, 2009 at 4:47 pm

    I’ve a simple expression to make the opacity go from 0 to 100 like this:

    linear(time,0,3,0,100)

    and it work ok…

    but i want to make this in loop like fadeIN and fadeOUT

    i try something like this:

    startVal = 0;
    endVal = 100;

    opa = linear(time,time,time+3,startVal,endVal)

    if(opa==100)
    {
    startVal = 100;
    endVal = 0;
    }
    else
    {
    startVal = 0;
    endVal = 100;
    }

    But it doesnt work and i simply, can’t figured out…

    Koby Goldberg replied 16 years, 11 months ago 4 Members · 12 Replies
  • 12 Replies
  • Claudio Franco

    May 26, 2009 at 4:49 pm

    Thanks… i’m already using that, but i have to apply this for hundreds of objects, so i really want a “expression” solution… but thanks!

  • Eric Sanderson

    May 26, 2009 at 4:50 pm

    It also looks to me like your just defining variables without actually executing them for anything, Your saying what startVal and end equals but not putting them to use, and actually giving the same variable different values. Im not an expression pro at all or anything so this could be a method im not aware of but thats the main problem i can see with the code.

  • Eric Sanderson

    May 26, 2009 at 4:56 pm

    Im not sure how to alter your code to work but if its taking too much time to figure out i would just keyframe the fade up and back down over 3 seconds then “loopOut(“cycle”)” to get them to loop continuously.

  • Eric Sanderson

    May 26, 2009 at 5:05 pm

    you could also try this..

    Math.abs(Math.sin(time)*100)

  • Koby Goldberg

    May 26, 2009 at 5:46 pm

    Eric’s idea is really nice and simple.
    If you want to change the time that the opacity rises from 0 to 100 to a specific duration value, use the following expression:

    duration = 3;
    Math.abs(Math.sin(time/duration*Math.PI)*100)

    if you insist on linear opacity and not SIN opacity, you could use the next expression:

    duration = 3;
    T = Math.round(duration/thisComp.frameDuration);
    t = Math.round(time/thisComp.frameDuration);
    100*( 1 - Math.abs(t%(2*T) - T)/T )

    Koby.

  • Dan Ebberts

    May 26, 2009 at 6:12 pm

    Like this maybe:

    period = 6;
    t = time%period;
    Math.min(ease(t,0,period/2,0,100),ease(t,period/2,period,100,0))

    Dan

  • Koby Goldberg

    May 26, 2009 at 7:58 pm

    Or this

    period = 3;
    t = time;
    50*(1 – Math.cos(t / period * Math.PI))

    (which will yield almost the same result as Dan’s expression, but i think will render faster 🙂 )

    Koby.

  • Eric Sanderson

    May 26, 2009 at 8:25 pm

    Koby.

    I was just curious as to the purpose of the “1-Math.cos”..doesnt that basically leave you with a Math.sin?

  • Koby Goldberg

    May 26, 2009 at 9:00 pm

    Hi Eric,
    No, this is not the same.
    SIN(X) is also negative (in case pi

  • Claudio Franco

    May 27, 2009 at 8:37 am

    This works, but i have to use linear function…

    The thing is, i have for example 10 objects, i and want them to all to have the same effect, and that expression works.

    But i want to 3 of them, to start the effect at time 1 sec
    Other 3 to start at time 2sec
    etc

    To have a “effect” that they are all uncoordinated.

    If i use your function, they will all have the opacity at 0 and 100 at the same time, because the your expression is all based in time.

    Sorry, i know i didn’t explained this at the beginning.

Page 1 of 2

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