Circle.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 2155 15a41c701d00
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
86
claus
parents: 85
diff changeset
     1
"
claus
parents: 85
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
112
3e18f2cfe430 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
     3
	      All Rights Reserved
86
claus
parents: 85
diff changeset
     4
claus
parents: 85
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 85
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 85
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 85
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 85
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 85
diff changeset
    10
 hereby transferred.
claus
parents: 85
diff changeset
    11
"
1303
6ca5f36cdc63 category
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
6ca5f36cdc63 category
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    13
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    14
Geometric subclass:#Circle
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    15
	instanceVariableNames:'center radius'
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    16
	classVariableNames:''
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    17
	poolDictionaries:''
1303
6ca5f36cdc63 category
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    18
	category:'Graphics-Geometry-Objects'
78
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    21
!Circle class methodsFor:'documentation'!
78
claus
parents:
diff changeset
    22
claus
parents:
diff changeset
    23
copyright
claus
parents:
diff changeset
    24
"
claus
parents:
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
    26
	      All Rights Reserved
claus
parents:
diff changeset
    27
claus
parents:
diff changeset
    28
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    33
 hereby transferred.
claus
parents:
diff changeset
    34
"
claus
parents:
diff changeset
    35
!
claus
parents:
diff changeset
    36
claus
parents:
diff changeset
    37
documentation
claus
parents:
diff changeset
    38
"
claus
parents:
diff changeset
    39
     This class implements a circles which are defined by a radius and
claus
parents:
diff changeset
    40
     a centerpoint.
281
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    41
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    42
    [author:]
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    43
        Claus Gittinger
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    44
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    45
    [see also:]
331
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
    46
        EllipticalArc Spline Curve Polygon Rectangle LineSegment
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
    47
        Arrow ArrowedSpline
281
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
    48
        GraphicsContext
331
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
    49
        StrokingWrapper FillingWrapper
78
claus
parents:
diff changeset
    50
"
289
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    51
!
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    52
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    53
examples
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    54
"
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    55
  circle; filled and unfilled:
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    56
                                                                        [exBegin]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    57
    |v c|
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    58
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    59
    v := (View extent:200@100) openAndWait.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    60
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    61
    c := Circle boundingBox:(10@10 corner:90@90). 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    62
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    63
    v paint:Color blue.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    64
    c displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    65
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    66
    c center:150@50.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    67
    v paint:Color red.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    68
    c displayStrokedOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    69
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    70
                                                                        [exEnd]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    71
  circle & rectangle; both filled:
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    72
                                                                        [exBegin]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    73
    |v c|
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    74
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    75
    v := (View extent:100@100) openAndWait.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    76
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    77
    c := Circle center:50@50 radius:40. 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    78
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    79
    v paint:Color red.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    80
    c asRectangle displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    81
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    82
    v paint:Color blue.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    83
    c displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    84
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    85
                                                                        [exEnd]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    86
  circles; filled & unfilled:
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    87
                                                                        [exBegin]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    88
    |v c|
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    89
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    90
    v := View new openAndWait.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    91
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    92
    c := Circle center:50@50 radius:40.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    93
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    94
    v paint:Color red.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    95
    c displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    96
    50 to:1 by:-1 do:[:r |
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    97
        c radius:r.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    98
        v paint:(Color grey:(r * 2)).
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    99
        c displayStrokedOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   100
    ].
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   101
    1 to:50 do:[:r |
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   102
        c radius:r.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   103
        v paint:(Color grey:100-(r * 2)).
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   104
        c displayStrokedOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   105
    ]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   106
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   107
                                                                        [exEnd]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   108
  more arcs; filled:
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   109
                                                                        [exBegin]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   110
    |v ell|
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   111
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   112
    v := View new openAndWait.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   113
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   114
    ell := EllipticalArc
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   115
                boundingBox:(10@10 corner:90@90) 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   116
                startAngle:0
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   117
                sweepAngle:0.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   118
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   119
    #(45 90 135 180 225 270 315 360) 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   120
    keysAndValuesReverseDo:[:index :angle |
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   121
        index odd ifTrue:[
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   122
            v paint:Color white
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   123
        ] ifFalse:[
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   124
            v paint:Color black
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   125
        ].
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   126
        ell sweepAngle:angle.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   127
        ell displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   128
        Delay waitForSeconds:0.1.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   129
    ].
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   130
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   131
                                                                        [exEnd]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   132
  more arcs; filled:
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   133
                                                                        [exBegin]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   134
    |v ell|
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   135
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   136
    v := View new openAndWait.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   137
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   138
    ell := EllipticalArc
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   139
                boundingBox:(10@10 corner:90@90) 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   140
                startAngle:0
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   141
                sweepAngle:45.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   142
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   143
    #(45 90 135 180 225 270 315 360) 
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   144
    with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1)
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   145
    do:[:angle :grey |
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   146
        ell startAngle:angle-45.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   147
        v paint:(ColorValue red:grey green:0 blue:0).
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   148
        ell displayFilledOn:v.
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   149
    ].
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   150
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   151
                                                                        [exEnd]
c4a61914a9a0 more examples & comments
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   152
"
78
claus
parents:
diff changeset
   153
! !
claus
parents:
diff changeset
   154
claus
parents:
diff changeset
   155
!Circle class methodsFor:'instance creation'!
claus
parents:
diff changeset
   156
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   157
boundingBox:aRectangle
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   158
    "Return a new Circle centered in aRectangle."
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   159
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   160
    ^ self
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   161
        center:(aRectangle center)
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   162
        radius:(aRectangle width min:aRectangle height) / 2
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   163
!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   164
78
claus
parents:
diff changeset
   165
center:centerPoint radius:radius
claus
parents:
diff changeset
   166
    "Return a new Circle."
claus
parents:
diff changeset
   167
283
59a8cfbc1e5e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   168
    ^ self new center:centerPoint radius:radius
78
claus
parents:
diff changeset
   169
283
59a8cfbc1e5e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   170
    "Modified: 8.5.1996 / 20:39:30 / cg"
78
claus
parents:
diff changeset
   171
! !
claus
parents:
diff changeset
   172
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   173
!Circle methodsFor:'accessing'!
78
claus
parents:
diff changeset
   174
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   175
center 
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   176
    "return the center."
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   177
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   178
    ^ center
78
claus
parents:
diff changeset
   179
!
claus
parents:
diff changeset
   180
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   181
center:aPoint 
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   182
    "set the center point."
78
claus
parents:
diff changeset
   183
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   184
    center := aPoint
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   185
!
78
claus
parents:
diff changeset
   186
claus
parents:
diff changeset
   187
center:centerPoint radius:radiusNumber
claus
parents:
diff changeset
   188
    "set the center and radius"
claus
parents:
diff changeset
   189
claus
parents:
diff changeset
   190
    center := centerPoint.
claus
parents:
diff changeset
   191
    radius := radiusNumber
claus
parents:
diff changeset
   192
!
claus
parents:
diff changeset
   193
claus
parents:
diff changeset
   194
radius 
claus
parents:
diff changeset
   195
    "return the radius."
claus
parents:
diff changeset
   196
claus
parents:
diff changeset
   197
    ^ radius
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   198
!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   199
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   200
radius:aNumber 
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   201
    "set the radius."
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   202
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   203
    radius := aNumber
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   204
! !
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   205
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   206
!Circle methodsFor:'converting'!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   207
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   208
asEllipticalArc
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   209
    "convert the receiver into an ellipticalArc"
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   210
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   211
    ^ EllipticalArc center:center radius:radius 
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   212
! !
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   213
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   214
!Circle methodsFor:'displaying'!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   215
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   216
displayFilledOn:aGC
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   217
    "draw the receiver as a filled circle in a graphicsContext, aGC"
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   218
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   219
    aGC fillCircle:center radius:radius
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   220
!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   221
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   222
displayStrokedOn:aGC
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   223
    "draw the receiver as a unfilled circle in a graphicsContext, aGC"
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   224
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   225
    aGC displayCircle:center radius:radius
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   226
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   227
! !
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   228
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   229
!Circle methodsFor:'queries'!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   230
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   231
area
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   232
    "return the area of the receiver."
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   233
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   234
    ^ radius * radius * (Float pi)
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   235
!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   236
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   237
bounds
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   238
    "return the smallest enclosing rectangle"
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   239
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   240
    ^ Rectangle origin:(center - radius) corner:(center + radius)
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   241
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   242
    "
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   243
     (Circle center:100@100 radius:50) bounds 
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   244
    "
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   245
!
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   246
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   247
diameter
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   248
    "return the diameter of the receiver."
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   249
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   250
    ^ radius * 2
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   251
!
78
claus
parents:
diff changeset
   252
claus
parents:
diff changeset
   253
startAngle
claus
parents:
diff changeset
   254
    "return the startAngle.
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   255
     Provided for protocol compatibility with arcs and ellipese;
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   256
     for circles, this is an arbitrary angle."
78
claus
parents:
diff changeset
   257
claus
parents:
diff changeset
   258
    ^ 0
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   259
!
78
claus
parents:
diff changeset
   260
claus
parents:
diff changeset
   261
sweepAngle
claus
parents:
diff changeset
   262
    "return the sweepAngle.
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   263
     Provided for protocol compatibility with arcs and ellipese;
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   264
     for circles, this is always 360 degrees."
78
claus
parents:
diff changeset
   265
claus
parents:
diff changeset
   266
    ^ 360
claus
parents:
diff changeset
   267
! !
claus
parents:
diff changeset
   268
2155
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   269
!Circle methodsFor:'testing'!
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   270
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   271
canBeFilled
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   272
    "return true, if the receiver can be drawn filled; always true here"
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   273
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   274
    ^ true
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   275
! !
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   276
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   277
!Circle class methodsFor:'documentation'!
78
claus
parents:
diff changeset
   278
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   279
version
2155
15a41c701d00 category changes
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   280
    ^ '$Header: /cvs/stx/stx/libbasic2/Circle.st,v 1.13 2009-06-06 10:12:18 cg Exp $'
275
4a9fed506144 doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   281
! !