eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'EllipticalPieSlice':

Home

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

Class: EllipticalPieSlice


Inheritance:

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

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.3 date: 2022/02/17 10:26:13
user: cg
file: EllipticalPieSlice.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


These are similar to ellipticalArcs,
but drawn differently:

If drawn as outline, the endpoints are connected to the center (pie);
same if drawn filled.

If the sweepAngle covers all 360 degrees, they look the same as elliptical arcs

copyright

COPYRIGHT (c) 2020 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 protocol:

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

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


Examples:


pie slices; filled & unfilled:
  |v e1 e2 e3 e4 e5|

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

  e1 := EllipticalPieSlice 
          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.
pie slices ; filled & unfilled:
  |v e e2 e3 e4|

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

  e := EllipticalPieSlice 
          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 := EllipticalPieSlice 
          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 := EllipticalPieSlice 
          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 pies; filled:
  |v ell|

  v := View new openAndWaitUntilVisible.

  ell := EllipticalPieSlice
              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 := EllipticalPieSlice
              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 open.
   v waitUntilVisible.
   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 := EllipticalPieSlice
               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 open.
   v waitUntilVisible.
   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 := EllipticalPieSlice
               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 open.
   v waitUntilVisible.
   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 := EllipticalPieSlice
               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; Sun, 08 Sep 2024 02:48:52 GMT