' Classes/System/Drawing/SizeF.ab

Namespace System
Namespace Drawing

Class SizeF
Public
	Sub SizeF()
		width = 0
		height = 0
	End Sub

	Sub SizeF(initWidth As Single, initHeight As Single)
		width = initWidth
		height = initHeight
	End Sub

	Sub SizeF(sz As SizeF)
		width = sz.width
		height = sz.height
	End Sub

	Function Width() As Single
		Return width
	End Function

	Sub Width(w As Single)
		width = w
	End Sub

	Function Height() As Single
		Return height
	End Function

	Sub Height(h As Single)
		height = h
	End Sub

	Function Operator +(sz As SizeF) As SizeF
		Return New SizeF(width + sz.width, height + sz.height)
	End Function

	Function Operator -(sz As SizeF) As SizeF
		Return New SizeF(width - sz.width, height - sz.height)
	End Function

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

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

	Function Equals(sz As SizeF) As Boolean
		Return width = sz.width And height = sz.height
	End Function

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

	Function IsEmpty() As Boolean
		Return width = 0 And height = 0
	End Function

	Function Add(sz As SizeF) As SizeF
		Return This + sz
	End Function

	Function Subtract(sz As SizeF) As SizeF
		Return This - sz
	End Function

	Function ToSize() As Size
		Return Size.Round(This)
	End Function

	Function ToPointF() As PointF
		Return New PointF(width, height)
	End Function
Private
	width As Single
	height As Single
End Class

End Namespace
End Namespace
