ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How can I modify this expression to make it work with multiple text layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Finn Hitchcock
How can I modify this expression to make it work with multiple text layers
on Nov 16, 2019 at 9:26:47 pm

Hi,

I've got this expression which I use to auto size a rectangle to the size and letters of the text. I have been trying to modify/create an expression which does this, with 2 text layers.

(I'm putting the expression in rectangle size)

Expression:
L=thisComp.layer("text");
X=L.sourceRectAtTime().width;
Y=L.sourceRectAtTime().height;
[X,Y]


Thanks in advance for help!

F :)

L=thisComp.layer("text");
X=L.sourceRectAtTime().width;
Y=L.sourceRectAtTime().height;
[X,Y]


Return to posts index

Dan Ebberts
Re: How can I modify this expression to make it work with multiple text layers
on Nov 16, 2019 at 10:31:49 pm

This is a kind of general solution, but it should do what you're looking for:

L1 = thisComp.layer("text 1");
r1 = L1.sourceRectAtTime();
ul1 = L1.toComp([r1.left,r1.top]);
lr1 = L1.toComp([r1.left+r1.width,r1.top+r1.height]);
L2 = thisComp.layer("text 2");
r2 = L2.sourceRectAtTime();
ul2 = L2.toComp([r2.left,r2.top]);
lr2 = L2.toComp([r2.left+r2.width,r2.top+r2.height]);
ulTot = [Math.min(ul1[0],ul2[0]),Math.min(ul1[1],ul2[1])];
lrTot = [Math.max(lr1[0],lr2[0]),Math.max(lr1[1],lr2[1])];
lrTot - ulTot


Dan



Return to posts index

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