ScummVM API documentation
easing.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef TWP_EASING_H
23
#define TWP_EASING_H
24
25
#include "common/func.h"
26
#include "math/vector2d.h"
27
#include "twp/rectf.h"
28
29
namespace
Twp
{
30
31
typedef
float
EasingFunc(
float
t);
32
33
typedef
struct
EasingFunc_t
{
34
EasingFunc *func;
35
}
EasingFunc_t
;
36
37
enum
InterpolationKind {
38
IK_LINEAR = 0,
39
IK_EASEIN = 1,
40
IK_EASEINOUT = 2,
41
IK_EASEOUT = 3,
42
IK_SLOWEASEIN = 4,
43
IK_SLOWEASEOUT = 5
44
};
45
46
struct
InterpolationMethod
{
47
InterpolationKind kind = IK_LINEAR;
48
bool
loop =
false
;
49
bool
swing =
false
;
50
};
51
52
InterpolationMethod
intToInterpolationMethod(
int
value);
53
54
static
float
linear(
float
t) {
return
t; }
55
56
static
float
easeIn(
float
t) {
57
return
t * t * t * t;
58
}
59
60
static
float
easeOut(
float
t) {
61
float
f = (t - 1.0f);
62
return
f * f * f * (1.0f - t) + 1.0f;
63
}
64
65
static
float
easeInOut(
float
t) {
66
if
(t < 0.5f)
67
return
8.0f * t * t * t * t;
68
float
f = (t - 1.0f);
69
return
-8.f * f * f * f * f + 1.f;
70
}
71
72
inline
EasingFunc_t
easing(InterpolationKind kind) {
73
switch
(kind) {
74
case
IK_LINEAR:
75
return
{&linear};
76
case
IK_EASEIN:
77
return
{&easeIn};
78
case
IK_EASEINOUT:
79
return
{&easeInOut};
80
case
IK_EASEOUT:
81
return
{&easeOut};
82
case
IK_SLOWEASEIN:
83
return
{&easeIn};
84
case
IK_SLOWEASEOUT:
85
return
{&easeOut};
86
}
87
error
(
"Invalid interpolation kind: %d"
, kind);
88
return
{&linear};
89
}
90
91
}
// namespace Twp
92
93
#endif
Twp::EasingFunc_t
Definition:
easing.h:33
error
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Twp::InterpolationMethod
Definition:
easing.h:46
Twp
Definition:
achievements_tables.h:27
engines
twp
easing.h
Generated on Sun Dec 22 2024 09:20:50 for ScummVM API documentation by
1.8.13