Skip to content

Commit 5fd9594

Browse files
committed
add double versions of easings
1 parent 0867f3f commit 5fd9594

File tree

5 files changed

+381
-92
lines changed

5 files changed

+381
-92
lines changed

include/gf2/core/Activities.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace gf {
1818

1919
class GF_CORE_API ValueActivity : public Activity {
2020
public:
21-
ValueActivity(float origin, float target, float* value, Time duration, Easing easing = ease_linear);
21+
ValueActivity(float origin, float target, float* value, Time duration, EasingF easing = ease_linear);
2222

2323
void set_origin(float origin)
2424
{
@@ -59,7 +59,7 @@ namespace gf {
5959

6060
class GF_CORE_API RotationActivity : public Activity {
6161
public:
62-
RotationActivity(float origin, float target, float* angle, Time duration, Easing easing = ease_linear);
62+
RotationActivity(float origin, float target, float* angle, Time duration, EasingF easing = ease_linear);
6363

6464
void set_origin(float origin)
6565
{
@@ -104,7 +104,7 @@ namespace gf {
104104

105105
class GF_CORE_API MotionActivity : public Activity {
106106
public:
107-
MotionActivity(Vec2F origin, Vec2F target, Vec2F* position, Time duration, Easing easing = ease_linear);
107+
MotionActivity(Vec2F origin, Vec2F target, Vec2F* position, Time duration, EasingF easing = ease_linear);
108108

109109
void set_origin(Vec2F origin)
110110
{
@@ -145,7 +145,7 @@ namespace gf {
145145

146146
class GF_CORE_API ColorActivity : public Activity {
147147
public:
148-
ColorActivity(Color origin, Color target, Color* color, Time duration, Easing easing = ease_linear);
148+
ColorActivity(Color origin, Color target, Color* color, Time duration, EasingF easing = ease_linear);
149149

150150
void set_origin(Color origin)
151151
{
@@ -261,22 +261,22 @@ namespace gf {
261261

262262
namespace activity {
263263

264-
inline ValueActivity value(float origin, float target, float* value, Time duration, Easing easing = ease_linear)
264+
inline ValueActivity value(float origin, float target, float* value, Time duration, EasingF easing = ease_linear)
265265
{
266266
return { origin, target, value, duration, easing };
267267
}
268268

269-
inline RotationActivity rotation(float origin, float target, float* value, Time duration, Easing easing = ease_linear)
269+
inline RotationActivity rotation(float origin, float target, float* value, Time duration, EasingF easing = ease_linear)
270270
{
271271
return { origin, target, value, duration, easing };
272272
}
273273

274-
inline MotionActivity motion(Vec2F origin, Vec2F target, Vec2F* value, Time duration, Easing easing = ease_linear)
274+
inline MotionActivity motion(Vec2F origin, Vec2F target, Vec2F* value, Time duration, EasingF easing = ease_linear)
275275
{
276276
return { origin, target, value, duration, easing };
277277
}
278278

279-
inline ColorActivity color(Color origin, Color target, Color* value, Time duration, Easing easing = ease_linear)
279+
inline ColorActivity color(Color origin, Color target, Color* value, Time duration, EasingF easing = ease_linear)
280280
{
281281
return { origin, target, value, duration, easing };
282282
}

include/gf2/core/Easing.h

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
namespace gf {
99

10-
using Easing = float (*)(float);
10+
template<typename T>
11+
using Easing = T (*)(T);
12+
13+
using EasingF = Easing<float>;
1114

1215
GF_CORE_API float ease_linear(float t);
1316
GF_CORE_API float ease_smooth(float t);
@@ -63,6 +66,62 @@ namespace gf {
6366
GF_CORE_API float ease_in_out_expo(float t);
6467
GF_CORE_API float ease_out_in_expo(float t);
6568

69+
using EasingD = Easing<double>;
70+
71+
GF_CORE_API double ease_linear(double t);
72+
GF_CORE_API double ease_smooth(double t);
73+
GF_CORE_API double ease_smoother(double t);
74+
75+
GF_CORE_API double ease_in_sine(double t);
76+
GF_CORE_API double ease_out_sine(double t);
77+
GF_CORE_API double ease_in_out_sine(double t);
78+
GF_CORE_API double ease_out_in_sine(double t);
79+
80+
GF_CORE_API double ease_in_quad(double t);
81+
GF_CORE_API double ease_out_quad(double t);
82+
GF_CORE_API double ease_in_out_quad(double t);
83+
GF_CORE_API double ease_out_in_quad(double t);
84+
85+
GF_CORE_API double ease_in_cubic(double t);
86+
GF_CORE_API double ease_out_cubic(double t);
87+
GF_CORE_API double ease_in_out_cubic(double t);
88+
GF_CORE_API double ease_out_in_cubic(double t);
89+
90+
GF_CORE_API double ease_in_quart(double t);
91+
GF_CORE_API double ease_out_quart(double t);
92+
GF_CORE_API double ease_in_out_quart(double t);
93+
GF_CORE_API double ease_out_in_quart(double t);
94+
95+
GF_CORE_API double ease_in_quint(double t);
96+
GF_CORE_API double ease_out_quint(double t);
97+
GF_CORE_API double ease_in_out_quint(double t);
98+
GF_CORE_API double ease_out_in_quint(double t);
99+
100+
GF_CORE_API double ease_in_circ(double t);
101+
GF_CORE_API double ease_out_circ(double t);
102+
GF_CORE_API double ease_in_out_circ(double t);
103+
GF_CORE_API double ease_out_in_circ(double t);
104+
105+
GF_CORE_API double ease_in_back(double t);
106+
GF_CORE_API double ease_out_back(double t);
107+
GF_CORE_API double ease_in_out_back(double t);
108+
GF_CORE_API double ease_out_in_back(double t);
109+
110+
GF_CORE_API double ease_in_bounce(double t);
111+
GF_CORE_API double ease_out_bounce(double t);
112+
GF_CORE_API double ease_in_out_bounce(double t);
113+
GF_CORE_API double ease_out_in_bounce(double t);
114+
115+
GF_CORE_API double ease_in_elastic(double t);
116+
GF_CORE_API double ease_out_elastic(double t);
117+
GF_CORE_API double ease_in_out_elastic(double t);
118+
GF_CORE_API double ease_out_in_elastic(double t);
119+
120+
GF_CORE_API double ease_in_expo(double t);
121+
GF_CORE_API double ease_out_expo(double t);
122+
GF_CORE_API double ease_in_out_expo(double t);
123+
GF_CORE_API double ease_out_in_expo(double t);
124+
66125
}
67126

68127
#endif // GF_EASING_H

include/gf2/core/Tween.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace gf {
1616
public:
1717
using Setter = std::function<void(const T&)>;
1818

19-
Tween(T origin, T target, Setter setter, Time duration, Easing easing = ease_linear)
19+
Tween(T origin, T target, Setter setter, Time duration, EasingF easing = ease_linear)
2020
: m_origin(origin)
2121
, m_target(target)
2222
, m_setter(setter)
@@ -25,7 +25,7 @@ namespace gf {
2525
{
2626
}
2727

28-
Tween(T origin, T target, T* value, Time duration, Easing easing = ease_linear)
28+
Tween(T origin, T target, T* value, Time duration, EasingF easing = ease_linear)
2929
: m_origin(origin)
3030
, m_target(target)
3131
, m_setter([value](const T& new_value) { if (value != nullptr) { *value = new_value; } })
@@ -92,7 +92,7 @@ namespace gf {
9292
Setter m_setter;
9393
Time m_elapsed;
9494
Time m_duration;
95-
Easing m_easing = ease_linear;
95+
EasingF m_easing = ease_linear;
9696
};
9797

9898
}

library/core/Activities.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace gf {
1212
* ValueActivity
1313
*/
1414

15-
ValueActivity::ValueActivity(float origin, float target, float* value, Time duration, Easing easing)
15+
ValueActivity::ValueActivity(float origin, float target, float* value, Time duration, EasingF easing)
1616
: m_tween(origin, target, value, duration, easing)
1717
{
1818
}
@@ -36,7 +36,7 @@ namespace gf {
3636
* RotateToActivity
3737
*/
3838

39-
RotationActivity::RotationActivity(float origin, float target, float* angle, Time duration, Easing easing)
39+
RotationActivity::RotationActivity(float origin, float target, float* angle, Time duration, EasingF easing)
4040
: m_tween(origin, target, angle, duration, easing)
4141
{
4242
normalize();
@@ -72,7 +72,7 @@ namespace gf {
7272
* MoveToActivity
7373
*/
7474

75-
MotionActivity::MotionActivity(Vec2F origin, Vec2F target, Vec2F* position, Time duration, Easing easing)
75+
MotionActivity::MotionActivity(Vec2F origin, Vec2F target, Vec2F* position, Time duration, EasingF easing)
7676
: m_tween(origin, target, position, duration, easing)
7777
{
7878
}
@@ -96,7 +96,7 @@ namespace gf {
9696
* ColorActivity
9797
*/
9898

99-
ColorActivity::ColorActivity(Color origin, Color target, Color* color, Time duration, Easing easing)
99+
ColorActivity::ColorActivity(Color origin, Color target, Color* color, Time duration, EasingF easing)
100100
: m_tween(origin, target, color, duration, easing)
101101
{
102102
}

0 commit comments

Comments
 (0)