Changeset 698 for trunk/ab5.0/ablib/src/Classes/System/Drawing/Point.ab
- Timestamp:
- Mar 31, 2009, 2:09:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/Drawing/Point.ab
r550 r698 4 4 Namespace Drawing 5 5 6 Class Point 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 18 Sub Point(sz As Size) 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 29 X = x 30 End Function 31 32 Sub X(newX As Long) 33 x = newX 34 End Sub 35 36 Function Y() As Long 37 Y = y 38 End Function 39 40 Sub Y(newY As Long) 41 y = newY 42 End Sub 43 44 Function IsEmpty() As Boolean 45 Return x = 0 And y = 0 46 End Function 47 48 Function Operator +(pt As Point) As Point 49 Return Add(This, pt) 50 End Function 51 52 Function Operator +(sz As Size) As Point 53 Return Add(This, sz) 54 End Function 55 56 Function Operator -(pt As Point) As Point 57 Return Substract(This, pt) 58 End Function 59 60 Function Operator -(sz As Size) As Point 61 Return Substract(This, sz) 62 End Function 63 64 Function Operator ==(sz As Point) As Boolean 65 Return Equals(sz) 66 End Function 67 68 Function Operator <>(sz As Point) As Boolean 69 Return Not Equals(sz) 70 End Function 71 72 Static Function Add(pt1 As Point, pt2 As Point) As Point 73 Return New Point(pt1.x + pt2.x, pt1.y + pt2.y) 74 End Function 75 76 Static Function Add(pt As Point, sz As Size) As Point 77 Return New Point(pt.x + sz.Width, pt.y + sz.Height) 78 End Function 79 80 Function Offset(pt As Point) As Point 81 Return New Point(x + pt.x, y + pt.y) 82 End Function 83 84 Sub Offset(dx As Long, dy As Long) 85 x += dx 86 y += dy 87 End Sub 88 89 Static Function Substract(pt1 As Point, pt2 As Point) As Point 90 Return New Point(pt1.x - pt2.x, pt1.y - pt2.y) 91 End Function 92 93 Static Function Substract(pt As Point, sz As Size) As Point 94 Return New Point(pt.x - sz.Width, pt.y - sz.Height) 95 End Function 96 97 Function Equals(pt As Point) As Boolean 98 Return x = pt.x And y = pt.y 99 End Function 100 101 Override Function GetHashCode() As Long 102 Return x Xor _System_BSwap(y As DWord) 103 End Function 104 105 Static Function Ceiling(ptf As PointF) As Point 106 Return New Point(Math.Ceiling(ptf.X) As Long, Math.Ceiling(ptf.Y) As Long) 107 End Function 108 109 Static Function Round(ptf As PointF) As Point 110 Return New Point(Math.Round(ptf.X) As Long, Math.Round(ptf.Y) As Long) 111 End Function 112 113 Static Function Truncate(ptf As PointF) As Point 114 Return New Point(Math.Truncate(ptf.X) As Long, Math.Truncate(ptf.Y) As Long) 115 End Function 116 117 Function Operator () As PointF 118 Return New PointF(X, Y) 119 End Function 120 121 Private 122 x As Long 123 y As Long 124 End Class 6 Type Point 7 X As Long 8 Y As Long 9 End Type 125 10 126 11 End Namespace
Note:
See TracChangeset
for help on using the changeset viewer.