1 #ifndef __DALI_INTERPOLATOR_FUNCTIONS_H__
2 #define __DALI_INTERPOLATOR_FUNCTIONS_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 * @addtogroup CAPI_DALI_ANIMATION_MODULE
26 #include <dali/public-api/object/any.h>
27 #include <dali/public-api/math/vector2.h>
28 #include <dali/public-api/math/vector3.h>
29 #include <dali/public-api/math/vector4.h>
30 #include <dali/public-api/math/quaternion.h>
31 #include <dali/public-api/math/matrix.h>
32 #include <dali/public-api/math/matrix3.h>
33 #include <dali/public-api/object/property.h>
35 namespace Dali DALI_IMPORT_API
38 // Interpolation functions used by Constraints
41 * @brief Interpolate linearly between two boolean values.
42 * @param [in] current The current value.
43 * @param [in] target The target value.
44 * @param [in] progress The current progress (between 0 & 1).
45 * @return The interpolated value.
47 bool LerpBoolean( const bool& current, const bool& target, float progress );
50 * @brief Interpolate linearly between two float values.
52 * @param [in] current The current value.
53 * @param [in] target The target value.
54 * @param [in] progress The current progress (between 0 & 1).
55 * @return The interpolated value.
57 float LerpFloat( const float& current, const float& target, float progress );
60 * @brief Interpolate linearly between two Vector2 values.
62 * @param [in] current The current value.
63 * @param [in] target The target value.
64 * @param [in] progress The current progress (between 0 & 1).
65 * @return The interpolated value.
67 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
70 * @brief Interpolate linearly between two Vector3 values.
72 * @param [in] current The current value.
73 * @param [in] target The target value.
74 * @param [in] progress The current progress (between 0 & 1).
75 * @return The interpolated value.
77 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
80 * @brief Interpolate linearly between two Vector4 values.
82 * @param [in] current The current value.
83 * @param [in] target The target value.
84 * @param [in] progress The current progress (between 0 & 1).
85 * @return The interpolated value.
87 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
90 * @brief Spherical linear interpolation between two Quaternion values.
92 * @param [in] current The current value.
93 * @param [in] target The target value.
94 * @param [in] progress The current progress (between 0 & 1).
95 * @return The interpolated value.
97 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
100 * @brief A function which interpolates between a start and target value.
102 * @param[in] start The start value.
103 * @param[in] target The target value.
104 * @param[in] progress The current progress (between 0 and 1).
105 * @return The interpolated value.
107 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
110 * @brief A function which interpolates between a start and target value.
112 * @param[in] start The start value.
113 * @param[in] target The target value.
114 * @param[in] progress The current progress (between 0 and 1).
115 * @return The interpolated value.
117 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
120 * @brief A function which interpolates between a start and target value.
122 * @param[in] start The start value.
123 * @param[in] target The target value.
124 * @param[in] progress The current progress (between 0 and 1).
125 * @return The interpolated value.
127 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
130 * @brief A function which interpolates between a start and target value.
132 * @param[in] start The start value.
133 * @param[in] target The target value.
134 * @param[in] progress The current progress (between 0 and 1).
135 * @return The interpolated value.
137 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
140 * @brief A function which interpolates between a start and target value.
142 * @param[in] start The start value.
143 * @param[in] target The target value.
144 * @param[in] progress The current progress (between 0 and 1).
145 * @return The interpolated value.
147 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
150 * @brief A function which interpolates between a start and target value.
152 * @param[in] start The start value.
153 * @param[in] target The target value.
154 * @param[in] progress The current progress (between 0 and 1).
155 * @return The interpolated value.
157 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
160 * @brief A function which interpolates between a start and target value.
162 * @param[in] start The start value.
163 * @param[in] target The target value.
164 * @param[in] progress The current progress (between 0 and 1).
165 * @return The interpolated value.
167 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
170 * @brief A function which interpolates between a start and target value.
172 * @param[in] start The start value.
173 * @param[in] target The target value.
174 * @param[in] progress The current progress (between 0 and 1).
175 * @return The interpolated value.
177 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
180 * @brief Any interpolator function.
182 typedef Any AnyInterpolator;
185 * @brief Retrieve an interpolator function for a property.
187 * This can be cast to boost::function<P (const P&, const P&, float)> where P corresponds to the property type.
188 * @param[in] type The property type for which to get an interpolator
189 * @return The interpolator function.
191 AnyInterpolator GetDefaultInterpolator(Property::Type type);
198 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__