[1] | 1 | ' Classes/System/Drawing/PointF.ab
|
---|
| 2 |
|
---|
| 3 | #ifndef __SYSTEM_DRAWING_POINTF_AB__
|
---|
| 4 | #define __SYSTEM_DRAWING_POINTF_AB__
|
---|
| 5 |
|
---|
| 6 | #include <Classes/System/Drawing/Size.ab>
|
---|
| 7 | #include <Classes/System/Drawing/SizeF.ab>
|
---|
| 8 |
|
---|
| 9 | Class PointF
|
---|
| 10 | Public
|
---|
| 11 | Sub PointF()
|
---|
| 12 | x = 0
|
---|
| 13 | y = 0
|
---|
| 14 | End Sub
|
---|
| 15 |
|
---|
| 16 | Sub PointF(initX As Single, initY As Single)
|
---|
| 17 | x = initX
|
---|
| 18 | y = initY
|
---|
| 19 | End Sub
|
---|
| 20 |
|
---|
[212] | 21 | Sub PointF(pt As PointF)
|
---|
[1] | 22 | x = pt.x
|
---|
| 23 | y = pt.y
|
---|
| 24 | End Sub
|
---|
| 25 |
|
---|
[212] | 26 | Sub PointF(sz As SizeF)
|
---|
[1] | 27 | x = sz.Width
|
---|
| 28 | y = sz.Height
|
---|
| 29 | End Sub
|
---|
| 30 |
|
---|
| 31 | Function X() As Single
|
---|
| 32 | Return x
|
---|
| 33 | End Function
|
---|
| 34 |
|
---|
| 35 | Sub X(newX As Single)
|
---|
| 36 | x = newX
|
---|
| 37 | End Sub
|
---|
| 38 |
|
---|
| 39 | Function Y() As Single
|
---|
| 40 | Return y
|
---|
| 41 | End Function
|
---|
| 42 |
|
---|
| 43 | Sub Y(newY As Single)
|
---|
| 44 | y = newY
|
---|
| 45 | End Sub
|
---|
| 46 |
|
---|
[104] | 47 | Function IsEmpty() As Boolean
|
---|
[212] | 48 | Return x = 0 And y = 0
|
---|
[1] | 49 | End Function
|
---|
[303] | 50 |
|
---|
[1] | 51 | Function Operator + (pt As PointF) As PointF
|
---|
[27] | 52 | Return Add(This, pt)
|
---|
[1] | 53 | End Function
|
---|
| 54 |
|
---|
| 55 | Function Operator + (sz As Size) As PointF
|
---|
[27] | 56 | Return Add(This, sz)
|
---|
[1] | 57 | End Function
|
---|
| 58 |
|
---|
| 59 | Function Operator + (sz As SizeF) As PointF
|
---|
[27] | 60 | Return Add(This, sz)
|
---|
[1] | 61 | End Function
|
---|
| 62 |
|
---|
| 63 | Function Operator - (pt As PointF) As PointF
|
---|
[27] | 64 | Return Substract(This, pt)
|
---|
[1] | 65 | End Function
|
---|
| 66 |
|
---|
| 67 | Function Operator - (sz As Size) As PointF
|
---|
[27] | 68 | Return Substract(This, sz)
|
---|
[1] | 69 | End Function
|
---|
| 70 |
|
---|
| 71 | Function Operator - (sz As SizeF) As PointF
|
---|
[27] | 72 | Return Substract(This, sz)
|
---|
[1] | 73 | End Function
|
---|
| 74 |
|
---|
[104] | 75 | Function Operator == (sz As PointF) As Boolean
|
---|
[1] | 76 | Return Equals(sz)
|
---|
| 77 | End Function
|
---|
| 78 |
|
---|
[104] | 79 | Function Operator <> (sz As PointF) As Boolean
|
---|
[1] | 80 | Return Not Equals(sz)
|
---|
| 81 | End Function
|
---|
| 82 |
|
---|
[27] | 83 | Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
|
---|
| 84 | Dim ret As PointF(pt1.x + pt2.x, pt1.y + pt2.y)
|
---|
[1] | 85 | Return ret
|
---|
| 86 | End Function
|
---|
| 87 |
|
---|
[27] | 88 | Static Function Add(pt As PointF, sz As Size) As PointF
|
---|
| 89 | Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
|
---|
[1] | 90 | Return ret
|
---|
| 91 | End Function
|
---|
| 92 |
|
---|
[27] | 93 | Static Function Add(pt As PointF, sz As SizeF) As PointF
|
---|
| 94 | Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
|
---|
[1] | 95 | Return ret
|
---|
| 96 | End Function
|
---|
| 97 |
|
---|
[77] | 98 | Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
|
---|
[27] | 99 | Dim ret As PointF(pt1.x - pt2.x, pt1.y - pt2.y)
|
---|
[1] | 100 | Return ret
|
---|
| 101 | End Function
|
---|
| 102 |
|
---|
[27] | 103 | Static Function Substract(pt As PointF, sz As Size) As PointF
|
---|
| 104 | Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
|
---|
[1] | 105 | Return ret
|
---|
| 106 | End Function
|
---|
| 107 |
|
---|
[27] | 108 | Static Function Substract(pt As PointF, sz As SizeF) As PointF
|
---|
| 109 | Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
|
---|
[1] | 110 | Return ret
|
---|
| 111 | End Function
|
---|
| 112 |
|
---|
[104] | 113 | Function Equals(pt As PointF) As Boolean
|
---|
[212] | 114 | Return x = pt.x And y = pt.y
|
---|
[1] | 115 | End Function
|
---|
| 116 |
|
---|
[166] | 117 | Override Function GetHashCode() As Long
|
---|
[212] | 118 | Return (GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))) As Long
|
---|
[166] | 119 | End Function
|
---|
| 120 |
|
---|
[1] | 121 | Private
|
---|
| 122 | x As Single
|
---|
| 123 | y As Single
|
---|
| 124 | End Class
|
---|
| 125 |
|
---|
| 126 | #endif '__SYSTEM_DRAWING_POINTF_AB__
|
---|