Skip to main content
Participating Frequently
January 9, 2024
Question

Scale from One End Animation - Reactive Text Box

  • January 9, 2024
  • 2 replies
  • 178 views

Hey there guys,

 

quite new to expressions, and I'm just trying to create a text box which reacts to the amount of text inside, and also animates so the text appears as the box scales from left to right.

 

I can think of a way to do this using a separate shape layer as a mask, but is there a way to keep it to one text box and one text layer? The problem I'm having is that my current text box's rectangle size property is used up with the expressions needed to have it react to the text. Usually I would set the anchor point to the left, and then use the size to create this wipe on effect.

 

Any ideas? I'll attach the aep file I've been working on so far.

 

 

 

This topic has been closed for replies.

2 replies

Community Expert
January 10, 2024

I see a couple of problems with your basic comp. First, reset the text layer's Anchor Point. Second, delete the Contents/Rectangle 1/Rectangle 1 Path/Position expression. Make sure all of the other Rectangle properties except the Transform Rectangle 1 properties are reset.

 

Lastly, add this expression to BG Box/Transform/Position to tie

the position of the shape layer to the position of the text layer:

 

var s = thisComp.layer("This is my layer");
var w = s.sourceRectAtTime().width/2;
var h = s.sourceRectAtTime().height/2;
var l = s.sourceRectAtTime().left;
var t = s.sourceRectAtTime().top;

[w+l,h+t] + s.position

 

Now, your BG Box layer will stay lined up with the text layer. 

 

To help with the rest of the problem, try explaining the design goal a little more clearly.  If you are using a Text animator to move the text into position, you can add a time value to measure the text area size at 2 or 3 seconds. If you want to tie the number of characters in the final position to the width of the text box, you can use the start or end values of the Text Animator to modify the text box size so it grows as characters land in their final position. There are too many different design ideas in my head to give you a meaningful solution to your problem without a better understanding of your design.

 

There is nothing keeping you from using the Background text layer as an Inverted Alpha Matte for the text layer and then turning the layer back on. If you have a Text Animator that moves the text into position in 2 seconds using sourceRectAtTime(2), then the text will not show up until it moves inside the background layer.

Mylenium
Legend
January 9, 2024

Nothing stops you from grouping your shape layer and use the group transform to align things. One way or the other the only thing required is to subtract half the width of the rectangle to accommodate any position changes caused by the size changing.

 

Mylenium