ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Aligning two text layers to be centered vertically

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andrew McClure
Aligning two text layers to be centered vertically
on May 13, 2018 at 4:40:12 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!


Return to posts index

Kalleheikki Kannisto
Re: Aligning two text layers to be centered vertically
on May 13, 2018 at 5:02:03 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


Return to posts index

Andrew McClure
Re: Aligning two text layers to be centered vertically
on May 13, 2018 at 5:39:43 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


Return to posts index


Kalleheikki Kannisto
Re: Aligning two text layers to be centered vertically
on May 14, 2018 at 3:30:12 pm
Last Edited By Kalleheikki Kannisto on May 14, 2018 at 3:32:29 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]