Activity › Forums › Adobe After Effects Expressions › function curve drives interpolation
-
function curve drives interpolation
Posted by Aaron Kent on February 25, 2013 at 9:32 pmHello all. I am wondering if it is possible to use a function curve keyed on another parameter to act as a replacement of “linear” or “ease” interpolation expression? I searched around here and found only one relevant atempt to make this work. Is it even possible, given the AE scripting language?
Cheers
AK
Gabriel Ferrão replied 10 years, 10 months ago 3 Members · 5 Replies -
5 Replies
-
Dan Ebberts
February 25, 2013 at 11:08 pmInteresting question…
Suppose you set up a template null and you keyframe the rotation property going from 0 to 1 degree as the time goes from 0 to 1 second. Use that keyframed segment to set up the ease curve you want.
Then on another layer you could use linear keyframes and apply an expression like this to generate a similar curve:
template = thisComp.layer("template").transform.rotation;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n == 0 || n == numKeys){
value
}else{
v1 = key(n).value;
v2 = key(n+1).value;
t1 = key(n).time;
t2 = key(n+1).time;
v1 + (v2-v1)*template.valueAtTime((time-t1)/(t2-t1));
}
I hope that helps.
Dan
-
Aaron Kent
February 26, 2013 at 4:32 pmHello Dan. Apologies, I believe I didn’t phrase this question well enough. Save I am setting an expression on scale like so (see below)
so that the layer’s width scales between 100% and 10% depending on its position between the two shape layers in the expression below. “Linear” will of course yield a linear result. If the layer was half way between the 2 layers it’s width would be 50%, 3/4 of the way there 75%, etc etc.
But is there a way to replace “linear” with a curve with multiple key frames between 0 and 1, so you could kind of art direct the range of scale values as the layer travels between the two points….
Cheers
AK
a = linear(transform.position[0], thisComp.layer("Shape Layer 1").transform.position[0], thisComp.layer("Shape Layer 2").transform.position[0], 100, 10);
b = transform.position[1];
[a,b] -
Dan Ebberts
February 26, 2013 at 9:32 pmI’m not sure if this is what you’re looking for, but if you wanted to scale a layer from 10% to 100% as its x postion moves between the x positions of Shape Layer 1 and Shape Layer 2, and you wanted to apply a cubic ease-in to the scaling, you could do it like this:
function myEase(t){
return t*t*t; // cubic ease in
}minVal = [10,10];
maxVal = [100,100];
x1 = thisComp.layer("Shape Layer 1").transform.position[0];
x2 = thisComp.layer("Shape Layer 2").transform.position[0];
x = transform.position[0];
myT = linear(x,x1,x2,0,1);
linear(myEase(myT),minVal,maxVal)
To apply a different ease, you would just need to change the function. The key to the function is that it expects values between 0 and 1, and returns values between 0 and 1.
Dan
-
Aaron Kent
February 26, 2013 at 9:39 pmThanks Dan. These are two great lessons / exercises in and of themselves.
I’m going to try to actually combine these two things into what I think I’m trying to achieve. I will post back my results.Cheers
AK
-
Gabriel Ferrão
June 24, 2015 at 1:37 amHey, I have the exact same question as you (different application, however).
The suggestions here are helpful, but not quite what you were talking about….
I’d love to know what you ended up doing.
Thanks!
Reply to this Discussion! Login or Sign Up