eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Circle':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Circle


Inheritance:

   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

Description:


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

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.

Class protocol:

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

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


Instance protocol:

accessing
o  center
return the center.

o  center: aPoint
set the center point.

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

o  radius
return the radius.

o  radius: aNumber
set the radius.

converting
o  asEllipticalArc
convert the receiver into an ellipticalArc

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

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

queries
o  area
return the area of the receiver.

o  computeBounds
return the smallest enclosing rectangle

o  diameter
return the diameter of the receiver.

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

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

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

transformations
o  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:)

o  roundedToNearestIntegerPoint
return a copy of the receiver, where all points are rounded to ly on the nearest integer coordinate

o  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

o  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)


Examples:


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.
  ].



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 03:39:06 GMT