The OP didn't write that he wanted to do a loop.
But if I think about it, it doesn't really make much sense to use an expression for a simple up and down...
And if you're saying it's faster to use loop keyframes, the OP should do that.
If for some reason the expression is still needed:
- Code: Select all
:start = 0;
fps = comp:GetPrefs("Comp.FrameFormat.Rate");
duration = fps * 2;
loopTime = (time - start) % duration;
if time >= start then return (cos(loopTime / duration * 2 * pi - pi) + 1) / 2;
else return 0; end