ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Custom ease

FAQ   •   VIEW ALL
 Custom ease on Jul 22, 2018 at 10:47:53 am

Hi, I am using the following expression on the Scale property;

```ScaleInTime=1; [easeOut(time, inPoint, inPoint+ScaleInTime, [0], [transform.scale[0]]), easeOut(time, inPoint, inPoint+ScaleInTime,[0],[transform.scale[0]])];```

I also sometimes use Ease and Wizz on keyframed animations, but wondered how I would implement the below functions in the above script?:

```// Ease and Wizz 2.0.4 : inOutQuint : All keyframes // Ian Haigh (http://ianhaigh.com/easeandwizz/) // Last built: 2013-07-05T11:46:51+10:00 // some defaults var p = 0.81; // period for elastic var a = 50; // amplitude for elastic var s = 1.70158; // overshoot amount for "back" function easeandwizz_inOutQuint(t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; } function easeAndWizz() { var n = 0; if (numKeys > 0) { n = nearestKey(time).index; if (key(n).time > time) { n-- } } try { var key1 = key(n); var key2 = key(n+1); } catch(e) { return null; } // determine how many dimensions the keyframes need var dim = 1; // It's gotta have at least ONE dimension try { key(1)[1]; dim = 2; key(1)[2]; dim = 3; } catch(e) {} t = time - key1.time; d = key2.time - key1.time; sX = key1[0]; eX = key2[0] - key1[0]; if (dim >= 2) { sY = key1[1]; eY = key2[1] - key1[1]; if (dim >= 3) { sZ = key1[2]; eZ = key2[2] - key1[2]; } } if ((time < key1.time) || (time > key2.time)) { return value; } else { val1 = easeandwizz_inOutQuint(t, sX, eX, d, a, p, s); switch (dim) { case 1: return val1; break; case 2: val2 = easeandwizz_inOutQuint(t, sY, eY, d, a, p, s); return [val1, val2]; break; case 3: val2 = easeandwizz_inOutQuint(t, sY, eY, d, a, p, s); val3 = easeandwizz_inOutQuint(t, sZ, eZ, d, a, p, s); return [val1, val2, val3]; break; default: return null; } } } (easeAndWizz() || value); ```

Thanks in advance

 Return to posts index

 Re: Custom easeon Jul 23, 2018 at 1:16:12 pm

I might not have been clear on this, I want to achieve something like:

```ScaleInTime=1; [easeandwizz_inOutQuint(time, inPoint, inPoint+ScaleInTime, [0], [transform.scale[0]]), easeandwizz_inOutQuint(time, inPoint, inPoint+ScaleInTime,[0],[transform.scale[0]])];```

 Return to posts index

 Re: Custom easeon Jul 23, 2018 at 2:24:45 pm

In case anyone is interested, I found an example here: https://gist.github.com/monsieuroeuf/6051422

 Return to posts index

 Re: Custom easeon Jul 23, 2018 at 2:25:37 pmLast Edited By Kalleheikki Kannisto on Jul 23, 2018 at 2:27:24 pm

I was gonna suggest just putting in those two keyframes, but looks like you found a solution.

Kalleheikki Kannisto
Senior Graphic Designer

 Return to posts index

 Re: Custom easeon Jul 23, 2018 at 2:34:27 pm

It would look something like this. Note that I stripped out all of the ease&Wizz dimension checks because you are only providing the X-value scale in your linear functions.

If you wanted to update the bezier animation functions, all you need to do is change the "easeandwizz_inOutQuint" function.

```// Ease and Wizz 2.0.4 : inOutQuint : All keyframes // Ian Haigh (http://ianhaigh.com/easeandwizz/) // Last built: 2013-07-05T11:46:51+10:00 // some Ease & Wizz defaults var p = 0.81; // period for elastic var a = 50; // amplitude for elastic var s = 1.70158; // overshoot amount for "back" var r = 1; //aka scaleInTime var x = value[0]; o = easeAndWizz(); [o,o] function easeAndWizz() { if ((time < inPoint) || (time > (inPoint + r))) { return x; } else { return easeandwizz_inOutQuint(time - inPoint, 0, x, r, a, p, s); } } function easeandwizz_inOutQuint(t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; }```

Alex Printz
Mograph Designer

 Return to posts index

 Re: Custom easeon Jul 23, 2018 at 3:40:11 pm

Thanks all. I modified monsieuroeuf's version and came up with the below. It scales in and out nicely without keyframes, you'd just replace easeandwizz_inOutQuart with which ever Ease and Whizz function you prefer

```fadeInTime=1.5; scaleFromTo=50; function easeandwizz_inOutQuart(t, b, c, d) { if ((t/=d/2) &lt; 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; } initialScale = transform.scale[0]; if (time &lt; (inPoint+outPoint)/2){ moveEnd = inPoint+fadeInTime; diff = initialScale-scaleFromTo; normalisedTime = linear(time, inPoint, inPoint + fadeInTime, 0, fadeInTime); s = easeandwizz_inOutQuart(normalisedTime, scaleFromTo, diff, fadeInTime); }else{ moveEnd = outPoint; diff = scaleFromTo-initialScale; normalisedTime = linear(time, outPoint-fadeInTime, outPoint, 0, fadeInTime); s = easeandwizz_inOutQuart(normalisedTime, initialScale, diff, fadeInTime); } [s, s] ```

 Return to posts index

© 2018 CreativeCOW.net All Rights Reserved
[TOP]