Skip to main content
Woms
Participant
September 21, 2017
Answered

Change Size of Shape Layer based on Text Layer

  • September 21, 2017
  • 1 reply
  • 10986 views

Hey guys,

I'm looking for an expression (preferably) to change the width of a plain ol' black rectangular box that's sitting beneath a layer of text. The text layer is going to change length, and I therefore need the black box to adjust with the text and change length accordingly. I'm sure there's a simple way to do this, but I've been fighting a cold all week and my brain is a little fried.

Any suggestions?

This topic has been closed for replies.
Correct answer Kyle Hamrick

There's a (relatively new) expression function that does exactly this: "sourceRectAtTime"
SourceRectAtTime() Expression- Adobe After Effects tutorial - YouTube

1 reply

Kyle Hamrick
Community Expert
Kyle HamrickCommunity ExpertCorrect answer
Community Expert
September 21, 2017

There's a (relatively new) expression function that does exactly this: "sourceRectAtTime"
SourceRectAtTime() Expression- Adobe After Effects tutorial - YouTube

Woms
WomsAuthor
Participant
September 21, 2017

Hi Kyle,

Thanks! Your link was helpful. This is what I ended up with:

theTextLayer = thisComp.layer("TEXT");

p = 50;

box = theTextLayer.sourceRectAtTime(time);

x = box.width + (p*2);

y = 150;

[x,y]