' Classes/System/Drawing/PointF.ab

Namespace System
Namespace Drawing

Class PointF
Public
	Sub PointF()
		x = 0
		y = 0
	End Sub

	Sub PointF(initX As Single, initY As Single)
		x = initX
		y = initY
	End Sub

	Sub PointF(pt As PointF)
		x = pt.x
		y = pt.y
	End Sub

	Sub PointF(sz As SizeF)
		x = sz.Width
		y = sz.Height
	End Sub

	Function X() As Single
		X = x
	End Function

	Sub X(newX As Single)
		x = newX
	End Sub

	Function Y() As Single
		Y = y
	End Function

	Sub Y(newY As Single)
		y = newY
	End Sub

	Function IsEmpty() As Boolean
		Return x = 0 And y = 0
	End Function

	Function Operator + (pt As PointF) As PointF
		Return Add(This, pt)
	End Function

	Function Operator + (sz As Size) As PointF
		Return Add(This, sz)
	End Function

	Function Operator + (sz As SizeF) As PointF
		Return Add(This, sz)
	End Function

	Function Operator - (pt As PointF) As PointF
		Return Substract(This, pt)
	End Function

	Function Operator - (sz As Size) As PointF
		Return Substract(This, sz)
	End Function

	Function Operator - (sz As SizeF) As PointF
		Return Substract(This, sz)
	End Function

	Function Operator == (sz As PointF) As Boolean
		Return Equals(sz)
	End Function

	Function Operator <> (sz As PointF) As Boolean
		Return Not Equals(sz)
	End Function

	Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
		Return New PointF(pt1.x + pt2.x, pt1.y + pt2.y)
	End Function

	Static Function Add(pt As PointF, sz As Size) As PointF
		Return New PointF(pt.x + sz.Width, pt.y + sz.Height)
	End Function

	Static Function Add(pt As PointF, sz As SizeF) As PointF
		Return New PointF(pt.x + sz.Width, pt.y + sz.Height)
	End Function

	Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
		Return New PointF(pt1.x - pt2.x, pt1.y - pt2.y)
	End Function

	Static Function Substract(pt As PointF, sz As Size) As PointF
		Return New PointF(pt.x - sz.Width, pt.y - sz.Height)
	End Function

	Static Function Substract(pt As PointF, sz As SizeF) As PointF
		Return New PointF(pt.x - sz.Width, pt.y - sz.Height)
	End Function

	Function Equals(pt As PointF) As Boolean
		Return x = pt.x And y = pt.y
	End Function

	Override Function GetHashCode() As Long
		Return (GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))) As Long
	End Function

Private
	x As Single
	y As Single
End Class

End Namespace
End Namespace
