feat: tail interpolates like head (mirrored with ease-in)

Tail now uses the same approach as head: interpolated in the body path
from its previous position, with ease-in (mirror of head's ease-out).
Ghost circle removed — no longer needed since tail is naturally smooth.
Added EaseInCubic to AnimationHelper. InterpolatePosition now uses
string easing mode instead of bool.
This commit is contained in:
Heller
2026-06-19 10:25:31 +00:00
parent 36bfe5ad45
commit c1b9543c47
2 changed files with 32 additions and 35 deletions

View File

@@ -26,7 +26,16 @@ public static class AnimationHelper
}
/// <summary>
/// Interpolates between two positions with given t value.
/// Ease-in cubic — mirror of EaseOutCubic, for tail interpolation.
/// </summary>
public static double EaseInCubic(double t)
{
t = Math.Clamp(t, 0.0, 1.0);
return t * t * t;
}
/// <summary>
/// Interpolates between two positions with given t value and easing mode.
/// Returns the visual position for rendering.
/// </summary>
public static (double X, double Y) InterpolatePosition(
@@ -34,9 +43,14 @@ public static class AnimationHelper
Position to,
double t,
double cellSize,
bool useEasing = false)
string easing = "linear")
{
var eased = useEasing ? EaseOutCubic(t) : t;
var eased = easing switch
{
"easeOut" => EaseOutCubic(t),
"easeIn" => EaseInCubic(t),
_ => t
};
var x = from.X + (to.X - from.X) * eased;
var y = from.Y + (to.Y - from.Y) * eased;
return (x * cellSize + cellSize * 0.5, y * cellSize + cellSize * 0.5);