Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Looping a property that already has an expression

  • Looping a property that already has an expression

    Posted by Navarro Parker on January 7, 2013 at 3:27 am

    I’m using the really fantastic Ease and Wizz script from Ian Haigh that gives you more option in how values in between keyframes are interpolated.

    I’ve contacted the author and there doesn’t seem to be an easy way to add a looping option in the code.

    So, I’m coming for the expertise of Dan to see if he can make this expression loop (both normal and ping-pong)

    If the code to too unwieldy to unravel, what about linking this expression to a Point Control effect (for 2D position) or slider (for 1D effects) and then adding a simple loop_out(); to those controllers?

    // Ease and Wizz 2.1 : inOutExpo : All keyframes
    // Ian Haigh (https://ianhaigh.com/easeandwizz/)
    // Last built: 2009-12-30T13:08:29+11:00
    // some defaults
    var p = 0.8; // period for elastic
    var a = 50; // amplitude for elastic
    var s = 1.70158; // overshoot amount for "back"
    function inOutExpo(t, b, c, d, a, p) {
    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 = inOutExpo(t, sX, eX, d, a, p, s);
    switch (dim) {
    case 1:
    return val1;
    break;
    case 2:
    val2 = inOutExpo(t, sY, eY, d, a, p, s);
    return [val1, val2];
    break;
    case 3:
    val2 = inOutExpo(t, sY, eY, d, a, p, s);
    val3 = inOutExpo(t, sZ, eZ, d, a, p, s);
    return [val1, val2, val3];
    break;
    default:
    return null;
    }
    }
    }
    (easeAndWizz() || value);

    Dan Ebberts replied 13 years, 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    January 7, 2013 at 6:38 pm

    I think everywhere you reference global time in the easeAdnWizz() function, you would need to replace it with a calculated loop time (loopT), which could be calculated like this (for the “cycle” version):


    if (numKeys > 1 && time > key(numKeys).time){
    t1 = key(1).time;
    t2 = key(numKeys).time;
    span = t2 - t1;
    delta = time - t2;
    loopT = delta%span;
    }else{
    loopT = time;
    }

    It would probably take a bit of work to get it working smoothly.

    Dan

  • Navarro Parker

    January 7, 2013 at 9:31 pm

    Thanks for your input. Looks like it isn’t an easy process.

    Maybe I’ll just precomp and loop a time remap. ;/ Wish there was another way to keep it all live.

  • Dan Ebberts

    January 7, 2013 at 9:34 pm

    Drop me an email through my site–I may have something that will work for you.

    Dan

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