using Microsoft.Xna.Framework;

namespace Igdc.Extensions
{
    public static class PointExt
    {
        public static Point ApplyCamera(this Point point, Point camera)
            => new Point(point.X - camera.X, point.Y - camera.Y);

        public static Point Interpolate(this Point from, Point to, bool canSkip = true)
        {
            var vectorFrom = from.ToVector2();
            var vectorTo = to.ToVector2();
            if (canSkip && vectorFrom == Vector2.Zero)
            {
                vectorFrom = vectorTo;
                return vectorTo.ToPoint();
            }
            if (Vector2.Distance(vectorTo, vectorFrom) > 2)
                vectorTo = (vectorTo + vectorFrom) / 2;
            vectorFrom = vectorTo;
            return vectorTo.ToPoint();
        }
    }
}