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 pmI’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 pmThanks… 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 pmIt 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 pmIm 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.
-
Koby Goldberg
May 26, 2009 at 5:46 pmEric’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 pmLike 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 pmOr 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 pmKoby.
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 pmHi Eric,
No, this is not the same.
SIN(X) is also negative (in case pi -
Claudio Franco
May 27, 2009 at 8:37 amThis 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
etcTo 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.
Reply to this Discussion! Login or Sign Up