Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Separate width and height in scale expression

  • Separate width and height in scale expression

    Posted by Brian Fisher on January 2, 2010 at 6:51 pm

    Hi, I”m sure some of you are familiar with this expression to animate scale at a layer marker from the Adobe website:

    n = 0;
    t = 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;

    amp = 15;
    freq = 5;
    decay = 3.0;

    angle = freq * 2 * Math.PI * t;
    scaleFact = (100 + amp * Math.sin(angle) / Math.exp(decay * t)) / 100;
    [value[0] * scaleFact, value[1] / scaleFact];

    Well, what I’d like to do is to be able to control the width and height element of this expression separately – so that the object squashes more than it stretches. I have the other parameters set up as sliders, and I’d like to add a couple more – one each for width and height.

    Anyone feeling mathematical?

    Mac Pro, 10.5.8, 2×2.66GHz, 6GB RAM, GeForce 8800GT 512MB

    Jonathan Marino replied 13 years, 8 months ago 4 Members · 3 Replies
  • 3 Replies
  • Tim West

    January 3, 2010 at 11:21 am

    Definitely not an expressions expert myself but I believe the info you’re looking for is on here somewhere:
    https://www.motionscript.com/

    Good luck.

  • Bartek Skorupa

    January 4, 2010 at 8:15 am

    Try this:

    —————————————–
    n = 0;
    t = 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;

    ampX = 15;
    ampY = 60;
    freq = 5;
    decay = 3.0;

    angle = freq * 2 * Math.PI * t;
    scaleFactX = (100 + ampX * Math.sin(angle) / Math.exp(decay * t)) / 100;
    scaleFactY = (100 + ampY * Math.sin(angle) / Math.exp(decay * t)) / 100;

    x=value[0] * scaleFactX;
    y=value[1] / scaleFactY;

    [x,y]
    —————————-

    You can change values of ampX, and ampY to get the desired results. You can attach them to sliders if you want.

    Bartek Skorupa
    Warszawa, Poland

  • Jonathan Marino

    September 14, 2012 at 7:42 pm

    For those interested in just separating the scale values, similar to Separate X,Y,Z position

    Add 3 Slider Control Effects to your Layer
    Name them (This is important- they can be any name, but it must match expression):
    xScale
    yScale
    zScale

    Then in the scale properties of your layer, add this expression:
    x = effect(“xScale”)(“Slider”);
    y = effect(“yScale”)(“Slider”);
    z = effect(“zScale”)(“Slider”);
    [x, y, z]

    For 2D layers, simply delete the z properties:

    x = effect(“xScale”)(“Slider”);
    y = effect(“yScale”)(“Slider”);
    [x, y]

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