[chore] add Interpolator
This commit is contained in:
parent
21c476c56f
commit
8f6fd5d1f6
|
|
@ -9,6 +9,12 @@
|
|||
<ClInclude Include="..\..\src\kiwano\2d\action\ActionTween.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\action\Animation.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\Actor.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Animation.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\EaseFunc.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\FrameAnimation.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Interpolator.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Key.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\TweenAnimation.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\base\component\Button.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\base\component\Component.h" />
|
||||
|
|
@ -123,6 +129,10 @@
|
|||
<ClCompile Include="..\..\src\kiwano\2d\action\ActionTween.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\action\Animation.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\Actor.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\Animation.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\EaseFunc.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\FrameAnimation.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\TweenAnimation.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\DebugActor.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\ShapeActor.cpp" />
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
<Filter Include="base\component">
|
||||
<UniqueIdentifier>{d15f4de1-7c2c-40d6-a3ce-68860b95a61e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="2d\animation">
|
||||
<UniqueIdentifier>{254c8f6b-8a27-4241-bae1-39cee771ccde}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\Canvas.h">
|
||||
|
|
@ -369,6 +372,24 @@
|
|||
<ClInclude Include="..\..\src\kiwano\core\Value.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Animation.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\EaseFunc.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\FrameAnimation.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Interpolator.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\Key.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\2d\animation\TweenAnimation.h">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp">
|
||||
|
|
@ -605,6 +626,18 @@
|
|||
<ClCompile Include="..\..\src\kiwano\core\Duration.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\Animation.cpp">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\EaseFunc.cpp">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\FrameAnimation.cpp">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\animation\TweenAnimation.cpp">
|
||||
<Filter>2d\animation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="suppress_warning.ruleset" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano/2d/animation/Animation.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano/2d/animation/EaseFunc.h>
|
||||
#include <kiwano/math/Math.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
inline EaseFunc MakeEaseIn(float rate)
|
||||
{
|
||||
return std::bind(math::EaseIn, std::placeholders::_1, rate);
|
||||
}
|
||||
inline EaseFunc MakeEaseOut(float rate)
|
||||
{
|
||||
return std::bind(math::EaseOut, std::placeholders::_1, rate);
|
||||
}
|
||||
inline EaseFunc MakeEaseInOut(float rate)
|
||||
{
|
||||
return std::bind(math::EaseInOut, std::placeholders::_1, rate);
|
||||
}
|
||||
inline EaseFunc MakeEaseElasticIn(float period)
|
||||
{
|
||||
return std::bind(math::EaseElasticIn, std::placeholders::_1, period);
|
||||
}
|
||||
inline EaseFunc MakeEaseElasticOut(float period)
|
||||
{
|
||||
return std::bind(math::EaseElasticOut, std::placeholders::_1, period);
|
||||
}
|
||||
inline EaseFunc MakeEaseElasticInOut(float period)
|
||||
{
|
||||
return std::bind(math::EaseElasticInOut, std::placeholders::_1, period);
|
||||
}
|
||||
|
||||
KGE_API EaseFunc Ease::Linear = math::Linear;
|
||||
KGE_API EaseFunc Ease::EaseIn = MakeEaseIn(2.f);
|
||||
KGE_API EaseFunc Ease::EaseOut = MakeEaseOut(2.f);
|
||||
KGE_API EaseFunc Ease::EaseInOut = MakeEaseInOut(2.f);
|
||||
KGE_API EaseFunc Ease::ExpoIn = math::EaseExponentialIn;
|
||||
KGE_API EaseFunc Ease::ExpoOut = math::EaseExponentialOut;
|
||||
KGE_API EaseFunc Ease::ExpoInOut = math::EaseExponentialInOut;
|
||||
KGE_API EaseFunc Ease::BounceIn = math::EaseBounceIn;
|
||||
KGE_API EaseFunc Ease::BounceOut = math::EaseBounceOut;
|
||||
KGE_API EaseFunc Ease::BounceInOut = math::EaseBounceInOut;
|
||||
KGE_API EaseFunc Ease::ElasticIn = MakeEaseElasticIn(0.3f);
|
||||
KGE_API EaseFunc Ease::ElasticOut = MakeEaseElasticOut(0.3f);
|
||||
KGE_API EaseFunc Ease::ElasticInOut = MakeEaseElasticInOut(0.3f);
|
||||
KGE_API EaseFunc Ease::SineIn = math::EaseSineIn;
|
||||
KGE_API EaseFunc Ease::SineOut = math::EaseSineOut;
|
||||
KGE_API EaseFunc Ease::SineInOut = math::EaseSineInOut;
|
||||
KGE_API EaseFunc Ease::BackIn = math::EaseBackIn;
|
||||
KGE_API EaseFunc Ease::BackOut = math::EaseBackOut;
|
||||
KGE_API EaseFunc Ease::BackInOut = math::EaseBackInOut;
|
||||
KGE_API EaseFunc Ease::QuadIn = math::EaseQuadIn;
|
||||
KGE_API EaseFunc Ease::QuadOut = math::EaseQuadOut;
|
||||
KGE_API EaseFunc Ease::QuadInOut = math::EaseQuadInOut;
|
||||
KGE_API EaseFunc Ease::CubicIn = math::EaseCubicIn;
|
||||
KGE_API EaseFunc Ease::CubicOut = math::EaseCubicOut;
|
||||
KGE_API EaseFunc Ease::CubicInOut = math::EaseCubicInOut;
|
||||
KGE_API EaseFunc Ease::QuartIn = math::EaseQuartIn;
|
||||
KGE_API EaseFunc Ease::QuartOut = math::EaseQuartOut;
|
||||
KGE_API EaseFunc Ease::QuartInOut = math::EaseQuartInOut;
|
||||
KGE_API EaseFunc Ease::QuintIn = math::EaseQuintIn;
|
||||
KGE_API EaseFunc Ease::QuintOut = math::EaseQuintOut;
|
||||
KGE_API EaseFunc Ease::QuintInOut = math::EaseQuintInOut;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 缓动函数
|
||||
using EaseFunc = Function<float(float)>;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 缓动函数枚举
|
||||
/// @details 查看 https://easings.net 获取更多信息
|
||||
struct Ease
|
||||
{
|
||||
static KGE_API EaseFunc Linear; ///< 线性
|
||||
static KGE_API EaseFunc EaseIn; ///< 由慢变快
|
||||
static KGE_API EaseFunc EaseOut; ///< 由快变慢
|
||||
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
|
||||
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
|
||||
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
|
||||
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
|
||||
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
|
||||
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
|
||||
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
|
||||
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
|
||||
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
|
||||
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
|
||||
static KGE_API EaseFunc BackIn;
|
||||
static KGE_API EaseFunc BackOut;
|
||||
static KGE_API EaseFunc BackInOut;
|
||||
static KGE_API EaseFunc QuadIn;
|
||||
static KGE_API EaseFunc QuadOut;
|
||||
static KGE_API EaseFunc QuadInOut;
|
||||
static KGE_API EaseFunc CubicIn;
|
||||
static KGE_API EaseFunc CubicOut;
|
||||
static KGE_API EaseFunc CubicInOut;
|
||||
static KGE_API EaseFunc QuartIn;
|
||||
static KGE_API EaseFunc QuartOut;
|
||||
static KGE_API EaseFunc QuartInOut;
|
||||
static KGE_API EaseFunc QuintIn;
|
||||
static KGE_API EaseFunc QuintOut;
|
||||
static KGE_API EaseFunc QuintInOut;
|
||||
static KGE_API EaseFunc SineIn;
|
||||
static KGE_API EaseFunc SineOut;
|
||||
static KGE_API EaseFunc SineInOut;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano/2d/animation/Animation.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) 2019-2020 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/math/Math.h>
|
||||
#include <kiwano/2d/animation/EaseFunc.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
#define KGE_INTERPOLATOR_NUMRIC_INTERPOLATE_IMPL(TYPE) \
|
||||
inline TYPE Interpolate(TYPE start, TYPE end, float frac) \
|
||||
{ \
|
||||
return NumricInterpolate(start, end, Fraction(frac)); \
|
||||
}
|
||||
|
||||
class KGE_API Interpolator
|
||||
{
|
||||
public:
|
||||
inline Interpolator() {}
|
||||
|
||||
inline Interpolator(const EaseFunc& ease_func)
|
||||
: ease_func_(ease_func)
|
||||
{
|
||||
}
|
||||
|
||||
KGE_INTERPOLATOR_NUMRIC_INTERPOLATE_IMPL(int)
|
||||
KGE_INTERPOLATOR_NUMRIC_INTERPOLATE_IMPL(unsigned)
|
||||
KGE_INTERPOLATOR_NUMRIC_INTERPOLATE_IMPL(float)
|
||||
KGE_INTERPOLATOR_NUMRIC_INTERPOLATE_IMPL(double)
|
||||
|
||||
template <typename _Ty>
|
||||
inline _Ty Interpolate(_Ty start, _Ty end, float frac)
|
||||
{
|
||||
if (NumricInterpolate(0, 1, Fraction(frac)) == 1)
|
||||
return end;
|
||||
return start;
|
||||
}
|
||||
|
||||
private:
|
||||
inline float Fraction(float frac)
|
||||
{
|
||||
if (ease_func_)
|
||||
{
|
||||
return ease_func_(frac);
|
||||
}
|
||||
return frac;
|
||||
}
|
||||
|
||||
template <typename _Ty>
|
||||
inline _Ty NumricInterpolate(_Ty start, _Ty end, float frac)
|
||||
{
|
||||
return start + static_cast<_Ty>(math::Floor(static_cast<float>(end - start) * frac));
|
||||
}
|
||||
|
||||
private:
|
||||
EaseFunc ease_func_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright (c) 2019-2020 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/2d/animation/Interpolator.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
template <typename _Ty, typename _NotifierTy>
|
||||
class KeyValue
|
||||
{
|
||||
public:
|
||||
typedef _Ty value_type;
|
||||
typedef Value<_Ty, _NotifierTy> property_type;
|
||||
|
||||
inline KeyValue(const property_type& prop, value_type end_value)
|
||||
: end_value_(end_value)
|
||||
, prop_(prop)
|
||||
, interpolator_()
|
||||
{
|
||||
}
|
||||
|
||||
inline KeyValue(const property_type& prop, value_type end_value, const EaseFunc& ease_func)
|
||||
: end_value_(end_value)
|
||||
, prop_(prop)
|
||||
, interpolator_(ease_func)
|
||||
{
|
||||
}
|
||||
|
||||
inline property_type GetProperty() const
|
||||
{
|
||||
return prop_;
|
||||
}
|
||||
|
||||
inline value_type GetEndValue() const
|
||||
{
|
||||
return end_value_;
|
||||
}
|
||||
|
||||
inline const Interpolator& GetInterpolator() const
|
||||
{
|
||||
return interpolator_;
|
||||
}
|
||||
|
||||
private:
|
||||
property_type prop_;
|
||||
value_type end_value_;
|
||||
Interpolator interpolator_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano/2d/animation/Animation.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue