Skip to main content
Participant
June 27, 2024
Answered

Problems with animated text using sourceRectAtTime

  • June 27, 2024
  • 2 replies
  • 1080 views

Hello, Im doing an animated text inside a Rectangle.
The animation is like the "Typewriter" template, but instead of opacity I used scale 0%

 

The animation works great if i play it from frame 0, but if i grab the Text and Rectangle layer and move to the frame 100, the Rectangle is already in full size when my text is empty. 

Is like the size of my text is being read from the layer timeline, instead of the composition timeline.

Expression im using in my Rectangle

x = thisComp.layer("text").sourceRectAtTime().width;
y = thisComp.layer("text").sourceRectAtTime().height;

[x,y]

This topic has been closed for replies.
Correct answer Dan Ebberts

sourceRectAtTime() has a built-in time parameter, so I think you just need to do something like this:

L = thisComp.layer("text");
x = L.sourceRectAtTime(time - L.inPoint).width;
y = L.sourceRectAtTime(time - L.inPoint).height;
[x,y]

2 replies

Community Expert
June 27, 2024

If you are using a text animator or scale, you will have to throw in a multiplier for Position to keep the rectangle lined up because the rectangle size will grow using Dan's expression, but it will not be offset. You will have to take sourceRectAtTime(when the text is fully revealed) and create a linear interpolation method that adjusts the Rectangle 1/Position so the box expands from the left side of the text instead of the middle. You still may have a problem with the rectangle jumping around because the text scales from the middle. I don't have time to fiddle with it right now, but I have created similar things in the past and ended up relying on a simple expression that uses the size of the text at the last keyframe and a simple linear interpolation between the first and last keyframes. 

 

 

Participant
June 28, 2024

Luckily i have the text aligned to the side, and in the Rectangle i have the following Expression in position

content("BOX").content("Rectangle Path 1").size/2

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
June 27, 2024

sourceRectAtTime() has a built-in time parameter, so I think you just need to do something like this:

L = thisComp.layer("text");
x = L.sourceRectAtTime(time - L.inPoint).width;
y = L.sourceRectAtTime(time - L.inPoint).height;
[x,y]
Participant
June 28, 2024

*chef kiss* works perfectly thanks 😄