1 #ifndef __DALI_INTERPOLATOR_FUNCTIONS_H__
2 #define __DALI_INTERPOLATOR_FUNCTIONS_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
31 namespace Dali DALI_IMPORT_API
34 // Interpolation functions used by Constraints
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.
43 bool LerpBoolean( const bool& current, const bool& target, float progress );
46 * @brief Interpolate linearly between two float values.
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.
53 float LerpFloat( const float& current, const float& target, float progress );
56 * @brief Interpolate linearly between two integer values.
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.
63 int LerpInteger( const int& current, const int& target, float progress );
66 * @brief Interpolate linearly between two Vector2 values.
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.
73 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
76 * @brief Interpolate linearly between two Vector3 values.
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.
83 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
86 * @brief Interpolate linearly between two Vector4 values.
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.
93 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
96 * @brief Spherical linear interpolation between two Quaternion values.
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.
103 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
106 * @brief A function which interpolates between a start and target value.
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.
113 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
116 * @brief A function which interpolates between a start and target value.
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.
123 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
126 * @brief A function which interpolates between a start and target value.
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.
133 typedef boost::function<int (const int& start, const int& target, float progress)> IntegerInterpolator;
136 * @brief A function which interpolates between a start and target value.
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.
143 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
146 * @brief A function which interpolates between a start and target value.
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.
153 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
156 * @brief A function which interpolates between a start and target value.
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.
163 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
166 * @brief A function which interpolates between a start and target value.
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.
173 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
176 * @brief A function which interpolates between a start and target value.
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.
183 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
186 * @brief A function which interpolates between a start and target value.
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.
193 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
196 * @brief Any interpolator function.
198 typedef Any AnyInterpolator;
201 * @brief Retrieve an interpolator function for a property.
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.
207 AnyInterpolator GetDefaultInterpolator(Property::Type type);
211 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__