Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression for Single Keyframe linked to Point Control

  • Expression for Single Keyframe linked to Point Control

    Posted by Max Williamson on March 19, 2019 at 10:59 pm

    Hey There!

    Hoping someone can help me with the following problem. I am templating a fairly complex animation for a team of editors and was hoping to create a user-friendly template. What I am trying to do is link the position (x,y) of two keyframes to a Point Control without adjusting the other keyframes on the layer. Is this possible with an expression?

    The idea is to quickly reframe a video layer within a frame while maintaining the position of the first and last keyframes.

    Thank you to anyone who can help!

    M

    Max Williamson replied 7 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    March 20, 2019 at 6:54 am

    I assume your mid 2 keyframes are equal. If you use normal ease or no ease, you can do this:

    pointControl = thisLayer("Effects")("Point Control")("Point");
    time1 = key(1).time;
    time2 = key(2).time;
    time3 = key(3).time;
    time4 = key(4).time;

    if (time < time1) {
    value;
    } else if (time < key(2).time) {
    ease(time, time1, time2, valueAtTime(time1), pointControl);
    } else if (time < time3) {
    pointControl;
    } else if (time < time4) {
    ease(time, time3, time4, pointControl, valueAtTime(time4));
    } else value;

    If you use no ease, just replace ease with linear. If you need further clarification and/or help, don’t hesitate to ask.

    Andrei
    My Envato portfolio.

  • Max Williamson

    March 20, 2019 at 11:35 pm

    Sorry I may have spoken too soon. With the ease and wizz expression, how do I tie this in?

    function easeandwizz_inoutExpo(t, b, c, d) {
    var CORRECTION = .000976563;
    var v;
    if ((t/=d/2) < 1) {
    v = Math.pow(2, 10 * (t – 1)) – CORRECTION;
    } else {
    v = (-Math.pow(2, -10 * (t – 1)) + 2) + CORRECTION;
    }
    return b + (v/2) * c;
    }

    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);
    switch (dim) {
    case 1:
    return val1;
    break;
    case 2:
    val2 = easeandwizz_inoutExpo(t, sY, eY, d);
    return [val1, val2];
    break;
    case 3:
    val2 = easeandwizz_inoutExpo(t, sY, eY, d);
    val3 = easeandwizz_inoutExpo(t, sZ, eZ, d);
    return [val1, val2, val3];
    break;
    default:
    return null;
    }
    }
    }

    (easeAndWizz() || value);

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