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 * @addtogroup CAPI_DALI_ANIMATION_MODULE
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>
36 namespace Dali DALI_IMPORT_API
39 // Interpolation functions used by Constraints
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.
48 bool LerpBoolean( const bool& current, const bool& target, float progress );
51 * @brief Interpolate linearly between two float values.
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.
58 float LerpFloat( const float& current, const float& target, float progress );
61 * @brief Interpolate linearly between two Vector2 values.
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.
68 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
71 * @brief Interpolate linearly between two Vector3 values.
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.
78 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
81 * @brief Interpolate linearly between two Vector4 values.
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.
88 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
91 * @brief Spherical linear interpolation between two Quaternion values.
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.
98 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
101 * @brief A function which interpolates between a start and target value.
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.
108 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
111 * @brief A function which interpolates between a start and target value.
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.
118 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
121 * @brief A function which interpolates between a start and target value.
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.
128 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
131 * @brief A function which interpolates between a start and target value.
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.
138 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
141 * @brief A function which interpolates between a start and target value.
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.
148 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
151 * @brief A function which interpolates between a start and target value.
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.
158 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
161 * @brief A function which interpolates between a start and target value.
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.
168 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
171 * @brief A function which interpolates between a start and target value.
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.
178 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
181 * @brief Any interpolator function.
183 typedef Any AnyInterpolator;
186 * @brief Retrieve an interpolator function for a property.
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.
192 AnyInterpolator GetDefaultInterpolator(Property::Type type);
199 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__