using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RichCreator.Utility.Structs { /// /// 点 /// public class ZTPoint { public static ZTPoint Empty = new ZTPoint(0,0); public ZTPoint() { } public ZTPoint(Int32 x, Int32 y) { this.X = x; this.Y = y; } public Int32 X { get; set; } public Int32 Y { get; set; } 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 (other == null) { return false; } if (this.X == other.X && this.Y == other.Y) { return true; } return false; } #endregion } }