Documentation
www.exept.de
Everywhere
for:

# Class: Circle

## Inheritance:

```   Object
|
+--Geometric
|
+--Circle
```

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.13 date: 2009/06/06 10:12:18
user: cg
file: Circle.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

## Description:

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

```

## Related information:

```    EllipticalArc
Spline
Curve
Polygon
Rectangle
LineSegment
Arrow
ArrowedSpline
GraphicsContext
StrokingWrapper
FillingWrapper
```

## Class protocol:

instance creation
boundingBox: aRectangle
Return a new Circle centered in aRectangle.

Return a new Circle.

## Instance protocol:

accessing
center
return the center.

center: aPoint
set the center point.

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.

bounds
return the smallest enclosing rectangle

usage example(s):

 `````` (Circle center:100@100 radius:50) bounds ``````

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

## Examples:

circle; filled and unfilled:
 `````` |v c| v := (View extent:200@100) openAndWait. 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) openAndWait. 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 openAndWait. 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 openAndWait. 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 openAndWait. 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. ]. ``````

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 22 Feb 2024 17:58:03 GMT