Tweening is a video editing term used to describe ease of motion. For example, with an elevator the lift does not go full speed and dead stop when it reaches it's desired floor. It knows what floor its on, what floor it is going to, and how long it will take to get there. Then it uses that data to smooth its motion.
I would like to be able to program this smooth motion for my projects by using tweening.
The method for how to do this is layed out in http://robertpenner.com/easing/penner_chapter7_tweening.pdf
Specifically looking at pg207-211
This guide explains what tweening is and then shows code in Action Script. To be honest I feel kind of stupid becuase I've tried to use the examples provided but I can't seem to replicate it in another language such as c++, java, javascript, or lua.
I do not wish to use a package or plugin to code tweening, I want to learn how to actually code a tweening function. So if anyone with better comprehension skills, or programming skills, thinks they understand then I would very much appreciate an explanation.
Sample Action script functions...
Math.easeInQuad = function (t, b, c, d) {
return c*(t/=d)*t + b;
};
Math.easeOutQuad = function (t, b, c, d) {
return -c * (t/=d)*(t-2) + b;
};
Math.easeInOutQuad = function (t, b, c, d) {
if ((t/=d/2) < 1)
return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
};
A proper tweening function in AS3 accepts 6 parameters of
Number
with last two parameters defaulting at 0. It should interpret the parameters as follows:The expected result is a value between
second
and(second+third)
parameters, or with their canonical names oft, b, c, d, a, p
betweenb
andb+c
.You can plot a function's graph using a simple algorithm like this:
Speaking of C++, for example an
easeInQuad
should be programmed like this (if I didn't mess up C++ syntax):