Auto Scaling Text Position Lock

New Here ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

I'm working on making some MOGRT's and I have been learning about auto scaling text with a corresponding text box. I've been able to follow enough tutorials to make the text box hold on the left side of the screen and have the text expand from the left without going past title safe borders. 

 

My hold up is trying to do the opposite and have text reference the right side of its position and build out from the right so I can have motion graphics on the right side of the screen. I followed this video to get the text to scale and then to hold to the left. Essentially references the height and width as well as the padding and divides by two and then i use value + and a value to have it line up on the left side. 

value + thisComp.layer("THIRD_LINE_CONTROL").effect("WIDTH_HEIGHT_EDGE")("Point")[0]/2

 

For the life of me I cannot figure out how to accomplish the same result but on the right side of the screen. As sourceRectatTime only has a left reference what is the formula to have go to the right?

 

 

TOPICS
Expressions

Views

58

Likes

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
Adobe Community Professional ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

This will give you the right edge:

rect = sourceRectAtTime(time,false);
rect.left + rect.width

Likes

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 ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

amazing thank you!

Likes

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
Adobe Community Professional ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

You can use sourceRectAtTime() to find the center of a text or shape layer. Knowing the left and right edges will allow you t find the center of the objects in the layer. From there, the calculations are pretty straightforward. This expression ties the center of any layer above a text or shape layer to the center of the layer content:

ref = thisComp.layer(index + 1);
sF = ref.scale * .01;
txt = ref.sourceRectAtTime();
x = sF[0] * (txt.width / 2 + txt.left);
y = sF[1] * (txt.height/2 + txt.top);


ls = scale[0] * .01;
lBox = sourceRectAtTime();
lx = ls * lBox.width/2 + lBox.left;

ref.position + [lx  + x , y]

I have compensated for scale for both layers. 

 

The expression compensates for baseline shift and Shape/Transform properties. It also compensates for left, right, and center paragraph settings. The layer with this expression will always be centered on the shape or text in the layer below as long as the anchor point of the text or shape layer is at the default 0, 0 value.

 

Change x to x = sF[0] * (txt.width + txt.left); and the layer is now centered on the right edge.

 

Change x to x = sF[0] * txt.left; and the layer is centered on the left edge.

 

I use this as the starting framework for all the animation presets I create for text and shape layers. I have created presets to position graphics before or after one or more lines of text, create backgrounds for one or more text or shape layers, and by using sourceRectAtTime(inPoint + .5, true), have been able to make background layers stay in position as text animators take a half-second to fly characters into positon. 

 

I hope this helps.

 

My YouTube Quick Tips

 

Likes

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 ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

Wow this is incredible. Out of curiosity why do you prefer to use index rather than pick whipping to a layer? I'm fairly new to using expressions so just trying to get more insight from people who are more knowlegeable. 

Likes

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
Adobe Community Professional ,
Jun 25, 2022 Jun 25, 2022

Copy link to clipboard

Copied

LATEST

I use index when it is convenient to point to resources in another layer. It means the expression can be used for the layer of any name and it eliminates errors.

Likes

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