Copy link to clipboard
Copied
Is it possible to have two different texts (Title in color and font A and subtext in color and font B)
in one auto-scaling box?
How do I add the 't' (Main text layer) in this script?
s=thisComp.layer("Main title");
t=thisComp.layer("Main text");
w=s.sourceRectAtTime().width;
h=s.sourceRectAtTime().height;
[w,h]
Just get sourceRectAtTime() for t, and check for larger values.
The larger values are the ones, you take.
So:
s=thisComp.layer("Main title");
t=thisComp.layer("Main text");
s_w=s.sourceRectAtTime().width;
s_h=s.sourceRectAtTime().height;
t_w=s.sourceRectAtTime().width;
t_h=s.sourceRectAtTime().height;
w = max(s_w, t_w)
h = max(s_h, t_h)
[w,h]
*Martin
The correct function is Math.max(). It returns the largest possible value of both your layers, which is what you would want to encompass all text.
Mylenium
Give this a try. All credit goes to Mylenium.
Copy link to clipboard
Copied
Just get sourceRectAtTime() for t, and check for larger values.
The larger values are the ones, you take.
So:
s=thisComp.layer("Main title");
t=thisComp.layer("Main text");
s_w=s.sourceRectAtTime().width;
s_h=s.sourceRectAtTime().height;
t_w=s.sourceRectAtTime().width;
t_h=s.sourceRectAtTime().height;
w = max(s_w, t_w)
h = max(s_h, t_h)
[w,h]
*Martin
Copy link to clipboard
Copied
Sorry, I'm a newbie to scripts.
I assumed I could just copy yours and it would work but I get an error saying that max is not a function.
Not sure what you mean with check for larger values and where to check those.
I hope you have some patience with me 🙂
Copy link to clipboard
Copied
The correct function is Math.max(). It returns the largest possible value of both your layers, which is what you would want to encompass all text.
Mylenium
Copy link to clipboard
Copied
I think it should look like this then but I now get an error:
Copy link to clipboard
Copied
My bad...Got it. Forgot the ;
Thanks again
Copy link to clipboard
Copied
Yeah, sorry. Math.max() it has to be - thanks Mylenium!
*Martin
Copy link to clipboard
Copied
Sorry...back again...
Both textbox are responding to the text being added. So that is good. However I need to the red text (main title) to be on top and the grey (main text) underneath the red. And both within the white box. I imagine I should add a margin to the height of the "Main text". How can I best accomplish this?
Copy link to clipboard
Copied
Did you ever figure this out? I'm following the expression as detailed above and still only have one box following one layer of text. I've been chasing this down for a week.
Thanks,
Jason
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks! That kinda did what I wanted 🙂
One lousy character haha
Copy link to clipboard
Copied
The easiest and most flexible approach for this is using my extension Pins & Boxes.
Note that Pins & Boxes creates expressions. So the rigs you create with it also work inside templates and mogrts and also on machines, where Pins & Boxes is not installed.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now