source: Include/Classes/System/Drawing/PointF.ab@ 106

Last change on this file since 106 was 104, checked in by イグトランス (egtra), 18 years ago

Boolean対応ほか微修正

File size: 2.8 KB
Line 
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
9Class PointF
10Public
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 Boolean
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 () As PointF
61 Dim ptf As PointF(X, Y)
62 Return ptf
63 End Function
64
65 Function Operator + (pt As PointF) As PointF
66 Return Add(This, pt)
67 End Function
68
69 Function Operator + (sz As Size) As PointF
70 Return Add(This, sz)
71 End Function
72
73 Function Operator + (sz As SizeF) As PointF
74 Return Add(This, sz)
75 End Function
76
77 Function Operator - (pt As PointF) As PointF
78 Return Substract(This, pt)
79 End Function
80
81 Function Operator - (sz As Size) As PointF
82 Return Substract(This, sz)
83 End Function
84
85 Function Operator - (sz As SizeF) As PointF
86 Return Substract(This, sz)
87 End Function
88
89 Function Operator == (sz As PointF) As Boolean
90 Return Equals(sz)
91 End Function
92
93 Function Operator <> (sz As PointF) As Boolean
94 Return Not Equals(sz)
95 End Function
96
97 Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
98 Dim ret As PointF(pt1.x + pt2.x, pt1.y + pt2.y)
99 Return ret
100 End Function
101
102 Static Function Add(pt As PointF, sz As Size) As PointF
103 Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
104 Return ret
105 End Function
106
107 Static Function Add(pt As PointF, sz As SizeF) As PointF
108 Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
109 Return ret
110 End Function
111
112 Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
113 Dim ret As PointF(pt1.x - pt2.x, pt1.y - pt2.y)
114 Return ret
115 End Function
116
117 Static Function Substract(pt As PointF, sz As Size) As PointF
118 Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
119 Return ret
120 End Function
121
122 Static Function Substract(pt As PointF, sz As SizeF) As PointF
123 Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
124 Return ret
125 End Function
126
127 Function Equals(pt As PointF) As Boolean
128 If x = pt.x And y = pt.y Then
129 Equals = _System_TRUE
130 Else
131 Equals = _System_FALSE
132 End If
133 End Function
134
135Private
136 x As Single
137 y As Single
138End Class
139
140#endif '__SYSTEM_DRAWING_POINTF_AB__
Note: See TracBrowser for help on using the repository browser.