Merge "Change shader data pointer to IntrusivePtr" into tizen
[platform/core/uifw/dali-core.git] / 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 // INTERNAL INCLUDES
22 #include <dali/public-api/object/any.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/public-api/math/vector3.h>
25 #include <dali/public-api/math/vector4.h>
26 #include <dali/public-api/math/quaternion.h>
27 #include <dali/public-api/math/matrix.h>
28 #include <dali/public-api/math/matrix3.h>
29 #include <dali/public-api/object/property.h>
30
31 namespace Dali DALI_IMPORT_API
32 {
33
34 // Interpolation functions used by Constraints
35
36 /**
37  * @brief Interpolate linearly between two boolean values.
38  * @param [in] current The current value.
39  * @param [in] target The target value.
40  * @param [in] progress The current progress (between 0 & 1).
41  * @return The interpolated value.
42  */
43 bool LerpBoolean( const bool& current, const bool& target, float progress );
44
45 /**
46  * @brief Interpolate linearly between two float values.
47  *
48  * @param [in] current The current value.
49  * @param [in] target The target value.
50  * @param [in] progress The current progress (between 0 & 1).
51  * @return The interpolated value.
52  */
53 float LerpFloat( const float& current, const float& target, float progress );
54
55 /**
56  * @brief Interpolate linearly between two integer values.
57  *
58  * @param [in] current The current value.
59  * @param [in] target The target value.
60  * @param [in] progress The current progress (between 0 & 1).
61  * @return The interpolated value.
62  */
63 int LerpInteger( const int& current, const int& target, float progress );
64
65 /**
66  * @brief Interpolate linearly between two Vector2 values.
67  *
68  * @param [in] current The current value.
69  * @param [in] target The target value.
70  * @param [in] progress The current progress (between 0 & 1).
71  * @return The interpolated value.
72  */
73 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
74
75 /**
76  * @brief Interpolate linearly between two Vector3 values.
77  *
78  * @param [in] current The current value.
79  * @param [in] target The target value.
80  * @param [in] progress The current progress (between 0 & 1).
81  * @return The interpolated value.
82  */
83 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
84
85 /**
86  * @brief Interpolate linearly between two Vector4 values.
87  *
88  * @param [in] current The current value.
89  * @param [in] target The target value.
90  * @param [in] progress The current progress (between 0 & 1).
91  * @return The interpolated value.
92  */
93 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
94
95 /**
96  * @brief Spherical linear interpolation between two Quaternion values.
97  *
98  * @param [in] current The current value.
99  * @param [in] target The target value.
100  * @param [in] progress The current progress (between 0 & 1).
101  * @return The interpolated value.
102  */
103 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
104
105 /**
106  * @brief A function which interpolates between a start and target value.
107  *
108  * @param[in] start The start value.
109  * @param[in] target The target value.
110  * @param[in] progress The current progress (between 0 and 1).
111  * @return The interpolated value.
112  */
113 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
114
115 /**
116  * @brief A function which interpolates between a start and target value.
117  *
118  * @param[in] start The start value.
119  * @param[in] target The target value.
120  * @param[in] progress The current progress (between 0 and 1).
121  * @return The interpolated value.
122  */
123 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
124
125 /**
126  * @brief A function which interpolates between a start and target value.
127  *
128  * @param[in] start The start value.
129  * @param[in] target The target value.
130  * @param[in] progress The current progress (between 0 and 1).
131  * @return The interpolated value.
132  */
133 typedef boost::function<int (const int& start, const int& target, float progress)> IntegerInterpolator;
134
135 /**
136  * @brief A function which interpolates between a start and target value.
137  *
138  * @param[in] start The start value.
139  * @param[in] target The target value.
140  * @param[in] progress The current progress (between 0 and 1).
141  * @return The interpolated value.
142  */
143 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
144
145 /**
146  * @brief A function which interpolates between a start and target value.
147  *
148  * @param[in] start The start value.
149  * @param[in] target The target value.
150  * @param[in] progress The current progress (between 0 and 1).
151  * @return The interpolated value.
152  */
153 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
154
155 /**
156  * @brief A function which interpolates between a start and target value.
157  *
158  * @param[in] start The start value.
159  * @param[in] target The target value.
160  * @param[in] progress The current progress (between 0 and 1).
161  * @return The interpolated value.
162  */
163 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
164
165 /**
166  * @brief A function which interpolates between a start and target value.
167  *
168  * @param[in] start The start value.
169  * @param[in] target The target value.
170  * @param[in] progress The current progress (between 0 and 1).
171  * @return The interpolated value.
172  */
173 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
174
175 /**
176  * @brief A function which interpolates between a start and target value.
177  *
178  * @param[in] start The start value.
179  * @param[in] target The target value.
180  * @param[in] progress The current progress (between 0 and 1).
181  * @return The interpolated value.
182  */
183 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
184
185 /**
186  * @brief A function which interpolates between a start and target value.
187  *
188  * @param[in] start The start value.
189  * @param[in] target The target value.
190  * @param[in] progress The current progress (between 0 and 1).
191  * @return The interpolated value.
192  */
193 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
194
195 /**
196  * @brief Any interpolator function.
197  */
198 typedef Any AnyInterpolator;
199
200 /**
201  * @brief Retrieve an interpolator function for a property.
202  *
203  * This can be cast to boost::function<P (const P&, const P&, float)> where P corresponds to the property type.
204  * @param[in] type The property type for which to get an interpolator
205  * @return The interpolator function.
206  */
207 AnyInterpolator GetDefaultInterpolator(Property::Type type);
208
209 } // namespace Dali
210
211 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__