ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Tracking a shape layer along edge from of a .sourceRectAtTime rectangle

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ryan Powell
Tracking a shape layer along edge from of a .sourceRectAtTime rectangle
on Jan 3, 2019 at 11:20:41 pm

Hi! Another expression question that I'm hoping someone can help with. 😊

I am trying to create a template for a series of titles. The idea is that theres a cursor on screen that "highlights" the text, similar to how you would highlight a string of text on a webpage to copy/look-up/etc by dragging the mouse over the selection. We will do many variations of the length of text, so I want to streamline this one specific animation action to always move from corner to corner without needing to adjust position keyframes.

Currently, I'm working with the line of text and using sourceRectAtTime to create a box with padding behind the line of text. I used this tutorial:



to build my growing/shrinking box with text. What I want to do now is have a "cursor" (I've built this as a shape layer) start at the bottom left corner of the box and then slide across to the bottom right corner of the box. This cursor will have a matte attached that reveals the text/box combo.

Essentially it will do this:
1.
2.
3.

I can get the wipe to work fine by adjusting the x-scale of the rectangle, but where I'm stumped is figuring out how to connect my cursor to this action. My thoughts are if I can find these two points on the X-axis (bottom left corner and bottom right corner) of my rectangle and designate those two points as in/out points for my "cursor", it might be possible to set LEFT as 0% and RIGHT as 100% and use a slider to keyframe the animation timing. Can I create a path that is only the bottom edge of the image and parent the cursor to the path?? What expression do I use to find the position of the two corners of the rectangle??

Keep in mind, this will need to work with varying widths of the rectangle since the text will vary in length for each title. Any help would be greatly appreciated!! Thank you!


Return to posts index

Kalleheikki Kannisto
Re: Tracking a shape layer along edge from of a .sourceRectAtTime rectangle
on Jan 4, 2019 at 7:46:37 am

Put your anchor point at one corner of the rectangle, that will take care of half the task, as that will be your origin [0,0] point.

The width of the text with sourceRectAtTime().width plus some margin will give you the width of the rectangle.

That will control both the arrow and the rectangle during the animation.

To get it animated, you can use the linear() or ease() to map the motion to a specific time range:

cursor_x_motion = linear(time, start_time, end_time, 0, rect_width+2*margin)

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Ryan Powell
Re: Tracking a shape layer along edge from of a .sourceRectAtTime rectangle
on Jan 4, 2019 at 5:52:32 pm

Wow thank you!! You are a huge help!

I'm now using this expression and have parented it to the black box. The bulk of what I want is happening now. I have one last more questions.

1) How do I change the in/out to to specific frame numbers instead of 1 sec+2 sec? Here's my expression:

var o = thisComp.layer("BLACK BOX").content("Offset Paths 1").amount;
cursor_x_motion = ease(time, 1, 2, 0, thisComp.layer("BLACK BOX").content("Rectangle 1").content("Rectangle Path 1").size[0]+o*2);

"time, 1, 2" makes my in/out at 1 sec and 2 sec.

Thanks again for your help!!


Return to posts index


Ryan Powell
Re: Tracking a shape layer along edge from of a .sourceRectAtTime rectangle
on Jan 4, 2019 at 6:11:19 pm

Never mind, I solved my own question with some math.

in-point value = (in point frame number/comp frame rate)
out-point value = (outpoint frame number/comp frame rate)

Thanks again for your help on the other parts of the expression!! I've learned a lot!

Ryan


Return to posts index

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