mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-11-18 16:59:09 +08:00
初始化
This commit is contained in:
65
CPF.Mac/Mac/CoreGraphics/CGPoint.cs
Normal file
65
CPF.Mac/Mac/CoreGraphics/CGPoint.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user