ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression based animation with custom easing

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Saint
Expression based animation with custom easing
on May 31, 2018 at 10:37:52 am

Hi all,

I'm working on a templated project where I need to animate the X position between two frames using expressions to feed in the values. I've done this before but only using the basic ease() function and this expression:

//Time Variables (based on where keyframes are in timeline)
t1 = key(1).time;
t2 = key(2).time;

min = 800 //start value;
max = 1200 //end value;

//Animate Return Value Across Time

if (time <= t1) {

xPos = min; //Return value is start of animation
}
else if (time > t1 && time < t2) {

xPos = ease(time, t1, t2, min, max); //Ease return value over time
}
else { xPos = max };

[ xPos, value[1] ]; //Final position values


In practice this uses two keyframes as a reference to the time to animate between, and then eases the x position of the layer from 800 to 1200.

This time I want to try and get a much smoother ease, and I've seen someone adapting the expressions from Ian Haigh's Ease and Whizz plugin here:

https://forums.creativecow.net/docs/forums/post.php?forumid=227&postid=2660...

I've managed to get this working as intended for scale, but just can't figure out how to translate this to the x position value of a layer (plus not including the "SCALE LINES" element which Chiara Morlacchi is adding to the equation).

Any suggestions would be appreciated, I'm still learning to write expressions and maths isn't my strong suite! :)

yScale = 100;
xScaleZero = 0;
xScaleMask = thisComp.layer("SCALE LINES").transform.scale[0];
min = [xScaleZero,yScale];
max = [xScaleMask,yScale];
t1 = key(1).time;
t2 = key(2).time;

// Ease and Wizz 2.0 : outQuint : All keyframes
// Ian Haigh (http://ianhaigh.com/easeandwizz/)
// Last built: 2009-01-08T11:11:54+11:00
// some defaults

var p = 0.8; // period for elastic
var a = 50; // amplitude for elastic
var s = 1.70158; // overshoot amount for "back"
function outQuint(t, b, c, d, a, p) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
}

function easeAndWizz() {

var dim = 2;
t = time - t1;
d = t2 - t1;
sX = 0;
eX = xScaleMask - 0;
sY = 100;
eY = 100 - 100;

if (time &lt; t1) {
return min;
}
if (time > t2) {
return max;
} else {
val1 = outQuint(t, sX, eX, d, a, p, s);
switch (dim) {
case 1:
return val1;
break;
case 2:
val2 = outQuint(t, sY, eY, d, a, p, s);
return [val1, val2];
break;
default:
return null;
}
}
}
(easeAndWizz() || value);


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]