mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-04-05 17:37:51 +08:00
66 lines
1.1 KiB
C#
66 lines
1.1 KiB
C#
using System.Globalization;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace CPF.Mac.CoreGraphics
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
|
public struct CGPoint
|
|
{
|
|
public static readonly CGPoint Empty;
|
|
|
|
public double X;
|
|
|
|
public double Y;
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return X.GetHashCode() ^ Y.GetHashCode();
|
|
}
|
|
|
|
public static bool operator ==(CGPoint left, CGPoint right)
|
|
{
|
|
if (left.X == right.X)
|
|
{
|
|
return left.Y == right.Y;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static bool operator !=(CGPoint left, CGPoint right)
|
|
{
|
|
if (left.X == right.X)
|
|
{
|
|
return left.Y != right.Y;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static CGPoint operator +(CGPoint pt, CGSize sz)
|
|
{
|
|
return new CGPoint(pt.X + sz.Width, pt.Y + sz.Height);
|
|
}
|
|
|
|
public static CGPoint operator -(CGPoint pt, CGSize sz)
|
|
{
|
|
return new CGPoint(pt.X - sz.Width, pt.Y - sz.Height);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format(CultureInfo.CurrentCulture, "{{X={0},Y={1}}}", X, Y);
|
|
}
|
|
|
|
public CGPoint(int x, int y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
|
|
public CGPoint(double x, double y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
}
|
|
}
|