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

Scale by proximity script

Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Hi all,

I'm searching for an expression I can use so I don't go insane. See the attached image. I want each number to scale from 100% to 150% as the red line approaches. So if the red line is 200 or more pixels away from the number's anchor, the scale is 100%. If it's right on top, it's 150%.

Thank you.

  -  Geoff

Timeline.jpg

Views

2.1K

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 , May 08, 2017 May 08, 2017

Try naming your red line layer "Red Line" and using this expression for scale on a text layer:

t = length(position, thisComp.layer("Red line").position);

s = ease(t, 200, 0, 150, 100);

[s, s]

The Length method is under the Vector Math section of the expression language menu, the ease method is under the Interpolation section.

You are measuring the length between the anchor point of the current layer and the anchor point of the Red Line layer. Then a simple interpolation method takes the length ("t" f

...

Votes

Translate

Translate
Community Expert ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Let me get this straight. The red vertical line moves along the timeline. As the red line approaches a date the text scales up. If each date is on a separate text layer then you could use the position of the red line and a length method to scale as the red line approaches. If all of the dates are on the same layer then you could use a text animator for scale and just keyframe by hand. You could also use timeline markers and an expression based on time. It all depends on how much monkeying around you plan to do when setting up the composition, the length of the shot and how many changes you need to make.

If I had a narration track that I was using to time the movement of the red line I"d just throw a couple of markers in the timeline to indicate kay points, animate the position of the red line, then use a text animator for scale and animate by hand. It would take seconds to get the timing correct.

If I needed to build an automated system that followed the movement of the red line I would probably use a length method tied to the anchor point of each date layer. Put the anchor point of each date layer in the middle of the date and then use the same length method to ease the scale up and down for the text layer.

I'm no where near AE right now and wouldn't attempt to write the expression without checking it in AE but it should be pretty straight forward.

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
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

I think you understand my problem conceptually, I just don't know anything about expressions, so I'm hoping someone can give me something that I can edit and paste into the scale of each number.

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
Community Expert ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Try naming your red line layer "Red Line" and using this expression for scale on a text layer:

t = length(position, thisComp.layer("Red line").position);

s = ease(t, 200, 0, 150, 100);

[s, s]

The Length method is under the Vector Math section of the expression language menu, the ease method is under the Interpolation section.

You are measuring the length between the anchor point of the current layer and the anchor point of the Red Line layer. Then a simple interpolation method takes the length ("t" for temporary value of length) and applies an ease when t starts at 200 and ending at zero between 150 and 100. The result of the interpolation method translates to scale for the layer with the expression.

For this to work properly the text layers should be created with the anchor point directly in the center of the text in a center justified paragraph. You can easily center the anchor point by using the baseline shift property in the Character Panel. Start by using the resetting the position of any text layer you created by clicking with the type tool anywhere in the comp panel and typing, then match the baseline shift for every layer.

That should do it.

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
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

I just don't know anything about expressions, so I'm hoping someone can give me something that I can edit and paste into the scale of each number.

I would recommend also trying here:

After Effects Expressions

or here:

CreativeCOW

who knows, you may very well be touched by the Expressionist Dan Ebberts himself. may he continue to bless us with his unparalleled Ae coding talent for years to come...

*EDIT: I can see Rick found the time.

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
Community Expert ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

I hope I got the expression right. If it works as expected great, if the layers scale down when you approach the text layer reverse the 150 and 100...

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
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

it works perfectly, Rick. thank you. let's see if Op gets it too. here's a visual:

158.gif

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
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Thank you so much for this. It seems I had an issue though in that it didn't work because I have the timeline, including the numbers, parented to a dummy object (called "base"). The red line isn't attached to that, but I've attached it now and things work fine. Just means I need to re-animate it, which isn't a big deal, now that I have this script.

Though I'm curious, is there any way to make this work if the Red line isn't also a child of the same parent as the numbers?

Thanks again.

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
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

GeoffKornfeld I am merely a sidekick in this thread. expressions are not easy for me, you should really mark rick's response as correct. Re: Scale by proximity script since it also provide useful explanation to what its actually doing.

as for the parenting situation. you can parent the redline and disable the parenting using this for the position parameter of the red line:

value-parent.transform.position

it will shift in position, you can place it where you need to. now the red line is parented but its position is not affected by the null.

there's gotta be a more elegant expression then this... but it works

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
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Thanks much. Makes sense.

And I just have marked Rick's as the correct one now. I realized my error a second after I marked yours, but didn't know it was undo-able. This is my first time on the forum.

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
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

LATEST

welcome to the fun house

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