Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding function to an expression

  • Adding function to an expression

    Posted by Alekos Mazzolotti on June 22, 2020 at 10:10 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;

    Alekos Mazzolotti replied 6 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 23, 2020 at 7:06 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

  • Alekos Mazzolotti

    June 24, 2020 at 3:24 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)

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