on Oct 9, 2019 at 10:36:14 am Last Edited By aniello ferrone on Oct 9, 2019 at 11:14:47 am
Hi masters, how are you? I saw a lot of guide to self-resize box, but nobody seems to care about this problem.
I made an auto-resize text box, and i really like this expression I used in the position of the shape layer, that allows me to scale the box proportionally and justify the text (paragraph) both right and left. Here it is
var s = thisComp.layer("Text") ;
var h = s.sourceRectAtTime().height/2 ;
var w = s.sourceRectAtTime().width/2 ;
var t = s.sourceRectAtTime().top ;
var l= s.sourceRectAtTime().left ;
Hey Aniello, try applying the following expression to shape's anchor point. It will stick in the middle for this case.
In order to changes its anchor point placement, adjust value in the brackets, to reflect it.
Currently, it reads 'take left value of the layer, add half of layer's width' for X, and then 'take top value of the layer and add half of its height'. This results to a center value in both, x and y. Based on this relation, you will manage to make it work to your case.
sourceSize = thisLayer.sourceRectAtTime(0, false);
T = sourceSize.top;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;