using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RichCreator.Utility.Structs { /// /// 点 /// public struct ZTPoint : IEquatable { public static ZTPoint Empty = new ZTPoint(0, 0); public ZTPoint(Int32 x, Int32 y) { this.X = x; this.Y = y; } public Int32 X; public Int32 Y; public static bool operator ==(ZTPoint a, ZTPoint b) { if (a.X == b.X && a.Y == b.Y) { return true; } return false; } public static bool operator !=(ZTPoint a, ZTPoint b) { if (a.X != b.X || a.Y != b.Y) { return true; } return false; } public static ZTPoint operator +(ZTPoint a, ZTPoint b) { return new ZTPoint(a.X + b.X, a.Y + b.Y); } public static ZTPoint operator -(ZTPoint a, ZTPoint b) { return new ZTPoint(a.X - b.X, a.Y - b.Y); } public override string ToString() { return "(" + this.X.ToString() + "," + this.Y.ToString() + ")"; } /// /// x,y坐标加上指定的值 /// /// /// public ZTPoint Add(Int32 val) { return new ZTPoint(this.X + val, this.Y + val); } /// /// 两个坐标相加 /// /// /// public ZTPoint Add(ZTPoint val) { return new ZTPoint(this.X + val.X, this.Y + val.Y); } /// /// 两个坐标相减 /// /// /// public ZTPoint Sub(ZTPoint val) { return new ZTPoint(this.X - val.X, this.Y - val.Y); } #region IEquatable public bool Equals(ZTPoint other) { if (this.X == other.X && this.Y == other.Y) { return true; } return false; } #endregion } }