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 |
|
---|
21 | Sub PointF(ByRef pt As PointF)
|
---|
22 | x = pt.x
|
---|
23 | y = pt.y
|
---|
24 | End Sub
|
---|
25 |
|
---|
26 | Sub PointF(ByRef sz As SizeF)
|
---|
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 |
|
---|
47 | Function IsEmpty() As BOOL
|
---|
48 | If x = 0 And y = 0 Then
|
---|
49 | Return _System_TRUE
|
---|
50 | Else
|
---|
51 | Return _System_FALSE
|
---|
52 | End If
|
---|
53 | End Function
|
---|
54 |
|
---|
55 | Sub Operator = (ByRef pt As PointF)
|
---|
56 | x = pt.x
|
---|
57 | y = pt.y
|
---|
58 | End Sub
|
---|
59 |
|
---|
60 | Function Operator + (pt As PointF) As PointF
|
---|
61 | Return Add(pt)
|
---|
62 | End Function
|
---|
63 |
|
---|
64 | Function Operator + (sz As Size) As PointF
|
---|
65 | Return Add(sz)
|
---|
66 | End Function
|
---|
67 |
|
---|
68 | Function Operator + (sz As SizeF) As PointF
|
---|
69 | Return Add(sz)
|
---|
70 | End Function
|
---|
71 |
|
---|
72 | Function Operator - (pt As PointF) As PointF
|
---|
73 | Return Substract(pt)
|
---|
74 | End Function
|
---|
75 |
|
---|
76 | Function Operator - (sz As Size) As PointF
|
---|
77 | Return Substract(sz)
|
---|
78 | End Function
|
---|
79 |
|
---|
80 | Function Operator - (sz As SizeF) As PointF
|
---|
81 | Return Substract(sz)
|
---|
82 | End Function
|
---|
83 |
|
---|
84 | Function Operator == (sz As PointF) As BOOL
|
---|
85 | Return Equals(sz)
|
---|
86 | End Function
|
---|
87 |
|
---|
88 | Function Operator <> (sz As PointF) As BOOL
|
---|
89 | Return Not Equals(sz)
|
---|
90 | End Function
|
---|
91 |
|
---|
92 | Function Add(pt As PointF) As PointF
|
---|
93 | Dim ret As PointF(x + pt.x, y + pt.y)
|
---|
94 | Return ret
|
---|
95 | End Function
|
---|
96 |
|
---|
97 | Function Add(sz As Size) As PointF
|
---|
98 | Dim ret As PointF(x + sz.width, y + sz.height)
|
---|
99 | Return ret
|
---|
100 | End Function
|
---|
101 |
|
---|
102 | Function Add(sz As SizeF) As PointF
|
---|
103 | Dim ret As PointF(x + sz.width, y + sz.height)
|
---|
104 | Return ret
|
---|
105 | End Function
|
---|
106 |
|
---|
107 | Function Substract(pt As PointF) As PointF
|
---|
108 | Dim ret As PointF(x - pt.x, y - pt.y)
|
---|
109 | Return ret
|
---|
110 | End Function
|
---|
111 |
|
---|
112 | Function Substract(sz As Size) As PointF
|
---|
113 | Dim ret As PointF(x - sz.width, y - sz.height)
|
---|
114 | Return ret
|
---|
115 | End Function
|
---|
116 |
|
---|
117 | Function Substract(sz As SizeF) As PointF
|
---|
118 | Dim ret As PointF(x - sz.width, y - sz.height)
|
---|
119 | Return ret
|
---|
120 | End Function
|
---|
121 |
|
---|
122 | Function Equals(pt As PointF) As BOOL
|
---|
123 | If x = pt.x And y = pt.y Then
|
---|
124 | Equals = _System_TRUE
|
---|
125 | Else
|
---|
126 | Equals = _System_FALSE
|
---|
127 | End If
|
---|
128 | End Function
|
---|
129 |
|
---|
130 | Private
|
---|
131 | x As Single
|
---|
132 | y As Single
|
---|
133 | End Class
|
---|
134 |
|
---|
135 | #endif '__SYSTEM_DRAWING_POINTF_AB__
|
---|