0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
68
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Array subclass:#Polygon
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
68
|
17 |
category:'Graphics-Geometry'
|
0
|
18 |
!
|
|
19 |
|
|
20 |
Polygon comment:'
|
31
|
21 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
68
|
22 |
All Rights Reserved
|
36
|
23 |
|
68
|
24 |
$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.8 1995-03-18 05:08:10 claus Exp $
|
31
|
25 |
'!
|
|
26 |
|
|
27 |
!Polygon class methodsFor: 'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
68
|
32 |
All Rights Reserved
|
0
|
33 |
|
31
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
68
|
45 |
$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.8 1995-03-18 05:08:10 claus Exp $
|
31
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
Polygon - an array of points
|
|
52 |
Adds simple boundary checking methods to Array.
|
|
53 |
(needs much more - such as inside check, area computation etc.)
|
|
54 |
"
|
|
55 |
! !
|
0
|
56 |
|
|
57 |
!Polygon methodsFor: 'accessing'!
|
|
58 |
|
|
59 |
top
|
14
|
60 |
"return the top boundary of the polygon,
|
|
61 |
that is the minimum y coordinate of all its points"
|
|
62 |
|
0
|
63 |
|minY|
|
|
64 |
|
|
65 |
(self size == 0) ifTrue: [^ nil].
|
|
66 |
minY := (self at:1) y.
|
|
67 |
self do:[:p |
|
68
|
68 |
(p y < minY) ifTrue:[minY := p y].
|
|
69 |
0 "stc hint"
|
0
|
70 |
].
|
|
71 |
^ minY
|
|
72 |
!
|
|
73 |
|
|
74 |
bottom
|
14
|
75 |
"return the bottom boundary of the polygon,
|
|
76 |
that is the maximum y coordinate of all its points"
|
|
77 |
|
0
|
78 |
|maxY|
|
|
79 |
|
|
80 |
(self size == 0) ifTrue: [^ nil].
|
|
81 |
maxY := (self at:1) y.
|
|
82 |
self do:[:p |
|
68
|
83 |
(p y > maxY) ifTrue:[maxY := p y].
|
|
84 |
0 "stc hint"
|
0
|
85 |
].
|
|
86 |
^ maxY
|
|
87 |
!
|
|
88 |
|
|
89 |
left
|
14
|
90 |
"return the left boundary of the polygon,
|
|
91 |
that is the minimum x coordinate of all its points"
|
|
92 |
|
0
|
93 |
|minX|
|
|
94 |
|
|
95 |
(self size == 0) ifTrue: [^ nil].
|
|
96 |
minX := (self at:1) x.
|
|
97 |
self do:[:p |
|
68
|
98 |
(p x < minX) ifTrue:[minX := p x].
|
|
99 |
0 "stc hint"
|
0
|
100 |
].
|
|
101 |
^ minX
|
|
102 |
!
|
|
103 |
|
|
104 |
right
|
14
|
105 |
"return the right boundary of the polygon,
|
|
106 |
that is the maximum y coordinate of all its points"
|
|
107 |
|
0
|
108 |
|maxX|
|
|
109 |
|
|
110 |
(self size == 0) ifTrue: [^ nil].
|
|
111 |
maxX := (self at:1) x.
|
|
112 |
self do:[:p |
|
68
|
113 |
(p x > maxX) ifTrue:[maxX := p x].
|
|
114 |
0 "stc hint"
|
0
|
115 |
].
|
|
116 |
^ maxX
|
|
117 |
! !
|