Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Aligning two text layers to be centered vertically

  • Aligning two text layers to be centered vertically

    Posted by Andrew Mcclure on May 13, 2018 at 4:40 pm

    Hi all, currently looking for a way to align two text layers together so they will remain centered vertically even if the amount of text changes. What is the best way to go about doing this?

    Using this expression at the moment to combine them although I haven’t found a way to center them both-

    gap = 10;
    L = thisComp.layer(“text”);
    r = L.sourceRectAtTime(0,true);
    y = L.position[1] + (r.top + r.height – L.anchorPoint[1])*L.scale[1]/100 + scale[1]*height/200 + gap;
    [value[0],y]

    Thank you!

    Kalleheikki Kannisto replied 8 years ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    May 13, 2018 at 5:02 pm

    You just need to vertically align the individual text layers by moving them up based on the layer height (sourceRectAtTime). You don’t need to take into account any other layers. If they are all center aligned vertically the result is that they are aligned with each other.

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Andrew Mcclure

    May 13, 2018 at 5:39 pm

    Hey Kalleheikki, sorry my image was a bit confusing!

    screenshot2018-05-13at18.34.59.png

    The white text and red text are the two separate text layers that I’m trying to align vertically

  • Kalleheikki Kannisto

    May 14, 2018 at 3:30 pm

    Ah, ok, I see. You would want to align the top piece of text based on the total height of the two layers, and then the bottom piece of text at the bottom of the first piece of text. So that would be two separate position expressions, one for the top, one for the bottom piece.

    You current expression seems suitable for the bottom layer.

    Kalleheikki Kannisto
    Senior Graphic Designer

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