"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
Array subclass:#Polygon
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Graphics-Primitives'
!
Polygon comment:'
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.7 1994-08-05 01:07:06 claus Exp $
'!
!Polygon class methodsFor: 'documentation'!
copyright
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
version
"
$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.7 1994-08-05 01:07:06 claus Exp $
"
!
documentation
"
Polygon - an array of points
Adds simple boundary checking methods to Array.
(needs much more - such as inside check, area computation etc.)
"
! !
!Polygon methodsFor: 'accessing'!
top
"return the top boundary of the polygon,
that is the minimum y coordinate of all its points"
|minY|
(self size == 0) ifTrue: [^ nil].
minY := (self at:1) y.
self do:[:p |
(p y < minY) ifTrue:[minY := p y].
0 "stc hint"
].
^ minY
!
bottom
"return the bottom boundary of the polygon,
that is the maximum y coordinate of all its points"
|maxY|
(self size == 0) ifTrue: [^ nil].
maxY := (self at:1) y.
self do:[:p |
(p y > maxY) ifTrue:[maxY := p y].
0 "stc hint"
].
^ maxY
!
left
"return the left boundary of the polygon,
that is the minimum x coordinate of all its points"
|minX|
(self size == 0) ifTrue: [^ nil].
minX := (self at:1) x.
self do:[:p |
(p x < minX) ifTrue:[minX := p x].
0 "stc hint"
].
^ minX
!
right
"return the right boundary of the polygon,
that is the maximum y coordinate of all its points"
|maxX|
(self size == 0) ifTrue: [^ nil].
maxX := (self at:1) x.
self do:[:p |
(p x > maxX) ifTrue:[maxX := p x].
0 "stc hint"
].
^ maxX
! !