Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 2 auto resizing text layers staying the same size

  • 2 auto resizing text layers staying the same size

    Posted by Daniel Casey on November 8, 2022 at 2:30 pm

    Hi,

     

    I want to create 2 text layers that auto size to fit inside the comp,

    I also want the 2 text layers to stay the same size, so both layers match whichever text layer is the smallest.

     

    Can this be done?

     

    Thanks

    Daniel Casey replied 3 years, 6 months ago 4 Members · 8 Replies
  • 8 Replies
  • Julian Chojnacki

    November 8, 2022 at 3:36 pm

    Hi Daniel,

    something like this?

    https://www.youtube.com/watch?v=YW8EI9a6DHY

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Daniel Casey

    November 8, 2022 at 3:43 pm

    Hi Julian,

    yes to begin with, I know how to auto scale a layer to fit a comp,

    now I just need to know how to work it with 2 text layer

    for example, if text layer 1 is larger than text layer 2, scale down text layer to match text layer 2.

    and vice versa if text layer 2 is larger

  • Adam Greenberg

    November 8, 2022 at 6:13 pm

    yes, your 2 layers should parent to a null and that null has the expression that resizes down when the total of the 2 goes over your max

  • Daniel Casey

    November 8, 2022 at 6:41 pm

    Thanks Adam, any idea what that expression looks like?

  • Tomas Bumbulevičius

    November 10, 2022 at 11:07 am

    Hey Daniel,

    with expressions, you can do it this way:
    1. Take both layers sourceRectAtTime sizes of width;
    2. Then compare as Math.max(layerA, layerB) or Math.min(layerA, layerB);
    3. Based on above, you will know which is bigger. Then, change the scaling of the other layer by multiplying width difference ratio.

  • Adam Greenberg

    November 11, 2022 at 1:59 am

    I use code on a null – but you need to change the math for your needs

    x= thisComp.layer(“TEXT1”).sourceRectAtTime(3).width;

    y= thisComp.layer(“TEXT2”).sourceRectAtTime(3).width;

    a=(1920/x)*44;

    b=(1920/y)*44;

    xclamp= clamp(a,1,100);

    yclamp= clamp(b,1,100);

    if(x>y) [xclamp,xclamp]; else [yclamp,yclamp]

  • Adam Greenberg

    November 11, 2022 at 2:03 am

    are your layers on top of each other or next to each other, I had just posted in another thread in order to update this exact expression in case I have multiple layers that need this, otherwise it gets long to write, if 1 is bigger than 2 else if 1 is bigger than 3, else if 1 is bigger than 4, else if 2 is bigger than 3, etc… you see how quickly that method can be tedious.

  • Daniel Casey

    November 11, 2022 at 10:31 am

    Good morning Adam,

    my layers are on top of each other, and this expression worked like a charm

    thank you very much

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