Copier le lien dans le Presse-papiers
Copié
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.
Copier le lien dans le Presse-papiers
Copié
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
Copier le lien dans le Presse-papiers
Copié
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 🙂
Copier le lien dans le Presse-papiers
Copié
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
Copier le lien dans le Presse-papiers
Copié
I think it should look like this then but I now get an error:
Copier le lien dans le Presse-papiers
Copié
My bad...Got it. Forgot the ;
Thanks again
Copier le lien dans le Presse-papiers
Copié
Yeah, sorry. Math.max() it has to be - thanks Mylenium!
*Martin
Copier le lien dans le Presse-papiers
Copié
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?
Copier le lien dans le Presse-papiers
Copié
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
Copier le lien dans le Presse-papiers
Copié
Copier le lien dans le Presse-papiers
Copié
Copier le lien dans le Presse-papiers
Copié
Thanks! That kinda did what I wanted 🙂
One lousy character haha
Copier le lien dans le Presse-papiers
Copié
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.
Trouvez plus d’idées, d’événements et de ressources dans la nouvelle communauté Adobe
Explorer maintenant