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