CUGL 1.2
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CUEasingFunction.h
1 //
2 // CUEasingFunction.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides easing function support for sophisticated tweening.
6 // All of the easing functions are implemented directly, using the definitions
7 // provided by http:://easings.net.
8 //
9 // This class is simply a factory for returning function pointers to the
10 // appropriate static method.
11 //
12 // CUGL MIT License:
13 // This software is provided 'as-is', without any express or implied
14 // warranty. In no event will the authors be held liable for any damages
15 // arising from the use of this software.
16 //
17 // Permission is granted to anyone to use this software for any purpose,
18 // including commercial applications, and to alter it and redistribute it
19 // freely, subject to the following restrictions:
20 //
21 // 1. The origin of this software must not be misrepresented; you must not
22 // claim that you wrote the original software. If you use this software
23 // in a product, an acknowledgment in the product documentation would be
24 // appreciated but is not required.
25 //
26 // 2. Altered source versions must be plainly marked as such, and must not
27 // be misrepresented as being the original software.
28 //
29 // 3. This notice may not be removed or altered from any source distribution.
30 //
31 // Author: Sophie Huang and Walker White
32 // Version: 3/12/17
33 //
34 #ifndef __CU_EASING_FUNCTION_H__
35 #define __CU_EASING_FUNCTION_H__
36 
37 #include <cugl/math/CUVec2.h>
38 #include <vector>
39 #include <memory>
40 
42 #define ELASTIC_PERIOD 0.3f
43 
44 namespace cugl {
45 
62 public:
66  enum class Type : int {
68  LINEAR,
70  SINE_IN,
72  SINE_OUT,
76  QUAD_IN,
78  QUAD_OUT,
82  CUBIC_IN,
84  CUBIC_OUT,
88  QUART_IN,
90  QUART_OUT,
94  QUINT_IN,
96  QUINT_OUT,
100  EXPO_IN,
102  EXPO_OUT,
104  EXPO_IN_OUT,
106  CIRC_IN,
108  CIRC_OUT,
110  CIRC_IN_OUT,
112  BACK_IN,
114  BACK_OUT,
116  BACK_IN_OUT,
118  BOUNCE_IN,
120  BOUNCE_OUT,
124  ELASTIC_IN,
126  ELASTIC_OUT,
129  };
130 
136  static std::function<float(float)> alloc() {
137  return alloc(Type::LINEAR);
138  }
139 
151  static std::function<float(float)> alloc(Type type, float period = ELASTIC_PERIOD);
152 
162  static float linear(float time);
163 
173  static float sineIn(float time);
174 
184  static float sineOut(float time);
185 
196  static float sineInOut(float time);
197 
207  static float quadIn(float time);
208 
218  static float quadOut(float time);
219 
230  static float quadInOut(float time);
231 
241  static float cubicIn(float time);
242 
252  static float cubicOut(float time);
253 
264  static float cubicInOut(float time);
265 
275  static float quartIn(float time);
276 
286  static float quartOut(float time);
287 
298  static float quartInOut(float time);
299 
309  static float quintIn(float time);
310 
320  static float quintOut(float time);
321 
332  static float quintInOut(float time);
333 
343  static float expoIn(float time);
344 
354  static float expoOut(float time);
355 
366  static float expoInOut(float time);
367 
377  static float circIn(float time);
378 
388  static float circOut(float time);
389 
400  static float circInOut(float time);
401 
411  static float backIn(float time);
412 
422  static float backOut(float time);
423 
434  static float backInOut(float time);
435 
446  static float bounceIn(float time);
447 
458  static float bounceOut(float time);
459 
470  static float bounceInOut(float time);
471 
483  static float elasticIn(float time, float period);
484 
496  static float elasticOut(float time, float period);
497 
509  static float elasticInOut(float time, float period);
510 
511 };
512 
513 }
514 
515 
516 #endif /* __CU_EASING_ELASTIC_H__ */
static float sineIn(float time)
static float quadInOut(float time)
static float quartIn(float time)
static float quintIn(float time)
static float elasticInOut(float time, float period)
static float bounceInOut(float time)
static float circIn(float time)
static float circOut(float time)
static float quartOut(float time)
static float circInOut(float time)
static float sineOut(float time)
static std::function< float(float)> alloc()
Definition: CUEasingFunction.h:136
static float cubicOut(float time)
Type
Definition: CUEasingFunction.h:66
static float cubicIn(float time)
static float linear(float time)
static float backIn(float time)
static float elasticOut(float time, float period)
static float bounceIn(float time)
static float backInOut(float time)
static float quintInOut(float time)
static float quartInOut(float time)
static float quadIn(float time)
static float expoOut(float time)
static float backOut(float time)
static float quintOut(float time)
static float cubicInOut(float time)
Definition: CUEasingFunction.h:61
static float quadOut(float time)
static float expoIn(float time)
Definition: CUAction.h:51
static float expoInOut(float time)
static float bounceOut(float time)
static float sineInOut(float time)
static float elasticIn(float time, float period)