-
Text Box Constraints
Hi, expression geniuses!
I’m a veteran AE user, but have never been able to get my head around expressions, and have been scratching my head, over what I think should be quite a simple fix, but I’m just too stupid! If anyone could help, I’d be extremely grateful. I need to create a rounded text box, which will become a MOGRT, which grows with the amount of text in the paragraph. The box needs to have a series of parameters: It needs to be locked at the top left, so it doesn’t move or grow upwards; It needs to have a fixed width (eg 400 pixels) and a minimum height of 200 pixels: It needs to grow downwards with the amount of text input, and I need to have control over the amount of pixels of margin I have between the text and the box.
So far, I have these parameters, which do everything I need, apart from fixing the width to 400 pixels and stopping the box from going below 200 pixels in height:
Rectangle Path:
margin = 31;
text_width = thisComp.layer(“Text”).sourceRectAtTime().width;
text_height = thisComp.layer(“Text”).sourceRectAtTime().height;
box_width = text_width + margin*2;
box_height = text_height + margin*2;
[box_width, box_height]
Rectangle Position:
text_height = thisComp.layer(“Text”).sourceRectAtTime().height;
[0, text_height/2]
Transform:Rectangle Position:
t = thisComp.layer(“Text”);
tRect = t.sourceRectAtTime(time,false);
tUL = t.toComp([tRect.left,tRect.top]);
tLR = t.toComp([tRect.left+tRect.width,tRect.top+tRect.height]);
tCenter = (tUL + tLR)/2
myRect = sourceRectAtTime(time,false);
myUL = toComp([myRect.left,myRect.top]);
myLR = toComp([myRect.left+myRect.width,myRect.top+myRect.height]);
myCenter = (myUL + myLR)/2
delta = myCenter – tCenter;
value – delta
As I said earlier, if anyone could help me out, I’d be very grateful.