ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Dynamically adjust position of shape layer to text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ricky London
Dynamically adjust position of shape layer to text
on Oct 15, 2019 at 6:26:19 pm

Hi All,

I would like to have the red shapelayer start at the beginning of the text and end at the last character of the text with alittle breathing room.

i'm not sure where to start with the expression! (I think something like linking the shapelayer x position to the first and last character count + any extra space needed) hope someone can help.

13821_lefttoright.gif.zip

Thanks,
K


Return to posts index

Tomas Bumbulevičius
Re: Dynamically adjust position of shape layer to text
on Oct 16, 2019 at 9:21:35 am

Hey Ricky, more information is needed about your layout and use case scenario.

1. Are you going to place this strictly in some area of the screen, or not?
2. What flexibility is preferred to adjust there?

Anyways, to breakdown this quickly if this is center aligned:
1. Instead of path, use thin rectangle.
2. Use sourceRectAtTime to get 'text layer' size.
3. Apply paddings by attaching sliders to rect shape's x and y.
4. Animate horizontally by using interpolation: ease(time, inTime, outTme, rectLeftEdge, rectsRightEdge)
5. Apply expression to text and rect shape:

sourceSize = thisLayer.sourceRectAtTime(time, false);
T = sourceSize.top;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;
([L+ W/2,T+H/2])


Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Kyle Maven
Re: Dynamically adjust position of shape layer to text
on Oct 18, 2019 at 3:06:01 pm

1. Create a new shape layer
2. Create a 2-point line with the pen tool
3. click on the shape path in the timeline panel
4. Window>Create Nulls From Paths>Points Follow Nulls
5. Use Tomas Bumbulevičius expression for both null's positions with the Text Layer as your Source.
-Null 1 should have an expression that positions it always on the left side
-Null 2 should have an expression that positions it always on the RIGHT side
6. Click on the shape path in the timeline panel
7. Window>Create Nulls From Paths>Trace Path
8. Shift + Parent your red shape layer to this new null

this will animate the shape on the x-axis based on the width of the Text. I haven't done this in a long time but I know it took some experimenting with the expressions. There are ways to add "padding" within the expressions that links to sliders.

I would suggest watching some tutorials and looking more into the sourceRectAtTime() expression.







I hope this helps!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]