' Classes/System/Drawing/PointF.ab

#ifndef __SYSTEM_DRAWING_POINTF_AB__
#define __SYSTEM_DRAWING_POINTF_AB__

#include <Classes/System/Drawing/Size.ab>
#include <Classes/System/Drawing/SizeF.ab>

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
		Return x
	End Function

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

	Function Y() As Single
		Return 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
		Dim ret As PointF(pt1.x + pt2.x, pt1.y + pt2.y)
		Return ret
	End Function

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

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

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

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

	Static Function Substract(pt As PointF, sz As SizeF) As PointF
		Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
		Return ret
	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

#endif '__SYSTEM_DRAWING_POINTF_AB__
