ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

SourceRectAtTime() for 2 lines of text with different sized Box

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pierre Josserand
SourceRectAtTime() for 2 lines of text with different sized Box
on Jun 7, 2019 at 12:45:09 pm
Last Edited By Pierre Josserand on Jun 7, 2019 at 1:43:25 pm

Hello everyone,

i'm working on a subtitle template and i'm having some trouble to have the desired render that i need.
basically it's a sourcerectattime() process with two text line, and the boxes in the back should have the same size of the line, i did all my template but i'm stuck at the different size boxes, i only have one box, that is the length of my longest line.
i finished my template that way to show to my client, but he really wants the separate boxes.

to explain my template :
my subtitle are on 2 text line, animated on Source text with a fading opacity at each key frame
i did expression on my text and boxes anchor point so i can change the alignement of my text and the box will stay at the same places

i have an expression in my anchor point :
a=thisComp.layer("Soustitre") .sourceRectAtTime() ;
Height=a.height;
Width=a.width;
Left=a.left;
Top=a.top;

x=Left+Width/2;
y=Top+Height/2;

[x,y]


and one in my opacity so my text fade before each key frame :

fadeTime = .3;

txt = text.sourceText;

if (txt.numKeys > 0){
t = txt.nearestKey(time).time;
if (time &lt; t)
ease(time,t-fadeTime,t,100,0)
else
ease(time,t,t+fadeTime,0,100);
}else
value


then i created a shape layer box :
with an expression in my size, so it copy my text sizeand i added a controller for the padding :

a=thisComp.layer("Soustitre") .sourceRectAtTime() ;

Height=a.height;
Width=a.width;

p=effect("Box Size") ("Curseur") ;
x=Width+p;
y=Height+p;

[x,y]

and another one in my anchor point:

a=thisComp.layer("Soustitre") .sourceRectAtTime() ;
Height=a.height;
Width=a.width;
Left=a.left;
Top=a.top;

x=Width/-2-Left;
y=Height/-2-Top;

[x,y]


and at least a fading expression on my box so it fade when the layer stop:

fadeIn = linear(time, inPoint , inPoint + .5, 0, 65)
fadeOut = linear(time, outPoint - .5,outPoint, 0, 65)
fadeIn - fadeOut


i've fix my template, with multiple code on the internet , (thanks to this forum, adobe's one and reddit, and of course Dan Ebbert)
i've seen that i'm not the only one looking for a hack on this, but never seen any solution so maybe any of you found and will be glad to share.

Thanks to everyone having an idea to share, if you have any question don't hesitate to ask.
have a good day


Return to posts index

Tomas Bumbulevičius
Re: SourceRectAtTime() for 2 lines of text with different sized Box
on Jun 7, 2019 at 5:16:38 pm

Hey Pierre - nice handle of multiple sources to get this into workable solution!

What I am not 100% sure, whether you have a single text layer, with two lines in it, or two layers each/line of text? One way or another, if you want to have text boxes corresponding to each line width, you must break the text into multiple layers.

I would recommend to start without animations first, and build it on top. Starting pretty heavy complicates the process ☺ Or alternatively, you could consider the following - Boxer. I made this project with pretty much every possible dynamic scenario, growing from different locations, animated, etc - check it out if interested!



Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Pierre Josserand
Re: SourceRectAtTime() for 2 lines of text with different sized Box
on Jun 8, 2019 at 4:41:51 pm

Thanks a lot Tomas, I saw boxer many times and got tempted many times too, but I work short term for a tv company that don't want to put coin in it and they asked me if I can have a look on a old template with a lot of keyframe and layer to move and they don't really care much if I found something or not, and me I thought it was a good challenge.

I actually need to thank you again, after posting this message I found an old version on your boxer, named 1to4line I think on a Adobe forum, with 4 sizeable text. Hope it's ok for you
It helped me to understand how to work with two text layer link. I have a problem tho on my version, when I animate my text in source text the second boxe
is stayingg under the first line in a small size. So I tried that my text start on the lowest line and go up when the character number limit is full, didn't work yet . I needed my weekend. I'll try to send my version here on Monday. So thank you so much for your old template and your info on this forums, it help me understand so much.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]