Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Modify Expand Contract expression

  • Modify Expand Contract expression

    Posted by Zach Meissner on December 18, 2008 at 11:11 pm
    maxDev = 10; // max deviation in pixels
    spd = 20; //speed of oscillation
    decay = 1.0; //how fast it slows down
    
    if (marker.numKeys > 0){
    t = time - marker.key(1).time;
    if (t >=0 ){
    x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
    y = scale[0]*scale[1]/x;
    [x,y]
    }else{
    value
    }
    }else{
    value
    } 

    Trying to modify the wonderful expand and contract expression that Dan made to only do it on the Y axis instead of both. I’m sure it’s simple, but i just cant figure it out. Thanks!

    Zach Meissner replied 16 years, 4 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    December 19, 2008 at 1:05 am

    This should do it:

    maxDev = 10; // max deviation in pixels
    spd = 20; //speed of oscillation
    decay = 1.0; //how fast it slows down

    if (marker.numKeys > 0){
    t = time – marker.key(1).time;
    if (t >=0 ){
    y = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
    [value[0],y]
    }else{
    value
    }
    }else{
    value
    }

    Dan

  • Zach Meissner

    December 19, 2008 at 6:43 am

    Thanks Dan! Is there an easy way to disable the expression with a another layer marker, or with a checkbox control? I want to change just the Y value of text to make appear to sink into the ground at a certain time, but i cant keyframe the scale because the expression is in use. I figure it’s easy to do with a layer marker but i wasn’t sure how. Thanks a bunch!!

  • Dan Ebberts

    December 19, 2008 at 3:28 pm

    Ah, I think that’s because there’s an error in the expression. Try changing the long line to this:

    y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);

    That should keep everything live for keyframing.

    Dan

  • Zach Meissner

    December 21, 2008 at 2:33 am

    Yes!! Thanks so much Dan!!

  • Zach Meissner

    December 22, 2008 at 8:33 pm

    Hey Dan, if i wanted to turn the expression on again at another layer marker, how would i modify it? I’m thinking something with the ‘key(1)’ text, but i’m not sure. Thanks!

  • Dan Ebberts

    December 22, 2008 at 8:44 pm

    This should trigger at each layer marker:

    maxDev = 10; // max deviation in pixels
    spd = 20; //speed of oscillation
    decay = 1.0; //how fast it slows down

    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n–;
    }
    }

    if (n > 0){
    t = time – marker.key(n).time;
    y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
    [value[0],y]
    }else{
    value
    }

    Dan

  • Zach Meissner

    December 23, 2008 at 9:03 pm

    Thanks so much Dan!!!

  • Zach Meissner

    April 14, 2010 at 7:05 pm

    Hi Dan, back again. Trying to get this to only be on the X axis. I’ve replaced the X and Y text, but that didn’t work.

    How can I get the expression to only do the x and not the y?

    maxDev = 10; // max deviation in pixels
    spd = 20; //speed of oscillation
    decay = 1.0; //how fast it slows down

    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }

    if (n > 0){
    t = time - marker.key(n).time;
    y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
    [value[0],y]
    }else{
    value
    }

    http://www.lab316.com

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