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)
21 me = makeEasing(obj, objSetter, func, time, animDuration, animStartValue, animEnd);
22 anim.addAnim(anim, me);
26 entity makeEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animStartTime, float animDuration, float animStartValue, float animEnd)
30 me.configureAnimation(me, obj, objSetter, animStartTime, animDuration, animStartValue, animEnd);
35 float Easing_calcValue(entity me, float tickTime, float animDuration, float animStart, float animDelta)
37 return me.math(tickTime, animDuration, animStart, animDelta);
40 void Easing_setMath(entity me, float(float, float, float, float) func)
45 float easingLinear(float tickTime, float animDuration, float animStart, float animDelta)
47 return (animDelta * (tickTime / animDuration)) + animStart;
50 float easingQuadIn(float tickTime, float animDuration, float animStart, float animDelta)
52 float frac = tickTime / animDuration;
53 return (animDelta * frac * frac) + animStart;
56 float easingQuadOut(float tickTime, float animDuration, float animStart, float animDelta)
58 float frac = tickTime / animDuration;
59 return (-animDelta * frac * (frac - 2)) + animStart;
62 float easingQuadInOut(float tickTime, float animDuration, float animStart, float animDelta)
64 if (tickTime < (animDuration / 2))
66 return easingQuadIn(tickTime, (animDuration / 2), animStart, (animDelta / 2));
70 return easingQuadOut((tickTime - (animDuration / 2)), (animDuration / 2), (animStart + (animDelta / 2)), (animDelta / 2));