Skip to main content
Mitesh Mhatre
Inspiring
February 8, 2022
Question

Custom Bezier expression not working

  • February 8, 2022
  • 1 reply
  • 350 views

/* ---------- Flow Function Declarations ---------- */
function customBezier(t,tMin,tMax,value1,value2,bezierPoints){if(arguments.length!==6)return value;var a=value2-value1;var b=tMax-tMin;var c=clamp((t-tMin)/b,0,1);if(!(bezierPoints instanceof Array)||bezierPoints.length!==4)bezierPoints=[0,0,1,1];return a*h(c,bezierPoints)+value1;function h(f,g){var x=3*g[0];var j=3*(g[2]-g[0])-x;var k=1-x-j;var l=3*g[1];var m=3*(g[3]-g[1])-l;var n=1-l-m;var d=f;for(var i=0;i<5;i++){var z=d*(x+d*(j+d*k))-f;if(Math.abs(z)<1e-3)break;d-=z/(x+d*(2*j+3*k*d));}return d*(l+d*(m+d*n));}}
/* ---------- Flow Function Declarations ---------- */
/* ---------- Flow Expression Template ------------ */
var animationStartTime = 1;
var animationEndTime = 2;
var startValue = value;
var endValue = value * 2;
if (numKeys > 0) {
var nearestKeyIndex = nearestKey(time).index;
if (key(nearestKeyIndex).time > time) nearestKeyIndex--;
if (nearestKeyIndex === 0 || nearestKeyIndex === numKeys) {
startValue = endValue = value;
} else {
animationStartTime = key(nearestKeyIndex).time;
animationEndTime = key(nearestKeyIndex + 1).time;
startValue = key(nearestKeyIndex).value;
endValue = key(nearestKeyIndex + 1).value;
}
}
customBezier(time, animationStartTime, animationEndTime, startValue, endValue, [0, 0.3, 1, 1]); // Nano
/* ---------- Flow Expression Template ------------ */

if (numKeys > 1){
t1 = key(1).time;
t2 = key(2).time;
t3 = key(3).time;
t4 = key(4).time;
v1 = [0, 20];
sliderControl = 2000;
fixedValue = 20;
v2 = [sliderControl, fixedValue];
v3 = [sliderControl, fixedValue];
v4 = [0, 20];
if (time < key(2).time)
customBezier(time, t1, t2, v1, v2);
else customBezier(time, t2, t3, v2, v3);
if (time < key(3).time)
customBezier(time, t1, t2, v1, v2);
else customBezier(time, t3, t4, v3, v4);
} else {
value
}

This topic has been closed for replies.

1 reply

Mylenium
Legend
February 8, 2022

And what actually is this illegible mess supposed to tell us? From where did you copy & paste it? You need to provide an actual explanation of what your problem is, not just dump other people's code in the forum, which I'm pretty sure is actualyl working fine. You may just not fulfill its prerequisites liek actually hjaving keyxframes somewhere.

 

Mylenium

Mitesh Mhatre
Inspiring
February 16, 2022

Hello Sorry for late reply & No explanation!

 

I just want to convert function into another function.

 

Suppose, I have created function "abc" It has different values but i want to change it to "efg", What should i do in this case?

 

If you still don't understand what i want then please tell me. I'll share you file.

 

BTW, this code is expression of flow plugin from aescripst & another part is for "Dynamic" keyframes. Using dynamic keyframing, you can change keyframe values...:) Thank You my friend!