eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'EllipticalArc':

Home

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

Class: EllipticalArc


Inheritance:

   Object
   |
   +--Geometric
      |
      +--EllipticalArc
         |
         +--EllipticalPieSlice

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.23 date: 2022/02/17 10:25:32
user: cg
file: EllipticalArc.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


This class implements an ellipse which is aligned to x and y axes
given a boundingBox, a startAngle and a sweepAngle.
Positive angles are taken clockwise, negative angles are counterclockwise.

If the boundingBox is a square, the result is a circular arc.
If it is rotated, the result will be aproximated as a polygon.

If drawn as outline, only the path along the circle is drawn;
if drawn filled, only the area between the circle and the line from start
to end are drawn.

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 elliptical arc (circular, if boundingBox is square).

o  boundingBox: aRectangle startAngle: startAngle endAngle: endAngle
Return a new elliptical arc (circular, if boundingBox is square).
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  boundingBox: aRectangle startAngle: startAngle sweepAngle: sweepAngle
Return a new elliptical arc (circular, if boundingBox is square).
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  center: centerPoint radius: radius
Return a circlular arc.

o  center: centerPoint radius: radius startAngle: startAngle endAngle: endAngle
Return a new (circular) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  center: centerPoint radius: radius startAngle: startAngle sweepAngle: sweepAngle
Return a new (circular) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  center: centerPoint radiusX: radiusX radiusY: radiusY startAngle: startAngle endAngle: endAngle
Return a new (elliptical) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  center: centerPoint radiusX: radiusX radiusY: radiusY startAngle: startAngle sweepAngle: sweepAngle
Return a new elliptical arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.


Instance protocol:

accessing
o  boundingBox: aRectangle
setup the arc, given a bounding rectangle

o  boundingBox: aRectangle startAngle: start sweepAngle: sweep
setup the arc, given a bounding rectangle, start and endAngle.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  center: centerPoint radius: radius
setup for a circular arc, given center and radius

o  center: centerPoint radiusX: radiusX radiusY: radiusY
setup for an elliptical arc, given center and radius in x and y direction

o  endAngle
return the endAngle.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  startAngle
return the startAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  startAngle: angle
set the startAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  sweepAngle
return the sweepAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

o  sweepAngle: angle
set the sweepAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.

converting
o  asEllipticalArc
convert the receiver into an ellipticalArc - that's the receiver itself

o  asPolygon
convert the receiver into a polygon which approximates the arc

o  computeVertices
compute vertices for drawing

displaying
o  displayFilledOn: aGC
(comment from inherited method)
display myself filled on a graphicsContext; the current graphics
attributes are used. Since we do not know how to do it, nothing is
drawn here.

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

o  vertices

queries
o  center
return the center

o  computeBounds
return the smallest enclosing rectangle

testing
o  canBeFilled
return true, if the receiver can be drawn as a filled geometric.
Always true here.

transforming
o  rotatedBy: angle about: rotationCenter
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  transformedBy: aMatrix
return a copy of the receiver, which is transformed using aMatrix;
for any transformation which shears or rotates to non-axis aligned bounding box,
a polygon which approximates the arc is returned.

Usage example(s):

bbx := boundingBox transformedBy:aMatrix.

Usage example(s):

((Point r:1 theta:(360-startAngle) degreesToRadians) transformedBy:aMatrix) theta radiansToDegrees.

o  translatedBy: amount
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number


Examples:


ellipses; filled & unfilled:
  |v e1 e2 p1 p2|

  v := (View extent:400@300) openAndWaitUntilVisible.
  v paint:Color red.
  v translation:100@100.
  v displayLineFrom:-100@0 to:100@0.
  v displayLineFrom:0@-100 to:0@100.

  e1 := EllipticalArc 
          center:0@0 radius:30
          startAngle:0
          endAngle:180. 

  v paint:Color blue.
  e1 displayOn:v.

  e2 := e1 rotatedBy:90 degreesToRadians about:0@0.
  v paint:Color cyan.
  e2 displayOn:v.

  p1 := e1 asPolygon.
  v paint:Color green darkened.
  p1 displayOn:v.

  p2 := p1 rotatedBy:90 degreesToRadians about:0@0.
  v paint:Color red.
  p2 displayOn:v.

  e2 := e1 rotatedBy:-90 degreesToRadians about:e1 center.
  v paint:Color green darkened.
  e2 displayOn:v.
  |v e1 e2 p1 p2|

  v := (View extent:400@300) openAndWaitUntilVisible.
  v paint:Color red.
  v translation:100@100.
  v displayLineFrom:-100@0 to:100@0.
  v displayLineFrom:0@-100 to:0@100.

  e1 := EllipticalArc 
          center:50@50 radius:30
          startAngle:0
          endAngle:180. 

  v paint:Color blue.
  e1 displayOn:v.

  p1 := e1 asPolygon.
  p1 := p1 translatedBy:100@0.
  p1 displayOn:v.

  p2 := p1 rotatedBy:90 degreesToRadians about:150@50.
  p2 := p2 translatedBy:100@0.
  v paint:Color red.
  p2 displayOn:v.

  e2 := e1 rotatedBy:-90 degreesToRadians about:e1 center.
  v paint:Color green darkened.
  e2 displayOn:v.
  |v e1 e2 e3 e4 e5|

  v := (View extent:400@300) openAndWaitUntilVisible.

  e1 := EllipticalArc 
          boundingBox:(10@50 corner:190@130)
          startAngle:0
          endAngle:360. 

  v paint:Color blue.
  e1 displayFilledOn:v.

  v paint:Color red.
  e1 displayStrokedOn:v.

  e2 := e1 translatedBy:(200@50).
  v paint:Color darkGreen.
  e2 displayStrokedOn:v.

  e3 := e1 rotatedBy:90 degreesToRadians about:e1 bounds center.
  v paint:Color darkRed.
  e3 displayStrokedOn:v.

  e4 := e1 rotatedBy:45 degreesToRadians about:e1 bounds center.
  v paint:Color orange.
  e4 displayStrokedOn:v.

  e5 := e4 translatedBy:(0@150).
  v paint:Color green darkened.
  e5 displayFilledOn:v.
elliptical arcs; filled & unfilled:
  |v e e2 e3 e4|

  v := (View extent:250@200) openAndWaitUntilVisible.

  e := EllipticalArc 
          boundingBox:(10@10 corner:140@95)
          startAngle:0
          endAngle:270. 

  v paint:Color blue.
  e displayFilledOn:v.

  v paint:Color red.
  e displayStrokedOn:v.

  e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
  e2 := e2 translatedBy:50@50.
  v paint:Color yellow.
  e2 displayFilledOn:v.
  v paint:Color orange.
  e2 displayStrokedOn:v.

  e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
  e3 := e3 translatedBy:00@100.
  v paint:Color orange.
  e3 displayFilledOn:v.
  v paint:Color red darkened.
  e3 displayStrokedOn:v.

  e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
  e4 := e4 translatedBy:100@75.
  v paint:Color orange lightened.
  e4 displayFilledOn:v.
  v paint:Color blue.
  e4 displayStrokedOn:v.

  |v e e2 e3 e4|

  v := (View extent:250@200) openAndWaitUntilVisible.

  e := EllipticalArc 
          boundingBox:(10@10 corner:140@95)
          startAngle:0
          endAngle:90. 

  v paint:Color blue.
  e displayFilledOn:v.

  v paint:Color red.
  e displayStrokedOn:v.

  e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
  e2 := e2 translatedBy:50@50.
  v paint:Color yellow.
  e2 displayFilledOn:v.
  v paint:Color orange.
  e2 displayStrokedOn:v.

  e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
  e3 := e3 translatedBy:00@100.
  v paint:Color orange.
  e3 displayFilledOn:v.
  v paint:Color red darkened.
  e3 displayStrokedOn:v.

  e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
  e4 := e4 translatedBy:100@75.
  v paint:Color orange lightened.
  e4 displayFilledOn:v.
  v paint:Color blue.
  e4 displayStrokedOn:v.

  |v e e2 e3 e4|

  v := (View extent:250@200) openAndWaitUntilVisible.

  e := EllipticalArc 
          boundingBox:(10@10 corner:140@95)
          startAngle:0
          endAngle:180. 

  v paint:Color blue.
  e displayFilledOn:v.

  v paint:Color red.
  e displayStrokedOn:v.

  e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
  e2 := e2 translatedBy:50@50.
  v paint:Color yellow.
  e2 displayFilledOn:v.
  v paint:Color orange.
  e2 displayStrokedOn:v.

  e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
  e3 := e3 translatedBy:00@100.
  v paint:Color orange.
  e3 displayFilledOn:v.
  v paint:Color red darkened.
  e3 displayStrokedOn:v.

  e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
  e4 := e4 translatedBy:100@75.
  v paint:Color orange lightened.
  e4 displayFilledOn:v.
  v paint:Color blue.
  e4 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.
  ].
   |v e  e2 e3 e4 e5|

   v := View new extent:400@400.
   v transformation:(WindowingTransformation 
                      scale:1 
                      translation:(150@150)).
   v openAndWaitUntilVisible.
   v clear.

   v paint:(Color red).
   v displayLineFrom:(-200@0) to:(200@0).
   v displayLineFrom:(0@-200) to:(0@200).
   v displayLineFrom:(100@3) to:(100@-3).
   v displayLineFrom:(3@100) to:(-3@100).

   e := EllipticalArc
               boundingBox:(10@10 corner:90@90) 
               startAngle:0
               sweepAngle:90.
   v paint:(Color darkGreen).
   e displayOn:v.
   e bounds displayOn:v.
   v paint:(Color green).
   e asPolygon displayOn:v.

   e2 := e rotatedBy:90 degreesToRadians about:0@0.
   e3 := e rotatedBy:180 degreesToRadians about:0@0.
   e4 := e rotatedBy:270 degreesToRadians about:0@0.

   v paint:(Color blue).
   e2 displayOn:v.
   e2 bounds displayOn:v.
   v paint:(Color blue lightened).
   e2 asPolygon displayOn:v.

   v paint:(Color yellow slightlyDarkened).
   e3 displayOn:v.
   e3 bounds displayOn:v.
   v paint:(Color yellow).
   e3 asPolygon displayOn:v.

   v paint:(Color cyan slightlyDarkened).
   e4 displayOn:v.
   e4 bounds displayOn:v.
   v paint:(Color cyan).
   e4 asPolygon displayOn:v.

   e5 := e rotatedBy:45 degreesToRadians about:0@0.
   v paint:(Color brown).
   (e bounds rotatedBy:45 degreesToRadians about:0@0) displayOn:v.
   e5 displayOn:v.
   |v e|

   v := View new extent:400@400.
   v transformation:(WindowingTransformation 
                      scale:1 
                      translation:(150@150)).
   v openAndWaitUntilVisible.
   v clear.

   v paint:(Color red).
   v displayLineFrom:(-200@0) to:(200@0).
   v displayLineFrom:(0@-200) to:(0@200).
   v displayLineFrom:(100@3) to:(100@-3).
   v displayLineFrom:(3@100) to:(-3@100).

   e := EllipticalArc
               boundingBox:(10@10 corner:90@90) 
               startAngle:0
               sweepAngle:90.

   0 to:359 by:20 do:[:angle |
      (e rotatedBy:(angle degreesToRadians) about:0@0) displayOn:v
   ].
|v e| v := View new extent:400@400. v transformation:(WindowingTransformation scale:1 translation:(150@150)). v openAndWaitUntilVisible. v clear. v paint:(Color red). v displayLineFrom:(-200@0) to:(200@0). v displayLineFrom:(0@-200) to:(0@200). v displayLineFrom:(100@3) to:(100@-3). v displayLineFrom:(3@100) to:(-3@100). e := EllipticalArc boundingBox:(10@10 corner:90@90) startAngle:0 sweepAngle:90. 0 to:359 by:20 do:[:angle | v paint:(Color hue:angle light:50 saturation:100). (e rotatedBy:(angle degreesToRadians) about:0@0) displayFilledOn:v ].

ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 10:41:15 GMT