3 #include "animation.qc"
4 entity makeHostedEasing(entity, void(entity, float), float(float, float, float, float), float, float, float);
5 entity makeEasing(entity, void(entity, float), float(float, float, float, float), float, float, float, float);
6 float easingLinear(float, float, float, float);
7 float easingQuadIn(float, float, float, float);
8 float easingQuadOut(float, float, float, float);
9 float easingQuadInOut(float, float, float, float);
10 CLASS(Easing, Animation)
11 METHOD(Easing, calcValue, float(entity, float, float, float, float));
12 METHOD(Easing, setMath, void(entity, float(float, float, float, float)));
13 ATTRIB(Easing, math, float(float, float, float, float), easingLinear)
18 entity makeHostedEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animDuration, float animStartValue, float animEnd)
20 entity this = makeEasing(obj, objSetter, func, time, animDuration, animStartValue, animEnd);
21 anim.addAnim(anim, this);
25 entity makeEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animStartTime, float animDuration, float animStartValue, float animEnd)
27 entity this = NEW(Easing);
28 this.configureAnimation(this, obj, objSetter, animStartTime, animDuration, animStartValue, animEnd);
29 this.setMath(this, func);
33 METHOD(Easing, calcValue, float(entity this, float tickTime, float animDuration, float animStart, float animDelta))
35 return this.math(tickTime, animDuration, animStart, animDelta);
38 METHOD(Easing, setMath, void(entity this, float(float, float, float, float) func))
43 float easingLinear(float tickTime, float animDuration, float animStart, float animDelta)
45 return (animDelta * (tickTime / animDuration)) + animStart;
48 float easingQuadIn(float tickTime, float animDuration, float animStart, float animDelta)
50 float frac = tickTime / animDuration;
51 return (animDelta * frac * frac) + animStart;
54 float easingQuadOut(float tickTime, float animDuration, float animStart, float animDelta)
56 float frac = tickTime / animDuration;
57 return (-animDelta * frac * (frac - 2)) + animStart;
60 float easingQuadInOut(float tickTime, float animDuration, float animStart, float animDelta)
62 if (tickTime < (animDuration / 2)) return easingQuadIn(tickTime, (animDuration / 2), animStart, (animDelta / 2));
63 else return easingQuadOut((tickTime - (animDuration / 2)), (animDuration / 2), (animStart + (animDelta / 2)), (animDelta / 2));