Activity › Forums › Adobe After Effects Expressions › Autoscale Text Box for two lines of text
-
Autoscale Text Box for two lines of text
Adam Greenberg replied 1 year, 1 month ago 2 Members · 11 Replies
-
Adam Greenberg
November 3, 2023 at 1:22 pmhere is the code for people who may stumble on this thread one day, to be applied to the path ( you need to add the path property to the rectangle of the shape layer )
margin = 30;
t1=thisComp.layer(“textLayer”);
s1=t1.sourceRectAtTime();
t2=thisComp.layer(“textLayer 2”);
s2=t2.sourceRectAtTime();
l = t1.toComp([s1.left, s1.top])[0] – margin;
r = t2.toComp([s2.left+s2.width, s1.top])[0] + margin;
t = Math.min(t1.toComp([s1.left, s1.top])[1], t2.toComp([s2.left+s2.width, s2.top])[1]) – margin;
b = Math.max(t1.toComp([s1.left, s1.top+s1.height])[1], t2.toComp([s2.left+s2.width, s2.top+s2.height])[1]) + margin;
y = thisComp.layer(“textLayer”).toComp([thisComp.layer(“textLayer”).sourceRectAtTime().left+thisComp.layer(“textLayer”).sourceRectAtTime().width,0],2)[0]+margin;
z = thisComp.layer(“textLayer 2”).toComp([thisComp.layer(“textLayer 2”).sourceRectAtTime().left+thisComp.layer(“textLayer 2”).sourceRectAtTime().width,0],2)[0]+margin;
x = Math.max(y,z);
createPath( [fromComp([l,t]), fromComp([x,t]), fromComp([x,b]), fromComp([l,b])], [],[], true);
Reply to this Discussion! Login or Sign Up