Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Ease and Wizz Question

  • Ease and Wizz Question

    Posted by Eric Guiliani on August 28, 2013 at 4:28 pm

    Hey All-

    I have a question. I’m fluent in JS/AS and am slowly learning Expressions. I’m finding myself using Ease and Wizz a lot lately, but I’m running into the same issue and I’m wondering if there is a way around it.

    It seems there are only a few options to use the expressions on a layer… (start only, stand and end, and all). This is fine if you’re only animating something in or out once. But I’m finding I want to use say “Back.easeOut” on a transition in, but then use “Expo.easeIn” on the same layer, at another time in the timeline. Is this possible using Ease and Wizz?

    So basically, can you put different ease types on the same layer at different times?

    I’m open to using other libraries that give more flexibility as well. Scripted movement is where its at!

    Thanks ahead of time.

    Dan Hep replied 12 years, 11 months ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    August 28, 2013 at 5:30 pm

    I think you’d have to have the code for all the different eases in the expression, and then have the expression choose the correct ease based on time, most recent keyframe number, marker number/comment, etc.

    Dan

  • Eric Guiliani

    August 28, 2013 at 5:35 pm

    Thanks Dan, any code examples on this? I’m pretty new with Expressions so I wouldn’t even know where to start.

  • Dan Ebberts

    August 28, 2013 at 6:46 pm

    Have you got a couple of ease expressions you can post?

    Dan

  • Eric Guiliani

    August 29, 2013 at 9:33 pm

    Sure…below:

    // Ease and Wizz 2.0.4 : inOutExpo : All keyframes
    // Ian Haigh (https://ianhaigh.com/easeandwizz/)
    // Last built: 2013-07-05T11:46:51+10:00
    // some defaults
    var p = 0.81; // period for elastic
    var a = 50; // amplitude for elastic
    var s = 1.70158; // overshoot amount for "back"
    function easeandwizz_inOutExpo(t, b, c, d) {
    if (t==0) return b;
    if (t==d) return b+c;
    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
    }
    function easeAndWizz() {
    var n = 0;
    if (numKeys > 0) {
    n = nearestKey(time).index;
    if (key(n).time > time) { n-- }
    }
    try {
    var key1 = key(n);
    var key2 = key(n+1);
    } catch(e) {
    return null;
    }

    // determine how many dimensions the keyframes need
    var dim = 1; // It's gotta have at least ONE dimension
    try {
    key(1)[1];
    dim = 2;
    key(1)[2];
    dim = 3;
    } catch(e) {}
    t = time - key1.time;
    d = key2.time - key1.time;
    sX = key1[0];
    eX = key2[0] - key1[0];
    if (dim >= 2) {
    sY = key1[1];
    eY = key2[1] - key1[1];
    if (dim >= 3) {
    sZ = key1[2];
    eZ = key2[2] - key1[2];
    }
    }
    if ((time < key1.time) || (time > key2.time)) {
    return value;
    } else {
    val1 = easeandwizz_inOutExpo(t, sX, eX, d, a, p, s);
    switch (dim) {
    case 1:
    return val1;
    break;
    case 2:
    val2 = easeandwizz_inOutExpo(t, sY, eY, d, a, p, s);
    return [val1, val2];
    break;
    case 3:
    val2 = easeandwizz_inOutExpo(t, sY, eY, d, a, p, s);
    val3 = easeandwizz_inOutExpo(t, sZ, eZ, d, a, p, s);
    return [val1, val2, val3];
    break;
    default:
    return null;
    }
    }
    }
    (easeAndWizz() || value);

    The only thing that would change ease-wise would be the Type of ease, say "Back.easeIn" for instance.

  • Dan Ebberts

    August 30, 2013 at 12:05 am

    That’s a little more complicated than I was hoping. You could do it, but it would be quite a bit of work. You would need to include the functions for each of the eases and then have a mechanism to tell it which ease to use at which keyframe. You might be a able to use markers for that, or include an array in the expression, with an entry for each keyframe. Do-able, but not trivial.

    Dan

  • Dan Hep

    August 30, 2013 at 2:20 pm

    i think the easiest way for you would be to let the script duplicate the layer you are working with and than let it set the in point of the new layer to the out point of the first layer (see code). then you can set a new expression for the new layer.

    newLayer: Layer where you want to set “Expo out” or something
    theLayer : Layer which already contains an Expression “Expo In”
    (you also should set some keyframes)

    im using it like this, if there is a better way, i would be happy to hear it.

    var newLayer = theLayer.duplicate();
    newLayer.inPoint = theLayer.outPoint;

    newLayer.property("xRotation").expression= "expression code goes here"

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