Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions center text to comp using left, top, width, height?

  • center text to comp using left, top, width, height?

  • Ilya Sire

    November 28, 2021 at 2:13 pm

    Hi forum,

    How can I center text layer to middle of comp?

    I found many results use anchorPoint and position sourceRectAtTime.width/2, sourceRectAtTime.height/2, but in this case, i want it remain anchorPoint original at [0,0]

    is there any tricks to center layer using layer left, top, width, height?

    Thank you

  • Bob Fares

    November 28, 2021 at 3:07 pm

    Add this expression to the anchor point to center the anchor point to the middle:

    ———————————————————————-

    l= sourceRectAtTime().left;

    t= sourceRectAtTime().top;

    h= sourceRectAtTime().height;

    w= sourceRectAtTime().width;

    [l+w/2,t+h/2]

    —————————————————————————-

    to center the text in the middle of the comp, add this expression to the position of the same text:
    ——————————————————–

    cw = thisComp.width /2;

    ch = thisComp.height /2;

    [cw,ch]

    ———————————————————-

  • Ilya Sire

    November 28, 2021 at 9:39 pm

    Ah yes, thank you.

    I use it like this, to maintain anchorPoint [0,0]

    cw = thisComp.width /2;

    ch = thisComp.height /2;

    t= sourceRectAtTime().top;

    h= sourceRectAtTime().height;

    [cw,ch]-[0,t+h/2]

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