ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Scale in relation to position in comp

FAQ   •   VIEW ALL
 Scale in relation to position in comp on May 27, 2014 at 11:51:16 am

I have found the following expression that adjusts the scale of a layer based on it's x-position in a comp

But what I need to do is base it's x-position of a parent comp.

Example:
I have a comp containing a static timeline with icons. As the comp moves along the x-axis in a parent comp then the icons need to scale up and then down as they approach and pass the centre of the parent comp.

I am pretty sure that I need to change the layer positioning space somehow but I am really confused in that regard.

Any help would be appreciated.

Chris

```offset = 100; //amount to scale up 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 x = ease(d, min, max, offset, 0); value + [x,x,0]```

 Re: Scale in relation to position in compon May 27, 2014 at 4:51:30 pm

Try this (change the name of the parent comp to match yours):

offset = 100;
min = 0
max = 300;

C = comp("Parent Comp");
L = C.layer(thisComp.name);
center = [C.width, C.height]/2;
p = L.toComp(toComp(anchorPoint));
d = Math.abs((p - center)[0]);
x = ease(d, min, max, offset, 0);
value + [x,x,0]

Dan

 Re: Scale in relation to position in compon May 27, 2014 at 4:56:33 pm

Thanx a million Dan - just the trick. Know I just have try and understand it ;-)

C

 Re: Scale in relation to position in compon Feb 5, 2019 at 10:39:17 am

Hi there,

Great expression ! thanks a lot !
How can I apply this method but not to the scale but to the opacity ?

Thanks a lot ! :-)

 Re: Scale in relation to position in compon Feb 5, 2019 at 6:24:38 pm

Try changing the last line to:

value + x

or maybe just:

x

(depending on how you want the opacity to respond)

Dan