-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEasingFunc.cpp
More file actions
119 lines (89 loc) · 1.52 KB
/
EasingFunc.cpp
File metadata and controls
119 lines (89 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "EasingFunc.h"
#include <cmath>
namespace Aurora
{
double EaseNone::EaseIn( double t )
{
return 0;
}
double EaseNone::EaseOut( double t )
{
return 0;
}
double EaseNone::EaseInOut( double t )
{
return 0;
}
double easing_back_func( double t )
{
const double s( 1.70158 );
return t * t * ( (s+1) * t - s);
}
double easing_bounce_func( double t )
{
const double v = 1 - t;
double c;
double d;
if ( v < (1 / 2.75) )
{
c = v;
d = 0;
}
else if ( v < (2 / 2.75) )
{
c = v - 1.5 / 2.75;
d = 0.75;
}
else if ( v < (2.5 / 2.75) )
{
c = v - 2.25 / 2.75;
d = 0.9375;
}
else
{
c = v - 2.625 / 2.75;
d = 0.984375;
}
return 1 - (7.5625 * c * c + d);
}
double easing_circ_func( double t )
{
return 1 - std::sqrt(1 - t * t);
}
double easing_cubic_func( double t )
{
return t * t * t;
}
double easing_elastic_func( double t )
{
const double pi = 3.1514926;
const double v(t-1);
const double p(0.3);
return -std::pow(2, 10 * v) * std::sin( (v - p / 4) * 2 * pi / p );
}
double easing_expo_func( double t )
{
return t == 0 ? 0 : std::pow(2, 10 * (t - 1));
}
double easing_linear_func( double t )
{
return t;
}
double easing_quad_func( double t )
{
return t * t;
}
double easing_quart_func( double t )
{
return t * t * t * t;
}
double easing_quint_func( double t )
{
return t * t * t * t * t;
}
double easing_sine_func( double t )
{
const double pi = 3.1514926;
return 1 - std::cos(t * pi / 2);
}
}