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 int LerpInteger( const int& current, const int& target, float progress )
45 return static_cast<int>( current + ( (target - current) * progress ) + 0.5f );
48 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress )
50 return current + ((target - current) * progress);
53 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress )
55 return current + ((target - current) * progress);
58 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress )
60 return current + ((target - current) * progress);
63 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress )
65 return Quaternion::Slerp(current, target, progress);
68 Matrix LerpMatrix( const Matrix& current, const Matrix& target, float progress )
78 Matrix3 LerpMatrix3( const Matrix3& current, const Matrix3& target, float progress )
88 AnyInterpolator GetDefaultInterpolator( Property::Type type )
90 AnyInterpolator function;
94 case Property::BOOLEAN:
96 function = boost::function<bool (const bool&, const bool&, float)>( &LerpBoolean );
100 case Property::FLOAT:
102 function = boost::function<float (const float&, const float&, float)>( &LerpFloat );
106 case Property::INTEGER:
108 function = boost::function<int (const int&, const int&, float)>( &LerpInteger );
112 case Property::VECTOR2:
114 function = boost::function<Vector2 (const Vector2&, const Vector2&, float)>( &LerpVector2 );
118 case Property::VECTOR3:
120 function = boost::function<Vector3 (const Vector3&, const Vector3&, float)>( &LerpVector3 );
124 case Property::VECTOR4:
126 function = boost::function<Vector4 (const Vector4&, const Vector4&, float)>( &LerpVector4 );
130 case Property::ROTATION:
132 function = boost::function<Quaternion (const Quaternion&, const Quaternion&, float)>( &SlerpQuaternion );
136 case Property::MATRIX3:
138 function = boost::function<Matrix3 (const Matrix3&, const Matrix3&, float)>(&LerpMatrix3);
142 case Property::MATRIX:
144 function = boost::function<Matrix (const Matrix&, const Matrix&, float)>(&LerpMatrix);