Automatic Text Box in After Effects

How to create perfect procedural and adjustable text box.

First, we need to create box that has same size and position as our text. For this let’s create Shape Layer and add an expression to Size and Position.

We will be using null that will contain all our data.

Expression for size:

JavaScript
s=thisComp.layer(index-1)
nw=s.sourceRectAtTime().width;
nh=s.sourceRectAtTime().height;
noffset=thisComp.layer("CONTROLLS").effect("Stroke")("Slider");
n[w+offset,h+offset]

We will add offset to the parameters so we can add stroke to the box.

Expression for position:

JavaScript
s=thisComp.layer(index-1)
nw=s.sourceRectAtTime().width/2;
nh=s.sourceRectAtTime().height/2;
nl=s.sourceRectAtTime().left;
nt=s.sourceRectAtTime().top;n[w+l,h+t]

Let’s parent our Text Box to the Text layer, so it will follow it. Add this expression to the Position of Text Box Layer:

JavaScript
thisComp.layer(index-1).position

To position it exactly at the bottom in the middle of the composition let’s add an expression to the Text Layer position:

JavaScript
var w=thisComp.width;
var h=thisComp.height;
var bottom_offset=thisComp.layer("CONTROLLS").effect("Bottom Offset")("Slider")
var w2=w/2;
var h2=h-bottom_offset;n[w2,h2]

Variable bottom_offset will make possible to move Text Layer from bottom of composition to the desirable height.

Leave a Reply

Your email address will not be published. Required fields are marked *