Xonotic
easing.qc
Go to the documentation of this file.
1 #include "easing.qh"
2 
3 #include "../menu.qh"
4 #include "keyframe.qh"
5 
6  entity makeHostedEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animDuration, float animStartValue, float animEnd)
7  {
8  entity this = makeEasing(obj, objSetter, func, time, animDuration, animStartValue, animEnd);
9  anim.addAnim(anim, this);
10  return this;
11  }
12 
13  entity makeEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animStartTime, float animDuration, float animStartValue, float animEnd)
14  {
15  entity this = NEW(Easing);
16  this.configureAnimation(this, obj, objSetter, animStartTime, animDuration, animStartValue, animEnd);
17  this.setMath(this, func);
18  return this;
19  }
20 
21  METHOD(Easing, calcValue, float(entity this, float tickTime, float animDuration, float animStart, float animDelta))
22  {
23  return this.math(tickTime, animDuration, animStart, animDelta);
24  }
25 
26  METHOD(Easing, setMath, void(entity this, float(float, float, float, float) func))
27  {
28  this.math = func;
29  }
30 
31  float easingLinear(float tickTime, float animDuration, float animStart, float animDelta)
32  {
33  return (animDelta * (tickTime / animDuration)) + animStart;
34  }
35 
36  float easingQuadIn(float tickTime, float animDuration, float animStart, float animDelta)
37  {
38  float frac = tickTime / animDuration;
39  return (animDelta * frac * frac) + animStart;
40  }
41 
42  float easingQuadOut(float tickTime, float animDuration, float animStart, float animDelta)
43  {
44  float frac = tickTime / animDuration;
45  return (-animDelta * frac * (frac - 2)) + animStart;
46  }
47 
48  float easingQuadInOut(float tickTime, float animDuration, float animStart, float animDelta)
49  {
50  if (tickTime < (animDuration / 2)) return easingQuadIn(tickTime, (animDuration / 2), animStart, (animDelta / 2));
51  else return easingQuadOut((tickTime - (animDuration / 2)), (animDuration / 2), (animStart + (animDelta / 2)), (animDelta / 2));
52  }
float easingLinear(float tickTime, float animDuration, float animStart, float animDelta)
Definition: easing.qc:31
#define NEW(cname,...)
Definition: oo.qh:105
entity makeEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animStartTime, float animDuration, float animStartValue, float animEnd)
Definition: easing.qc:13
float easingQuadInOut(float tickTime, float animDuration, float animStart, float animDelta)
Definition: easing.qc:48
entity() spawn
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
float easingQuadIn(float tickTime, float animDuration, float animStart, float animDelta)
Definition: easing.qc:36
float easingQuadOut(float tickTime, float animDuration, float animStart, float animDelta)
Definition: easing.qc:42
entity makeHostedEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animDuration, float animStartValue, float animEnd)
Definition: easing.qc:6
Definition: easing.qh:10
float time
Definition: csprogsdefs.qc:16