Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adjusting Dan’s Squash and Stretch Expression

  • Adjusting Dan’s Squash and Stretch Expression

    Posted by Zach Meissner on April 14, 2010 at 7:14 pm

    I am trying to make the expression only effect the X axis instead of the Y. I can’t quite get the expression right. I swapped out the X and Y in the expression, but it did not work. How can I get this to only squash and stretch the X axis?

    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

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

    April 15, 2010 at 12:35 am

    Try it this way:

    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;
    x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
    [x,value[1]]
    }else{
    value
    }

    Dan

  • Zach Meissner

    April 15, 2010 at 1:21 pm

    Worked like a charm! Thanks Dan!

    So, I tried to just interchange the X and Y values, which did not work, and I noticed you must also change the ‘value[1]’ portion.

    Why does x=scale[0] buy y=scale[1]?

    I would figure whichever active parameter would equal 1.
    Still learning how these expressions work.

    http://www.lab316.com

  • Dan Ebberts

    April 15, 2010 at 1:32 pm

    Multi-dimensional properties like scale are represented by JavaScript arrays. So, x is always represented by the value at index 0, y is at index 1, (and z would be at index 2).

    Dan

  • Zach Meissner

    April 15, 2010 at 2:16 pm

    Gotcha, thanks again Dan!

    http://www.lab316.com

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