Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Modify Expression ” Auto Scale Text”

  • Modify Expression ” Auto Scale Text”

  • Nuwan Thilina

    February 2, 2020 at 4:18 am

    Hello Experts, I need some help to modify the below expression.
    This auto-scale text expression works perfectly with the width of the text.
    But when changing the height of text it didn’t work.

    Can you help me to build an expression like ( width -100, height -200)?

    w=thisComp.width-100
    resize = (w/Math.round(thisLayer.sourceRectAtTime().width))*100;

    if (Math.round(thisLayer.sourceRectAtTime().width) > w){

    [resize,resize]

    }else

    [100,100];

    Really appreciate your help.

    Thank You,
    Nuwan T.

  • Walter Soyka

    February 3, 2020 at 9:10 pm

    This should do the trick:

    var maxWidth = thisComp.width - 100;
    var maxHeight = thisComp.height - 200;
    var myWidth = thisLayer.sourceRectAtTime(time).width;
    var myHeight = thisLayer.sourceRectAtTime(time).height;

    var resizeScale = Math.min(maxWidth/myWidth, maxHeight/myHeight, 1);
    [resizeScale, resizeScale] * 100

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Michael Szalapski

    February 3, 2020 at 10:42 pm

    I don’t have time to troubleshoot this right now (my machine is in the middle of a render), but in case you don’t get an answer here soon, you might also try the Creative COW expressions forum. The code-types tend to hang out there more. 🙂

    – The Great Szalam
    (The \’Great\’ stands for \’Not So Great, in fact, Extremely Humble\’)

    No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.

Viewing 1 - 3 of 3 posts

Log in to reply.

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