|
Class: Circle
Object
|
+--Geometric
|
+--Circle
- Package:
- stx:libbasic2
- Category:
- Graphics-Geometry-Objects
- Version:
- rev:
1.23
date: 2022/02/17 10:25:36
- user: cg
- file: Circle.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
This class implements a circles which are defined by a radius and
a centerpoint.
copyrightCOPYRIGHT (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.
instance creation
-
boundingBox: aRectangle
-
Return a new Circle centered in aRectangle.
-
center: centerPoint radius: radius
-
Return a new Circle.
accessing
-
center
-
return the center.
-
center: aPoint
-
set the center point.
-
center: centerPoint radius: radiusNumber
-
set the center and radius
-
radius
-
return the radius.
-
radius: aNumber
-
set the radius.
converting
-
asEllipticalArc
-
convert the receiver into an ellipticalArc
displaying
-
displayFilledOn: aGC
-
draw the receiver as a filled circle in a graphicsContext, aGC
-
displayStrokedOn: aGC
-
draw the receiver as a unfilled circle in a graphicsContext, aGC
queries
-
area
-
return the area of the receiver.
-
computeBounds
-
return the smallest enclosing rectangle
-
diameter
-
return the diameter of the receiver.
-
startAngle
-
return the startAngle.
Provided for protocol compatibility with arcs and ellipese;
for circles, this is an arbitrary angle.
-
sweepAngle
-
return the sweepAngle.
Provided for protocol compatibility with arcs and ellipese;
for circles, this is always 360 degrees.
testing
-
canBeFilled
-
return true, if the receiver can be drawn filled; always true here
transformations
-
rotatedBy: angle about: centerPoint
-
return a copy of the receiver, which is rotated around rotationCenter
by an angle (radians) around rotationCenter (which may be located outside);
the angle is interpreted as counter-clockwise (same as in Point >> rotatedBy:)
-
roundedToNearestIntegerPoint
-
return a copy of the receiver, where all points are rounded to ly on the nearest integer coordinate
-
scaledBy: amount
-
return a new circle which is scaled (i.e. moved)
by amount, aPoint or Number
Usage example(s):
(Circle center:10@10 radius:50) scaledBy:2
|
-
translatedBy: amount
-
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number
Usage example(s):
(Circle center:10@10 radius:50) translatedBy:10
(Circle center:10@10 radius:50) translatedBy:(10@20)
|
circle; filled and unfilled:
|v c|
v := (View extent:200@100) openAndWaitUntilVisible.
c := Circle boundingBox:(10@10 corner:90@90).
v paint:Color blue.
c displayFilledOn:v.
c center:150@50.
v paint:Color red.
c displayStrokedOn:v.
| circle & rectangle; both filled:
|v c|
v := (View extent:100@100) openAndWaitUntilVisible.
c := Circle center:50@50 radius:40.
v paint:Color red.
c asRectangle displayFilledOn:v.
v paint:Color blue.
c displayFilledOn:v.
| circles; filled & unfilled:
|v c|
v := View new openAndWaitUntilVisible.
c := Circle center:50@50 radius:40.
v paint:Color red.
c displayFilledOn:v.
50 to:1 by:-1 do:[:r |
c radius:r.
v paint:(Color grey:(r * 2)).
c displayStrokedOn:v.
].
1 to:50 do:[:r |
c radius:r.
v paint:(Color grey:100-(r * 2)).
c displayStrokedOn:v.
]
| more arcs; filled:
|v ell|
v := View new openAndWaitUntilVisible.
ell := EllipticalArc
boundingBox:(10@10 corner:90@90)
startAngle:0
sweepAngle:0.
#(45 90 135 180 225 270 315 360)
keysAndValuesReverseDo:[:index :angle |
index odd ifTrue:[
v paint:Color white
] ifFalse:[
v paint:Color black
].
ell sweepAngle:angle.
ell displayFilledOn:v.
Delay waitForSeconds:0.1.
].
| more arcs; filled:
|v ell|
v := View new openAndWaitUntilVisible.
ell := EllipticalArc
boundingBox:(10@10 corner:90@90)
startAngle:0
sweepAngle:45.
#(45 90 135 180 225 270 315 360)
with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1)
do:[:angle :grey |
ell startAngle:angle-45.
v paint:(ColorValue red:grey green:0 blue:0).
ell displayFilledOn:v.
].
|
|