' Classes/System/Drawing/Point.ab #ifndef __SYSTEM_DRAWING_POINT_AB__ #define __SYSTEM_DRAWING_POINT_AB__ #require #require #require Namespace System Namespace Drawing Class Point Public Sub Point() x = 0 y = 0 End Sub Sub Point(initX As Long, initY As Long) x = initX y = initY End Sub Sub Point(sz As Size) x = sz.Width y = sz.Height End Sub Sub Point(dw As DWord) x = LOWORD(dw) y = HIWORD(dw) End Sub Function X() As Long Return x End Function Sub X(newX As Long) x = newX End Sub Function Y() As Long Return y End Function Sub Y(newY As Long) y = newY End Sub Function IsEmpty() As Boolean Return x = 0 And y = 0 End Function Function Operator + (pt As Point) As Point Return Add(This, pt) End Function Function Operator + (sz As Size) As Point Return Add(This, sz) End Function Function Operator - (pt As Point) As Point Return Substract(This, pt) End Function Function Operator - (sz As Size) As Point Return Substract(This, sz) End Function Function Operator == (sz As Point) As Boolean Return Equals(sz) End Function Function Operator <> (sz As Point) As Boolean Return Not Equals(sz) End Function Static Function Add(pt1 As Point, pt2 As Point) As Point Dim ret As Point(pt1.x + pt2.x, pt1.y + pt2.y) Return ret End Function Static Function Add(pt As Point, sz As Size) As Point Dim ret As Point(pt.x + sz.Width, pt.y + sz.Height) Return ret End Function Function Offset(pt As Point) As Point Dim ret As Point(x + pt.x, y + pt.y) Return ret End Function Sub Offset(dx As Long, dy As Long) x += dx y += dy End Sub Static Function Substract(pt1 As Point, pt2 As Point) As Point Dim ret As Point(pt1.x - pt2.x, pt1.y - pt2.y) Return ret End Function Static Function Substract(pt As Point, sz As Size) As Point Dim ret As Point(pt.x - sz.Width, pt.y - sz.Height) Return ret End Function Function Equals(pt As Point) As Boolean Return x = pt.x And y = pt.y End Function Override Function GetHashCode() As Long Return x Xor _System_BSwap(y As DWord) End Function Static Function Ceiling(ptf As PointF) As Point Dim pt As Size(Math.Ceiling(ptf.width), Math.Ceiling(ptf.height)) Return pt End Function Static Function Round(ptf As PointF) As Point Dim pt As Point(Math.Round(ptf.width), Math.Round(ptf.height)) Return pt End Function Static Function Truncate(ptf As PointF) As Point Dim pt As Point(Math.Truncate(ptf.width), Math.Truncate(ptf.height)) Return pt End Function Function Operator () As PointF Return Return PointF(X, Y) End Function Private x As Long y As Long End Class End Namespace 'Drawing End Namespace 'System #endif '__SYSTEM_DRAWING_POINT_AB__