using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace RichCreator.Utility.Structs
|
{
|
/// <summary>
|
/// 多边形
|
/// </summary>
|
public struct ZTPolygon :IEquatable<ZTPolygon>
|
{
|
public static ZTPolygon Empty = default(ZTPolygon);
|
|
public ZTPolygon(ZTPoint[] points)
|
{
|
this.Points = points;
|
}
|
|
public ZTPoint[] Points
|
{
|
get;set;
|
}
|
|
public int Length
|
{
|
get { return Points==null?0:Points.Length; }
|
}
|
|
public ZTPoint this[int index]
|
{
|
get { return Points[index]; }
|
set { Points[index] = value; }
|
}
|
|
public bool Equals(ZTPolygon other)
|
{
|
|
if (this.Length != other.Length)
|
{
|
return false;
|
}
|
for (int i = 0; i < this.Length; i++)
|
{
|
if (!this[i].Equals(other[i]))
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
|
public static implicit operator ZTPoint[] (ZTPolygon polygon)
|
{
|
return polygon.Points;
|
}
|
|
public static implicit operator ZTPolygon(ZTPoint[] points)
|
{
|
return new ZTPolygon(points);
|
}
|
|
|
}
|
}
|