c5161e572539e49945fa11b8f1da4fb8f1d58174
[platform/core/uifw/dali-core.git] / capi / dali / public-api / animation / interpolator-functions.h
1 #ifndef __DALI_INTERPOLATOR_FUNCTIONS_H__
2 #define __DALI_INTERPOLATOR_FUNCTIONS_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 /**
22  * @addtogroup CAPI_DALI_ANIMATION_MODULE
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/object/any.h>
28 #include <dali/public-api/math/vector2.h>
29 #include <dali/public-api/math/vector3.h>
30 #include <dali/public-api/math/vector4.h>
31 #include <dali/public-api/math/quaternion.h>
32 #include <dali/public-api/math/matrix.h>
33 #include <dali/public-api/math/matrix3.h>
34 #include <dali/public-api/object/property.h>
35
36 namespace Dali DALI_IMPORT_API
37 {
38
39 // Interpolation functions used by Constraints
40
41 /**
42  * @brief Interpolate linearly between two boolean values.
43  * @param [in] current The current value.
44  * @param [in] target The target value.
45  * @param [in] progress The current progress (between 0 & 1).
46  * @return The interpolated value.
47  */
48 bool LerpBoolean( const bool& current, const bool& target, float progress );
49
50 /**
51  * @brief Interpolate linearly between two float values.
52  *
53  * @param [in] current The current value.
54  * @param [in] target The target value.
55  * @param [in] progress The current progress (between 0 & 1).
56  * @return The interpolated value.
57  */
58 float LerpFloat( const float& current, const float& target, float progress );
59
60 /**
61  * @brief Interpolate linearly between two Vector2 values.
62  *
63  * @param [in] current The current value.
64  * @param [in] target The target value.
65  * @param [in] progress The current progress (between 0 & 1).
66  * @return The interpolated value.
67  */
68 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
69
70 /**
71  * @brief Interpolate linearly between two Vector3 values.
72  *
73  * @param [in] current The current value.
74  * @param [in] target The target value.
75  * @param [in] progress The current progress (between 0 & 1).
76  * @return The interpolated value.
77  */
78 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
79
80 /**
81  * @brief Interpolate linearly between two Vector4 values.
82  *
83  * @param [in] current The current value.
84  * @param [in] target The target value.
85  * @param [in] progress The current progress (between 0 & 1).
86  * @return The interpolated value.
87  */
88 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
89
90 /**
91  * @brief Spherical linear interpolation between two Quaternion values.
92  *
93  * @param [in] current The current value.
94  * @param [in] target The target value.
95  * @param [in] progress The current progress (between 0 & 1).
96  * @return The interpolated value.
97  */
98 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
99
100 /**
101  * @brief A function which interpolates between a start and target value.
102  *
103  * @param[in] start The start value.
104  * @param[in] target The target value.
105  * @param[in] progress The current progress (between 0 and 1).
106  * @return The interpolated value.
107  */
108 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
109
110 /**
111  * @brief A function which interpolates between a start and target value.
112  *
113  * @param[in] start The start value.
114  * @param[in] target The target value.
115  * @param[in] progress The current progress (between 0 and 1).
116  * @return The interpolated value.
117  */
118 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
119
120 /**
121  * @brief A function which interpolates between a start and target value.
122  *
123  * @param[in] start The start value.
124  * @param[in] target The target value.
125  * @param[in] progress The current progress (between 0 and 1).
126  * @return The interpolated value.
127  */
128 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
129
130 /**
131  * @brief A function which interpolates between a start and target value.
132  *
133  * @param[in] start The start value.
134  * @param[in] target The target value.
135  * @param[in] progress The current progress (between 0 and 1).
136  * @return The interpolated value.
137  */
138 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
139
140 /**
141  * @brief A function which interpolates between a start and target value.
142  *
143  * @param[in] start The start value.
144  * @param[in] target The target value.
145  * @param[in] progress The current progress (between 0 and 1).
146  * @return The interpolated value.
147  */
148 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
149
150 /**
151  * @brief A function which interpolates between a start and target value.
152  *
153  * @param[in] start The start value.
154  * @param[in] target The target value.
155  * @param[in] progress The current progress (between 0 and 1).
156  * @return The interpolated value.
157  */
158 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
159
160 /**
161  * @brief A function which interpolates between a start and target value.
162  *
163  * @param[in] start The start value.
164  * @param[in] target The target value.
165  * @param[in] progress The current progress (between 0 and 1).
166  * @return The interpolated value.
167  */
168 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
169
170 /**
171  * @brief A function which interpolates between a start and target value.
172  *
173  * @param[in] start The start value.
174  * @param[in] target The target value.
175  * @param[in] progress The current progress (between 0 and 1).
176  * @return The interpolated value.
177  */
178 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
179
180 /**
181  * @brief Any interpolator function.
182  */
183 typedef Any AnyInterpolator;
184
185 /**
186  * @brief Retrieve an interpolator function for a property.
187  *
188  * This can be cast to boost::function<P (const P&, const P&, float)> where P corresponds to the property type.
189  * @param[in] type The property type for which to get an interpolator
190  * @return The interpolator function.
191  */
192 AnyInterpolator GetDefaultInterpolator(Property::Type type);
193
194 } // namespace Dali
195
196 /**
197  * @}
198  */
199 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__