Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Postion to scale

  • Posted by Criis Daw on June 11, 2014 at 11:11 am

    Hi.. can one of you help me with something that is probably very simple (once you know how !!)

    i am trying to have the y scale of a matte layer linked to the y position of another.

    There are two bars that wipe across the screen, one top to bottom the other bottom to top. from where they cross at the mid point (y=540) i would like to attach the y scale of the matte so it scales up from zero to a percentage that is governed by the final resting point of the bar . the resting point of the bar will vary depending on how much text needs to be revealed.

    Clear ??

    thanks

    Criis Daw replied 11 years, 11 months ago 2 Members · 7 Replies
  • 7 Replies
  • Criis Daw

    June 11, 2014 at 1:29 pm

    having tied and failed a few more times i have figured out what i want the expression to say .. but lack the skills to say it.

    So in english it goes like this:

    let the y scale of the matte = 0% when the wipe is at y position 540.

    increase the y scale by (1080/100)% for every pixel above 540 that the wipe travels on the y axis.

    So i am trying to make the the scale number work in relation to pixel measurements on the screen and have <540 = 0% scale

    any help much appreciated.

    Ta

  • George Goodman

    June 11, 2014 at 1:41 pm

    Just put this expression in the scale property of the matte and change the layer name to the layer you want the position to be taken from

    [value[0],thisComp.layer("ParentPosition").transform.position[1]]

    “|_ (°_0) _|”

    Sincerely,

    George

    http://www.vimeo.com/georgegoodman
    http://www.linkedin.com/in/georgefranklingoodman

  • Criis Daw

    June 11, 2014 at 2:00 pm

    Thanks for the reply

    but that gives me a straight conversion of pixels in percent.

    for example when the y position is 250 my matte scales to 250 %

    250 is 23% of a 1080 y axis which is the scale i would predict….

    But i dont want any scaling untill the wipe layer has passed the mid point at 540y.

    when the wipe has gone past the mid point and come to rest at say 700 i want a scaling of 700-540 = 160 pixels

    this 160 then needs to be turned into a % of 1080 so i would get a scaling of ~ 15%.

    make sense ?

    I can see the maths of what i am trying to do but how to write it in expessions has got me ….

  • George Goodman

    June 11, 2014 at 2:14 pm

    An extra 15% of the scale or 15% of the screen? This would give you the extra amount of scale. So it’s saying, once the y position is greater than 540, subtract that amount from its current y position, find the percentage of 1080 that is, and add it to the scale. The thing is, I’m guessing you may actually just be wanting to add the amount of pixels it is past the 540 in terms of scale, but I’m not entirely sure.

    ypos=thisComp.layer("Shape Layer 2").transform.position[1];
    if (ypos>540) [value[0], value[1]+(ypos - 540)/10.8] else [value[0],value[1]]

    “|_ (°_0) _|”

    Sincerely,

    George

    http://www.vimeo.com/georgegoodman
    http://www.linkedin.com/in/georgefranklingoodman

  • George Goodman

    June 11, 2014 at 2:29 pm

    If you’re looking for the latter of what I described, something along these lines should work (again you’ll need to change the layer name from Shape Layer 2 to whatever.

    ypos=thisComp.layer("Shape Layer 2").transform.position[1];
    ypos1=(ypos - 540)/10.8;
    yscale=transform.scale[1];
    tall=thisComp.height;
    if (ypos>540) [value[0], value[1]+[ypos1*(tall/100)]] else [value[0],value[1]]

    “|_ (°_0) _|”

    Sincerely,

    George

    http://www.vimeo.com/georgegoodman
    http://www.linkedin.com/in/georgefranklingoodman

  • Criis Daw

    June 11, 2014 at 2:34 pm

    thanks for the reply.

    i will have a proper look later. Have been diverted into less interesting work.

    But in the example i gave I only want the scaling to to be relative to any value above 540. So it would be a total of 15%.

    i will have a look at your examples latet and see how i get on.

    Many thanks

    Chris

  • Criis Daw

    June 11, 2014 at 4:57 pm

    this worked

    ypos=thisComp.layer(“color bar_base”).transform.yPosition
    if (ypos>534) [value[0], value[1]+(ypos – 549)/5.4] else [value[0],value[1]]

    thanks a million.

    I had to tweek the numbers slightly as the matte layer scales out from the centre on y and add 25 on here ypos – 549 to compensate for the size of the bar that make the wipe.

    Nice one mate .

    I owe you a beer ..

    (i will be London in the near future if you want to claim that pint !!)

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