using System.Numerics;

namespace Voile.Extensions
{
    public static class Vector2Extensions
    {
        public static Vector2 Lerp(this Vector2 a, Vector2 b, double t)
        {
            return new Vector2((float)MathUtils.Lerp(a.X, b.X, t), (float)MathUtils.Lerp(a.Y, b.Y, t));
        }

        public static Vector2 Snapped(this Vector2 a, Vector2 snap)
        {
            var x = a.X % snap.X;
            var y = a.Y % snap.Y;

            if (x == 0)
            {
                x = a.X;
            }
            else
            {
                x = a.X - x;
            }

            if (y == 0)
            {
                y = a.Y;
            }
            else
            {
                y = a.Y - y;
            }

            return new Vector2(x, y);
        }
    }
}