namespace HellionChat.Util;

// Framerate-independent smoothing for per-frame hover and motion
// values. Pattern anchor: Umbra Toolbar.Autohide.cs:55
// (`v += (target - v) * deltaTime`). The Math.Min(1f, speed*dt)
// clamp is a deliberate HellionChat addition -- on Wine/DXVK a
// stalled frame can push deltaTime well over 16ms, which would
// otherwise let the raw factor exceed 1.0 and overshoot the target.
// Clamping makes a stalled frame land exactly on target instead.
internal static class FrameLerp
{
    public static float Smooth(float current, float target, float speed, float deltaTime)
    {
        var factor = Math.Min(1f, speed * deltaTime);
        return current + (target - current) * factor;
    }
}
