using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace RichCreator.Utility.Structs
|
{
|
/// <summary>
|
/// 点
|
/// </summary>
|
public class ZTPoint : IEquatable<ZTPoint>
|
{
|
public static ZTPoint Empty = default(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 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() + ")";
|
}
|
|
/// <summary>
|
/// x,y坐标加上指定的值
|
/// </summary>
|
/// <param name="val"></param>
|
/// <returns></returns>
|
public ZTPoint Add(Int32 val)
|
{
|
return new ZTPoint(this.X + val, this.Y + val);
|
}
|
|
/// <summary>
|
/// 两个坐标相加
|
/// </summary>
|
/// <param name="val"></param>
|
/// <returns></returns>
|
public ZTPoint Add(ZTPoint val)
|
{
|
return new ZTPoint(this.X + val.X, this.Y + val.Y);
|
}
|
|
/// <summary>
|
/// 两个坐标相减
|
/// </summary>
|
/// <param name="val"></param>
|
/// <returns></returns>
|
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
|
}
|
}
|