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

Maintain Distance Between Multiple Text Layers

New Here ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

Hello Community,

I am creating a text carousel template where I would like text layers (up to 8) to maintain the horizontal distance between each other if I change the source text.

 

So for example, if I were to change the text in the  "Step Cross Behind" or "Line Dance", I would like to be able to maintain that gap of space between the two without having to manually re-position it each time I need to change the text for a new carousel.

 

I am newer to expressions so any help would be greatly appreciated.  Please let me know if something like this is possible.  Thank you so much.

TOPICS
Expressions

Views

1.3K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 09, 2021 Aug 09, 2021

You would automate that by having each set of words on a separate text layer and then use sourceRectAtTime() to figure the size of each text layer and add the required space. You would also tie the text layer position and the left value for each subsequent text layer into the calculations It could all be done with the position property of the text layers. Start with the leftmost text layer at the bottom then add this expression to the next layer above it.

src=thisComp.layer(index + 1);
srcWidth 
...

Votes

Translate

Translate
Community Expert ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

You would automate that by having each set of words on a separate text layer and then use sourceRectAtTime() to figure the size of each text layer and add the required space. You would also tie the text layer position and the left value for each subsequent text layer into the calculations It could all be done with the position property of the text layers. Start with the leftmost text layer at the bottom then add this expression to the next layer above it.

src=thisComp.layer(index + 1);
srcWidth = src.sourceRectAtTime().width;
pad = 80 // distance between layers
newX = srcWidth + pad;
strtPos = src.position;

[strtPos[0] + newX, strtPos[1]]

If you wanted the top layer to be the words on the far left you would change the index + 1 to index - 1.

 

As long as all layers have the same paragraph setting they will line up 80 pixels apart.  All you have to do is position the master (far left) layer. 

Votes

Translate

Translate

Report

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 ,
Aug 10, 2021 Aug 10, 2021

Copy link to clipboard

Copied

This was extremely helpful.  Thank you so much Rick, it was exactly what I was looking for!

Votes

Translate

Translate

Report

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 ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

LATEST

Thanks this is super helpful.. 

 

However trying to do the same thing but with layers of text stacked vertically. 

 

I can apply all the logic to height, & it works a treat, however if I increase font size on one of my layers, the distance between layers is affected by the increased height & distance between the layers stops being even..  If I do the same on the width layout the distance between the layers stays consistent.. What am I missing? 

 

Also sourceRectAtTime works when changing the font size, but not when scaling the text layer.. is there a way of being able to scale the text layers say to 75% & still have the sourceRectAtTime method work?  

 

cheers

Votes

Translate

Translate

Report

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