Circle.st
author Claus Gittinger <cg@exept.de>
Wed, 08 May 1996 21:06:54 +0200
changeset 283 59a8cfbc1e5e
parent 281 344857a33c20
child 284 1b272ff61339
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 1995 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.
"

Geometric subclass:#Circle
	instanceVariableNames:'center radius'
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Geometry'
!

!Circle class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 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.
"
!

documentation
"
     This class implements a circles which are defined by a radius and
     a centerpoint.

    [author:]
        Claus Gittinger

    [see also:]
        EllipticalArc Spline Polygon Rectangle
        GraphicsContext
"
! !

!Circle class methodsFor:'instance creation'!

boundingBox:aRectangle
    "Return a new Circle centered in aRectangle."

    ^ self
        center:(aRectangle center)
        radius:(aRectangle width min:aRectangle height) / 2
!

center:centerPoint radius:radius
    "Return a new Circle."

    ^ self new center:centerPoint radius:radius

    "Modified: 8.5.1996 / 20:39:30 / cg"
! !

!Circle methodsFor:'accessing'!

center 
    "return the center."

    ^ center
!

center:aPoint 
    "set the center point."

    center := aPoint
!

center:centerPoint radius:radiusNumber
    "set the center and radius"

    center := centerPoint.
    radius := radiusNumber
!

radius 
    "return the radius."

    ^ radius
!

radius:aNumber 
    "set the radius."

    radius := aNumber
! !

!Circle methodsFor:'converting'!

asEllipticalArc
    "convert the receiver into an ellipticalArc"

    ^ EllipticalArc center:center radius:radius 
! !

!Circle methodsFor:'displaying'!

displayFilledOn:aGC
    "draw the receiver as a filled circle in a graphicsContext, aGC"

    aGC fillCircle:center radius:radius
!

displayStrokedOn:aGC
    "draw the receiver as a unfilled circle in a graphicsContext, aGC"

    aGC displayCircle:center radius:radius

! !

!Circle methodsFor:'queries'!

area
    "return the area of the receiver."

    ^ radius * radius * (Float pi)
!

bounds
    "return the smallest enclosing rectangle"

    ^ Rectangle origin:(center - radius) corner:(center + radius)

    "
     (Circle center:100@100 radius:50) bounds 
    "
!

canBeFilled
    "return true, if the receiver can be drawn filled; always true here"

    ^ true
!

diameter
    "return the diameter of the receiver."

    ^ radius * 2
!

startAngle
    "return the startAngle.
     Provided for protocol compatibility with arcs and ellipese;
     for circles, this is an arbitrary angle."

    ^ 0
!

sweepAngle
    "return the sweepAngle.
     Provided for protocol compatibility with arcs and ellipese;
     for circles, this is always 360 degrees."

    ^ 360
! !

!Circle class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic2/Circle.st,v 1.8 1996-05-08 19:06:41 cg Exp $'
! !