Animations/ScaleAnimation.cs
/// <summary>
/// Animates a component by scaling it between a minimum and maximum scale value.
/// </summary>
using System;
namespace BetterUI.Animations;
public class ScaleAnimation : AnimationBase
{
/// <summary>
/// Gets or sets the minimum scale factor.
/// </summary>
[Property]
public float MinScale { get; set; } = 0.8f;
/// <summary>
/// Gets or sets the maximum scale factor.
/// </summary>
[Property]
public float MaxScale { get; set; } = 1.2f;
protected override void OnAnimate( float t )
{
var easedTime = ApplyEasing( NormalizedTime, Easing );
var scale = MinScale + (MaxScale - MinScale) * (0.5f + 0.5f * MathF.Sin( easedTime * MathF.PI * 2 ));
WorldScale = new Vector3(
Axis.x > 0 ? scale : 1f,
Axis.y > 0 ? scale : 1f,
Axis.z > 0 ? scale : 1f
);
}
}