Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scale in relation to position in comp

  • Scale in relation to position in comp

    Posted by Chris Gosling on May 27, 2014 at 11:51 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]

    Dan Ebberts replied 7 years, 3 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 27, 2014 at 4:51 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

  • Chris Gosling

    May 27, 2014 at 4:56 pm

    Thanx a million Dan – just the trick. Know I just have try and understand it 😉

    C

  • Alexandre Maye

    February 5, 2019 at 10:39 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 ! 🙂

  • Dan Ebberts

    February 5, 2019 at 6:24 pm

    Try changing the last line to:

    value + x

    or maybe just:

    x

    (depending on how you want the opacity to respond)

    Dan

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