Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Expression for text width/scale depending on another text width/scale

New Here ,
Mar 07, 2019 Mar 07, 2019

Hey guys,

i am pretty new to expressions (Just know some basics) and i ran into a problem.

I am creating a template right now and the user should be able to enter two titles: One main title and a subtitle.

I want the subtitle to have the same width as the main title.

Is there any way to get this done automatically?

Example.PNG

So for example the user writes into the first title: The Doggo Loves Walkies, and into the second title: The True Story Of The Doggo.

The second title should then scale up or down, depending on the width of the first title so that they line up on both sides.

Sorry for the bad explanation...I hope you understand what I mean...

Let me know if my idea is stupid and there is a much easier way to get this done.

Thank you already!

TOPICS
Expressions
4.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2019 Mar 07, 2019

You could try a scale expression like this:

w1 = thisComp.layer("First Title").sourceRectAtTime(time,false).width;

w2 = sourceRectAtTime(time,false).width;

s = (w1/w2)*100;

[s,value[1]]

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2019 Mar 08, 2019

Hey Dan,

that works perfect! Exactly what I was looking for! Thank you man.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2021 May 30, 2021

Hi Dan, i have seen a lot of questions here that were solved by you, so congrats and thank you for all your support! Here is my question.... I tried that expression but it only resized the width, can you tell me how can i have the height resized too? I am searching for this anwser for many hours... i dont know nothign about coding so i´m sorry if it wasnt a clever question.....

 

Thanks! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 30, 2021 May 30, 2021
LATEST

This should work

w1 = thisComp.layer("First Title").sourceRectAtTime(time,false).width;

w2 = sourceRectAtTime(time,false).width;

s = (w1/w2)*100;

[s,s]

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2019 Mar 07, 2019

你可以试试这个表达式transform.ypositon+index*数值

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines