ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression to control length of text relative to shape layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jay Hoogenboom
Expression to control length of text relative to shape layer
on Jul 9, 2018 at 7:13:59 am

Hi,
Relative noob to expressions, trying to get my head around them. I have a lower third that will be being used as a template and the name will always be changing.
Currently I have a shape that animates on at the right of screen, then slides over to reveal the text.
I'd like to use an expression so that the length of the text controls where the shape layer will animate and slide from (shorter names means it starts further in to the left, longer names means further right etc).

Initial research suggests that SourceRectAtTime might be an answer, but I don't know enough about applying the expression and experiments so far just give me an error.
Screenshot below.

Thanks!


Return to posts index

Kalleheikki Kannisto
Re: Expression to control length of text relative to shape layer
on Jul 11, 2018 at 10:52:10 am
Last Edited By Kalleheikki Kannisto on Jul 11, 2018 at 11:06:56 am

Here's my take. You need just one keyframe (the first keyframe of that layer) for the end position and time of the animation for both the graphic (slant) and the covering box. The position animation comes from the following expression, and you can adjust the time by changing the first variable. Same expression for both layer's position.

transition_time = 1; // how long an animation
margin = 150; // how much extra width in addition to text length
source_text =thisComp.layer("Text"); // reference to text layer
text_width = source_text.sourceRectAtTime(inPoint, true).width; // text width
initial_x_pos = transform.position[0] + text_width + margin; // starting position
end_time = key(1).time; // the keyframe when the animation ends, first keyframe in this case
anim_progress = linear (time, end_time-transition_time, end_time, 0, 100); // how far along the animation is, in percentage value
x_pos = ease(anim_progress, 0, 100, initial_x_pos, transform.position[0]); // eased animation
[x_pos, transform.position[1]]


Result:



Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Jay Hoogenboom
Re: Expression to control length of text relative to shape layer
on Jul 13, 2018 at 6:02:26 am

Hi Kalleheikki,
Thanks for your feedback. I'll give this a try soon and see how this goes.

Regards


Return to posts index


Jay Hoogenboom
Re: Expression to control length of text relative to shape layer
on Jul 16, 2018 at 4:40:13 am

Hi Kalleheikki,
I have added this script and it works well, so thanks for that. The only issue I have is that my colour bar needs to animate on, then move across. With this script it is animating and wiping across at the same time. Is there a way to make this script pause to let the initial animation happen, then complete?
Thanks again.


Return to posts index

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