ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Adding function to an expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alekos Mazzolotti
Adding function to an expression
on Jun 22, 2020 at 10:10:03 pm

Hi!

So, i've been using the following expression (pasting a "short version" of it) to add automatic behaviors to the start/end of a layer, at properties such as opacity.

Now, I had this idea of applying the same expression to the "end" property of a trim path animation. And it does work. Except that... For some properties (e.g. position), I like to shape my speed like this:



And the built in "ease out" function produces nothing of the sort. So, researching over the internet I came across this magnificent site:

http://gizma.com/easing/#expo3

And, in it, I found the following function to be added to my expression:

Math.easeInOutExpo = function (t, b, c, d) {
t /= d/2;
if (t < 1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
t--;
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
};


The question is: how can I integrate this function to my already working expression?

dur = Math.round(effect("Slider Control")("Slider"));

StartIn = inPoint;
StartOut = inPoint + dur;

EndIn = outPoint - dur;
EndOut = outPoint;

if (time>=StartIn && time &lt;= StartOut)
ease(time,StartIn,StartOut,0,100);
else if (time>=EndIn && time &lt;= EndOut)
ease(time,EndIn,EndOut,100,0);
else
value;


Return to posts index

Dan Ebberts
Re: Adding function to an expression
on Jun 23, 2020 at 7:06:49 am

I'm not sure if this is what your looking for, but it might be like this:


myEase = function (t, b, c, d) {
t /= d/2;
if (t < 1)
return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
t--;
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
};

dur = Math.round(effect("Slider Control")("Slider"));
if (time < (inPoint+outPoint)/2)
myEase(time-inPoint,0,100,dur)
else
myEase(time-(outPoint-dur),100,-100,dur)



Dan



Return to posts index

Alekos Mazzolotti
Re: Adding function to an expression
on Jun 24, 2020 at 3:24:13 am

Man, I love this forum 🖤

Ended up with my own combined function, to ease cubic in and exponential out. Turns out all I really needed was to get this function thing right. Never used it before.

I'll share my final result in a simplified version, case anyone desires to make good use of it.

Thanks a lot for your help =)

myEase = function (t, b, c, d) {
t /= d/2;
if (t &lt; 1) return c/2*t*t*t + b;
t --;
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
};

dur = 1
myEase(time-inPoint,1,100,dur)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]