ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Changing X-scale based on position.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kerr Scott
Changing X-scale based on position.
on Dec 28, 2017 at 12:51:12 pm

Hi there,

I'm looking for a way to change just the Y scale based on the position or distance from a certain point. For example as an object moves further away from the anchor point of another object it scales the Y position (gets slimmer) as it moves away from it.

So far I've found this which does both scale dimensions and only does it to the centre of the comp. Not a specific point / null / layer etc:

Any help is greatly appreciated. Thanks in advance!

pct = .50; // increase by 25%
r = 100; // distance to being increasing scale
center = thisComp.width/2;
p = toWorld(anchorPoint);
d = length(p,[center,p[1]]);
mult = ease(d,0,r,pct,0);

Return to posts index

Kevin Camp
Re: Changing X-scale based on position.
on Dec 28, 2017 at 8:01:07 pm

try this:
target = thisComp.layer("Null 1"); //change this to the layer you want to target
mul = .001; //change this to effect how much change in scale
d = length( position, target.position );
xScale = mul * value[0] * d;
[ xScale, value[1], ]

the expression assumes that neither layer is parented (or if they are they are parented to the same layer). if the layers are parented to other layers, we'll need to add a layer-space transform function.

Kevin Camp
Art Director

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved