Forums › Adobe After Effects Expressions › Expression to centralize two text layers to comp height
-
Expression to centralize two text layers to comp height
-
Avinash Ramanath
April 6, 2021 at 5:07 am -
Trent Armstrong
April 6, 2021 at 1:52 pmIf these are all set up as precomps or all the text in one layer, this solution will work.
POSITION EXPRESSION
L = thisComp;
x = L.width * .5;
y = L.height * .5;
[x, y]
ANCHOR POINT EXPRESSION
L = thisLayer.sourceRectAtTime(time);
a = L.left;
b = L.top;
x = L.width * .5;
y = L.height * .5;
[a + x, b + y]
If you are using multiple layers to stack the lines and text together, you’ll need to do some parenting to a Null or something like that, add all the sourceRectAtTime() heights and widths together, and then do the * .5 part of the expression.
The reason I multiply times .5 instead of dividing by 2 is just habit. When dividing by the number returned from a slider or time or size etc. it’s possible to divide by zero and that breaks an expression. So, using that for width and height makes sense to me in this situation.
Log in to reply.