ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Separate width and height in scale expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brian Fisher
Separate width and height in scale expression
on Jan 2, 2010 at 6:51:40 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, 2x2.66GHz, 6GB RAM, GeForce 8800GT 512MB


Return to posts index

Tim West
Re: Separate width and height in scale expression
on Jan 3, 2010 at 11:21:37 am

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

Good luck.



Return to posts index

Bartek Skorupa
Re: Separate width and height in scale expression
on Jan 4, 2010 at 8:15:38 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


Return to posts index


Jonathan Marino
Re: Separate width and height in scale expression
on Sep 14, 2012 at 7:42:53 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]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]