43 lines
2.1 KiB
C#
43 lines
2.1 KiB
C#
using Syntriax.Engine.Core;
|
|
|
|
namespace Syntriax.Engine.Systems.Tween;
|
|
|
|
public static class TweenTransform2DExtensions
|
|
{
|
|
public static ITween TweenPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetPosition)
|
|
{
|
|
Vector2D initialPosition = transform2D.Position;
|
|
return tweenManager.StartTween(duration, t => transform2D.Position = initialPosition.Lerp(targetPosition, t));
|
|
}
|
|
|
|
public static ITween TweenScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetScale)
|
|
{
|
|
Vector2D initialScale = transform2D.Scale;
|
|
return tweenManager.StartTween(duration, t => transform2D.Scale = initialScale.Lerp(targetScale, t));
|
|
}
|
|
|
|
public static ITween TweenRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetRotation)
|
|
{
|
|
float initialRotation = transform2D.Rotation;
|
|
return tweenManager.StartTween(duration, t => transform2D.Rotation = initialRotation.Lerp(targetRotation, t));
|
|
}
|
|
|
|
public static ITween TweenLocalPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalPosition)
|
|
{
|
|
Vector2D initialLocalPosition = transform2D.LocalPosition;
|
|
return tweenManager.StartTween(duration, t => transform2D.LocalPosition = initialLocalPosition.Lerp(targetLocalPosition, t));
|
|
}
|
|
|
|
public static ITween TweenLocalScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalScale)
|
|
{
|
|
Vector2D initialLocalScale = transform2D.LocalScale;
|
|
return tweenManager.StartTween(duration, t => transform2D.LocalScale = initialLocalScale.Lerp(targetLocalScale, t));
|
|
}
|
|
|
|
public static ITween TweenLocalRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetLocalRotation)
|
|
{
|
|
float initialLocalRotation = transform2D.LocalRotation;
|
|
return tweenManager.StartTween(duration, t => transform2D.LocalRotation = initialLocalRotation.Lerp(targetLocalRotation, t));
|
|
}
|
|
}
|