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

linear function that at end goes back to start value

Participant ,
Aug 25, 2017 Aug 25, 2017

Copy link to clipboard

Copied

Hi everyone.

Trying to figure out the best way to create a function that uses a linear(input, min, max, outmin, outmax) setup but, here's the trick: only does that for a specified amount and at the end goes back to the starting value.

I'm planning on using it to control the scale of a layer when a null layer is just above it, when the null layer is past the layer it goes back to the starting state.

As I understand the linear() function it doesn't have a way to define a specific range that the calculation is based on?

Any help is greatly appreciated!

TOPICS
Expressions

Views

636

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 , Aug 25, 2017 Aug 25, 2017

You didn't provide much detail, so this is pretty general, but probably something like this:

minDist = 100;

maxDist = 400;

d = length(thisComp.layer("Null 1").position,position);

linear(d,minDist,maxDist,[150,150],value)

Dan

Votes

Translate

Translate
Community Expert ,
Aug 25, 2017 Aug 25, 2017

Copy link to clipboard

Copied

You didn't provide much detail, so this is pretty general, but probably something like this:

minDist = 100;

maxDist = 400;

d = length(thisComp.layer("Null 1").position,position);

linear(d,minDist,maxDist,[150,150],value)

Dan

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
Participant ,
Aug 25, 2017 Aug 25, 2017

Copy link to clipboard

Copied

Hi Dan!

Yeah, this is exactly what I was trying to achieve!

But I don't really understand why and how it works: do you mind explaining the length function and the setup in general?

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 ,
Aug 25, 2017 Aug 25, 2017

Copy link to clipboard

Copied

LATEST

You can use length() to measure the distance between two layers. Then I just used linear() to scale the layer up as the null approaches. You might want to adjust maxDist (the distance where the null has no effect) and minDist (where the null has the maximum effect).

Dan

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