Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scale Up the Down at Markers

  • Scale Up the Down at Markers

    Posted by Justin Alexander on July 9, 2012 at 12:03 pm

    Hi everyone,

    I have been trying to get my layer to scale up at the first marker and then back down at the second. I have tried to copy and paste and hack at a whole heap of scripts that i have found here but alas my scripting skills are shocking.

    I would like a nice ease up and down. The script below just goes straight to the maxVal at the first marker but scales down nicely at the second. I have tried heaps of different techniques and I feel I am close but I just can’t seem to close the deal.

    Any help would be much appreciated.

    Regards

    Justin

    n = 0;
    numFrames = 5;
    t1 = marker.key(2).time;
    t2 = t1 + numFrames*thisComp.frameDuration;
    minVal = [85,85];
    maxVal = [100,100];
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }

    if (n == 0){

    ease(time,t2,t1,minVal,maxVal)

    } else {

    ease(time,t2,t1,maxVal,minVal)
    }

    Justin Alexander replied 13 years, 10 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    July 9, 2012 at 4:33 pm

    Something like this should work:


    numFrames = 5;
    minVal = [85,85];
    maxVal = [100,100];

    n = marker.numKeys;
    if (n > 1){
    d = framesToTime(numFrames);
    t1 = marker.key(1).time;
    t2 = marker.key(2).time;
    if (time < (t1+t2)/2)
    ease(time,t1,t1+d,minVal,maxVal)
    else
    ease(time,t2,t2+d,maxVal,minVal);
    }else
    value

    Dan

  • Justin Alexander

    July 9, 2012 at 10:29 pm

    Thanks so much Dan,

    worked perfectly. I see where I was all at sea, now I can go forth and make a mess of a heap more scripts.

    Regards

    Justin

  • Justin Alexander

    July 9, 2012 at 11:10 pm

    Hi Dan, speaking of messes,

    I have the following code that is working perfectly. It scales up at the first marker and scales to 0 at the second marker all with a nice little bounce that you helped me with some months ago.

    What I would love is for it to be able to scale up from zero to minVal at the inPoint. However, everything I have tried has ended up with either totally messed up scales or parts of the script being ignored completely.

    Thanks for everything so far, hope I am not pushing it by asking for more.

    Cheers

    Justin

    numFrames = 5;
    minVal = [70,70];
    maxVal = [80,80];

    rate = 1200;
    decay = 18;
    freq = .02;
    rampDur = value[0]/rate;
    w = freq*Math.PI*2;

    n = marker.numKeys;
    if (n > 1){
    d = framesToTime(numFrames);
    t1 = marker.key(1).time;
    t2 = marker.key(2).time;
    if (time &lt; (t1+t2)/2){
    if (time &lt; (t1 + rampDur)){
    s = ease(time,t1,t1+rampDur,minVal[0],maxVal[0]);
    }else{
    t = time - (t1+rampDur);
    s = value[0] + rate*Math.sin(t*w)/Math.exp(t*decay)/w;
    }
    }else{
    if (time > (t2 - rampDur)){
    s = ease(time,t2-rampDur,t2,maxVal[0],0);
    }else{
    t = (t2 - rampDur) - time;
    s = value[0] + rate*Math.sin(t*w)/Math.exp(t*decay)/w;
    }
    }
    }
    [s,s];

  • Justin Alexander

    July 9, 2012 at 11:31 pm

    It seems I can’t edit joy posts.

    Anyway, I have got the scale up at the inPoint working with an if else call in the below code. The only think I can’t get working is the nice little bounce at the start.

    numFrames = 5;
    minVal = [70,70];
    maxVal = [80,80];

    rate = 1200;
    decay = 18;
    freq = .02;
    rampDur = value[0]/rate;
    w = freq*Math.PI*2;
    n = marker.numKeys;

    if (time &lt; (inPoint + rampDur)){
    s = ease(time,inPoint,inPoint+rampDur,0,minVal[0])
     }else if (n > 1){
    d = framesToTime(numFrames);
    t1 = marker.key(1).time;
    t2 = marker.key(2).time;
    if (time &lt; (t1+t2)/2){
    if (time &lt; (t1 + rampDur)){
    s = ease(time,t1,t1+rampDur,minVal[0],maxVal[0]);
    }else{
    t = time - (t1+rampDur);
    s = value[0] + rate*Math.sin(t*w)/Math.exp(t*decay)/w;
    }
    }else{
    if (time > (t2 - rampDur)){
    s = ease(time,t2-rampDur,t2,maxVal[0],0);
    }else{
    t = (t2 - rampDur) - time;
    s = value[0] + rate*Math.sin(t*w)/Math.exp(t*decay)/w;

    }
    }
    }
    [s,s];

  • Dan Ebberts

    July 10, 2012 at 12:47 am

    I don’t have time to tear into your expression, but you might be interested in something similar that I’ve been working on. This would be for keyframed Scale animations, where you quickly ramp from one value to another, hold that value for a while, etc. It does anticipation and overshoot at each keyframe:


    freq = .5;
    decay = 12;

    if (numKeys > 0){
    k = nearestKey(time);
    if (time > k.time){
    t = time - k.time;
    amp = velocityAtTime(k.time - .001);
    w = freq*Math.PI*2;
    v = value + amp*Math.sin((t)*w)/Math.exp(decay*(t))/w;
    }else{
    t = k.time - time;
    amp = velocityAtTime(k.time + .001);
    w = freq*Math.PI*2;
    v = value - amp*Math.sin((t)*w)/Math.exp(decay*(t))/w;
    }
    [Math.max(v[0],0),Math.max(v[1],0)];
    }else
    value

    Dan

  • Justin Alexander

    July 10, 2012 at 5:02 am

    Thanks Dan,

    That brain of yours is magnificent!

    I got my original one sorted but this new script of yours is brilliant. Thanks for sharing, I think I will have many uses for it.

    Cheers

    Justin

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