2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <boost/function.hpp>
22 #include <dali/public-api/animation/interpolator-functions.h>
27 bool LerpBoolean( const bool& current, const bool& target, float progress )
29 // Not particularly useful for boolean values
38 float LerpFloat( const float& current, const float& target, float progress )
40 return current + ((target - current) * progress);
43 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress )
45 return current + ((target - current) * progress);
48 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress )
50 return current + ((target - current) * progress);
53 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress )
55 return current + ((target - current) * progress);
58 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress )
60 return Quaternion::Slerp(current, target, progress);
63 Matrix LerpMatrix( const Matrix& current, const Matrix& target, float progress )
73 Matrix3 LerpMatrix3( const Matrix3& current, const Matrix3& target, float progress )
83 AnyInterpolator GetDefaultInterpolator( Property::Type type )
85 AnyInterpolator function;
89 case Property::BOOLEAN:
91 function = boost::function<bool (const bool&, const bool&, float)>( &LerpBoolean );
97 function = boost::function<float (const float&, const float&, float)>( &LerpFloat );
101 case Property::VECTOR2:
103 function = boost::function<Vector2 (const Vector2&, const Vector2&, float)>( &LerpVector2 );
107 case Property::VECTOR3:
109 function = boost::function<Vector3 (const Vector3&, const Vector3&, float)>( &LerpVector3 );
113 case Property::VECTOR4:
115 function = boost::function<Vector4 (const Vector4&, const Vector4&, float)>( &LerpVector4 );
119 case Property::ROTATION:
121 function = boost::function<Quaternion (const Quaternion&, const Quaternion&, float)>( &SlerpQuaternion );
125 case Property::MATRIX3:
127 function = boost::function<Matrix3 (const Matrix3&, const Matrix3&, float)>(&LerpMatrix3);
131 case Property::MATRIX:
133 function = boost::function<Matrix (const Matrix&, const Matrix&, float)>(&LerpMatrix);