Activity › Forums › Adobe After Effects Expressions › Scale / Position Expression
-
Scale / Position Expression
Posted by Rafael Cruz on January 23, 2009 at 4:48 pmI am having a little difficulty with some basic expressions. I am trying to create a relationship between the position and scale of a group of images. The goal is to have a string of images pass before the camera, where the center-most image at any given time is large, and the outlying images remain small. The effect I’m going for is similar to the dock on a Mac.
I’d appreciate any help.
Thanks!Alberto Garcia replied 16 years, 7 months ago 4 Members · 12 Replies -
12 Replies
-
Darby Edelen
January 23, 2009 at 6:29 pmYou’ll need to determine the layer’s distance from the vertical center of the composition and then vary the scale based on that.
Here’s one possible implementation:
f = 2; //factor to increase scale by
min = 0; //distance in pixels from the center where the layer is at full scale
max = 300; //distance in pixels from the center where the layer is at 'normal' scale
c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition
p = toComp(anchorPoint); //location of the current layer in the composition
d = Math.abs((p - c)[0]); //distance from the center along the x-axis
ease(d, min, max, f * value, value);
Darby Edelen
-
Rafael Cruz
January 23, 2009 at 6:43 pmThanks for your help Darby.
Simple, functional, great.
How would I apply this expression to the y-axis? -
Darby Edelen
January 23, 2009 at 7:05 pmDo you want it to scale based on the distance from the center without regard for the axis? Or do you only want to take into account the distance along the y axis?
Darby Edelen
-
Rafael Cruz
January 23, 2009 at 7:18 pmI am looking to apply the expression solely to the y-axis.
*out of curiosity*
I’d like to try swapping scale for z-axis position. The idea being that when I move the image toward center-screen (say, on the y-axis) the image advances on the z-axis.
If it’s not any trouble if love to know how I could work a tweak like that as well.Again, thanks for your time.
-
Rafael Cruz
January 24, 2009 at 5:59 pmI hope I wasn’t asking for too much in my last post.
I really appreciate the help you given so far, and if possible I’d love to know how to epply the expression you suggested on the y-axis. -
Filip Vandueren
January 24, 2009 at 7:41 pmf = 2; //factor to increase scale by min = 0; //distance in pixels from the center where the layer is at full scale max = 300; //distance in pixels from the center where the layer is at 'normal' scale c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition p = toComp(anchorPoint); //location of the current layer in the composition d = Math.abs((p - c)[0]); //distance from the center along the x-axis ease(d, min, max, [value[0], f * value[1]], value); z = -500; //value to move in Z min = 0; //distance in pixels from the center where the layer is at full scale max = 300; //distance in pixels from the center where the layer is at 'normal' scale c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition p = toComp(anchorPoint); //location of the current layer in the composition d = Math.abs((p - c)[0]); //distance from the center along the x-axis ease(d, min, max, [value[0], value[1], value[2]+z], value);
To stretch only the Y-axis (I assume that’s what you meant) try the first exp.
For subtracting from the z-value of position try the second.
-
Rafael Cruz
January 24, 2009 at 9:06 pmThanks for your time and help Filip.
I need to clarify my request. Darby posted an expression which increased the scale of an image as it approached center-screen on the x-axis alone. So the image grows and shrinks normally as it changes position along the x-axis only (based on it’s position relative to the center).
I would like to do the same the the position of the image along the y-axis.
-
Filip Vandueren
January 24, 2009 at 11:59 pmOk in the second to last line of darby’s expression just change the final [0] to [1]
meaning you want to look at the second element of the array that describes position (y) instead of the first (x) -
Rafael Cruz
January 25, 2009 at 3:36 pmThanks Filip!
So simple.
And yet it would have taken me quite a while to figure out. -
Darby Edelen
January 25, 2009 at 11:24 pmSorry I hadn’t checked in on this thread in a while 🙂
Changes to my original code are in bold. Hopefully this helps you break the parts down a bit more conceptually.
You would apply this to the position property on a 3D layer.
offset = -500; //distance to move on the z-axis
min = 0; //distance in pixels from the center where the layer is at full scale
max = 300; //distance in pixels from the center where the layer is at 'normal' scale
c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition
p = toComp(anchorPoint); //location of the current layer in the composition
d = Math.abs((p - c)[1]); //distance from the center along the y-axis
z = ease(d, min, max, offset, 0);
value + [0,0,z]Darby Edelen
Reply to this Discussion! Login or Sign Up