0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Object subclass:#GraphicsContext
|
|
14 |
instanceVariableNames:'foreground background paint bgPaint
|
|
15 |
function font
|
|
16 |
lineStyle lineWidth
|
|
17 |
joinStyle capStyle
|
|
18 |
mask maskOrigin'
|
|
19 |
classVariableNames:'White Black'
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Graphics-Display Objects'
|
|
22 |
!
|
|
23 |
|
|
24 |
GraphicsContext comment:'
|
|
25 |
|
6
|
26 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
this is an abstract superclass for all kinds of graphic drawables -
|
|
30 |
both windows and printed pages (i.e. printers) are inheriting from
|
|
31 |
this class.
|
|
32 |
|
|
33 |
Drawing is done somewhat silly (due to beeing both backward compatible
|
|
34 |
and supporting ST-80 messages). The paint instance describes the paint
|
|
35 |
color, which can be (on monos) a dither pixmap drawn in foreground/background
|
|
36 |
colors.
|
|
37 |
Foreground and background are the underlying basic-colors, which must be
|
|
38 |
real colors (i.e. non dithered). Direct access to fg/bg is discouraged, since
|
|
39 |
in the future, foreground / background will be totally replaced by
|
|
40 |
paint.
|
|
41 |
|
|
42 |
All drawing is defined upon a few basic drawing methods, which must be
|
|
43 |
implemented by subclasses (some subclasses also redefine the others for
|
|
44 |
more performance)
|
|
45 |
|
24
|
46 |
$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.6 1994-01-08 17:15:42 claus Exp $
|
0
|
47 |
|
|
48 |
Instance variables:
|
|
49 |
|
|
50 |
paint <Color> the paint used for drawing
|
|
51 |
bgPaint <Color> the background used for drawing texts and bitmaps
|
|
52 |
foreground <Color> the device foreground color used for drawing
|
|
53 |
background <Color> the device background color used for drawing
|
|
54 |
function <Symbol> the drawing function (i.e. #copy, #or, #xor ...)
|
|
55 |
- not all Drawables support every function
|
|
56 |
(i.e. paper only allows #copy)
|
|
57 |
font <Font> the font currently used for drawing
|
|
58 |
lineStyle <Symbol> the lineStyle (i.e. #solid, #dashed, #doubleDashed)
|
|
59 |
lineWidth <SmallInteger> the lineWidth (device dependent, usually pixels)
|
|
60 |
joinStyle <Symbol> the style in which lines (in polygons)
|
|
61 |
are joined (i.e. #miter, #bevel, #round)
|
|
62 |
capStyle <Symbol> the style in which the last point
|
|
63 |
of a line is drawn
|
|
64 |
(i.e. #notLast, #butt, #round, #projecting)
|
|
65 |
mask <Form> a mask used for drawing
|
|
66 |
- not all Drawables support it
|
|
67 |
maskOrigin <Point> the origin of the mask relative to
|
|
68 |
the drawables origin
|
|
69 |
|
|
70 |
Class variables:
|
|
71 |
|
|
72 |
White <Color> cached white color - its needed so often
|
|
73 |
Black <Color> cached black color - its needed so often
|
|
74 |
|
|
75 |
Class instance variables:
|
|
76 |
|
|
77 |
DefaultFont <Font> default font to use
|
|
78 |
|
|
79 |
written summer 92 by claus
|
|
80 |
'!
|
|
81 |
|
|
82 |
GraphicsContext class instanceVariableNames:'DefaultFont'!
|
|
83 |
|
|
84 |
!GraphicsContext class methodsFor:'initialization'!
|
|
85 |
|
|
86 |
initialize
|
|
87 |
"setup some defaults - these are usually redefined
|
|
88 |
during startup."
|
|
89 |
|
12
|
90 |
Color isNil ifTrue:[^ self].
|
0
|
91 |
Color initialize.
|
|
92 |
White := Color white.
|
|
93 |
Black := Color black.
|
|
94 |
|
|
95 |
Font initialize.
|
|
96 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12
|
|
97 |
! !
|
|
98 |
|
|
99 |
!GraphicsContext class methodsFor:'accessing defaults'!
|
|
100 |
|
|
101 |
defaultFont:aFont
|
12
|
102 |
"set the default font used for drawing"
|
|
103 |
|
0
|
104 |
DefaultFont := aFont
|
|
105 |
!
|
|
106 |
|
|
107 |
defaultFont
|
12
|
108 |
"get the default font used for drawing"
|
|
109 |
|
0
|
110 |
^ DefaultFont
|
|
111 |
! !
|
|
112 |
|
|
113 |
!GraphicsContext class methodsFor:'constants'!
|
|
114 |
|
|
115 |
joinRound
|
|
116 |
"return a constant to specify round join"
|
|
117 |
|
|
118 |
^ #round
|
|
119 |
!
|
|
120 |
|
|
121 |
joinMiter
|
|
122 |
"return a constant to specify miter join"
|
|
123 |
|
|
124 |
^ #miter
|
|
125 |
!
|
|
126 |
|
|
127 |
joinBevel
|
|
128 |
"return a constant to specify bevel join"
|
|
129 |
|
|
130 |
^ #bevel
|
|
131 |
!
|
|
132 |
|
|
133 |
capNotLast
|
|
134 |
"return a constant to specify not-last cap"
|
|
135 |
|
|
136 |
^ #notLast
|
|
137 |
!
|
|
138 |
|
|
139 |
capProjecting
|
|
140 |
"return a constant to specify projecting cap"
|
|
141 |
|
|
142 |
^ #projecting
|
|
143 |
!
|
|
144 |
|
|
145 |
capRound
|
|
146 |
"return a constant to specify round cap"
|
|
147 |
|
|
148 |
^ #round
|
|
149 |
!
|
|
150 |
|
|
151 |
capButt
|
|
152 |
"return a constant to specify butt cap"
|
|
153 |
|
|
154 |
^ #butt
|
|
155 |
! !
|
|
156 |
|
|
157 |
!GraphicsContext class methodsFor:'instance creation'!
|
|
158 |
|
|
159 |
new
|
|
160 |
^ self basicNew initialize
|
|
161 |
! !
|
|
162 |
|
|
163 |
!GraphicsContext methodsFor:'initialization'!
|
|
164 |
|
|
165 |
initialize
|
|
166 |
"set up some useful default values"
|
|
167 |
|
|
168 |
"default is drawing black-on-white;
|
|
169 |
since these two colors are needed very often, cache them here"
|
|
170 |
|
|
171 |
White isNil ifTrue:[White := Color white].
|
|
172 |
Black isNil ifTrue:[Black := Color black].
|
|
173 |
|
|
174 |
paint := Black.
|
|
175 |
bgPaint := White.
|
|
176 |
foreground := Black.
|
|
177 |
background := White.
|
|
178 |
function := #copy.
|
|
179 |
lineWidth := 1.
|
|
180 |
lineStyle := #solid.
|
|
181 |
joinStyle := #miter.
|
|
182 |
capStyle := #butt.
|
|
183 |
|
|
184 |
self initFont
|
|
185 |
!
|
|
186 |
|
|
187 |
initFont
|
|
188 |
|aFont|
|
|
189 |
|
|
190 |
aFont := self class defaultFont.
|
|
191 |
"this is a kludge"
|
|
192 |
aFont isNil ifTrue:[
|
|
193 |
self class initialize.
|
|
194 |
aFont := self class defaultFont.
|
|
195 |
].
|
|
196 |
aFont notNil ifTrue:[
|
|
197 |
font := aFont
|
|
198 |
]
|
|
199 |
! !
|
|
200 |
|
2
|
201 |
!GraphicsContext methodsFor:'misc'!
|
|
202 |
|
|
203 |
flush
|
|
204 |
"st-80 compatibility"
|
|
205 |
|
|
206 |
^ self
|
|
207 |
! !
|
|
208 |
|
0
|
209 |
!GraphicsContext methodsFor:'accessing'!
|
|
210 |
|
|
211 |
paint
|
|
212 |
"return the current paint drawing color"
|
|
213 |
|
|
214 |
^ paint
|
|
215 |
!
|
|
216 |
|
|
217 |
paint:aColor
|
|
218 |
"set the drawing painting color, aColor can be a dithered one"
|
|
219 |
|
2
|
220 |
paint := aColor
|
0
|
221 |
!
|
|
222 |
|
|
223 |
paint:fgColor on:bgColor
|
|
224 |
"set the paint used for text and bitmaps, both colors may be
|
|
225 |
dithered colors"
|
|
226 |
|
2
|
227 |
paint := fgColor.
|
|
228 |
bgPaint := bgColor
|
0
|
229 |
!
|
|
230 |
|
|
231 |
backgroundPaint
|
|
232 |
"return the background paint color.
|
|
233 |
(used for opaqueForms and opaqueStrings)"
|
|
234 |
|
|
235 |
^ bgPaint
|
|
236 |
!
|
|
237 |
|
|
238 |
backgroundPaint:aColor
|
|
239 |
"set the background painting color (which is used for
|
|
240 |
opaqueForms and opaqueStrings). aColor can be a dithered one."
|
|
241 |
|
|
242 |
^ self subclassResponsibility
|
|
243 |
!
|
|
244 |
|
|
245 |
foreground
|
|
246 |
"return the current foreground drawing color"
|
|
247 |
|
|
248 |
^ foreground
|
|
249 |
!
|
|
250 |
|
|
251 |
foreground:aColor
|
|
252 |
"set the drawing foreground color.
|
|
253 |
aColor MUST be a real (i.e. device-) color"
|
|
254 |
|
2
|
255 |
foreground := aColor
|
0
|
256 |
!
|
|
257 |
|
|
258 |
background
|
|
259 |
"return the current background drawing color"
|
|
260 |
|
|
261 |
^ background
|
|
262 |
!
|
|
263 |
|
|
264 |
background:aColor
|
|
265 |
"set the drawing background color.
|
|
266 |
aColor MUST be a real (i.e. device-) color"
|
|
267 |
|
2
|
268 |
background := aColor
|
0
|
269 |
!
|
|
270 |
|
|
271 |
function
|
|
272 |
"return the current drawing function"
|
|
273 |
|
|
274 |
^ function
|
|
275 |
!
|
|
276 |
|
|
277 |
function:aFunctionSymbol
|
|
278 |
"set the drawing function"
|
|
279 |
|
|
280 |
^ self subclassResponsibility
|
|
281 |
!
|
|
282 |
|
|
283 |
foreground:fgColor background:bgColor
|
|
284 |
"set both foreground and background colors"
|
|
285 |
|
|
286 |
self foreground:fgColor.
|
|
287 |
self background:bgColor
|
|
288 |
!
|
|
289 |
|
|
290 |
foreground:fgColor background:bgColor function:f
|
|
291 |
"set foreground, background colors and function"
|
|
292 |
|
|
293 |
self foreground:fgColor.
|
|
294 |
self background:bgColor.
|
|
295 |
self function:f
|
|
296 |
!
|
|
297 |
|
|
298 |
lineWidth
|
|
299 |
"return the current drawing linewidth"
|
|
300 |
|
|
301 |
^ lineWidth
|
|
302 |
!
|
|
303 |
|
|
304 |
lineWidth:aNumber
|
|
305 |
"set the line drawing width in pixels"
|
|
306 |
|
2
|
307 |
lineWidth := aNumber
|
0
|
308 |
!
|
|
309 |
|
|
310 |
lineStyle
|
|
311 |
"return the current line-drawing-style"
|
|
312 |
|
|
313 |
^ lineStyle
|
|
314 |
!
|
|
315 |
|
|
316 |
lineStyle:aStyleSymbol
|
|
317 |
"set the line-drawing-style;
|
|
318 |
possible styles are: #solid, #dashed, #doubleDashed"
|
|
319 |
|
2
|
320 |
lineStyle := aStyleSymbol
|
0
|
321 |
!
|
|
322 |
|
|
323 |
capStyle
|
|
324 |
"return the current cap-style for line-drawing"
|
|
325 |
|
|
326 |
^ capStyle
|
|
327 |
!
|
|
328 |
|
|
329 |
capStyle:aStyleSymbol
|
|
330 |
"set the cap-style for line-drawing;
|
|
331 |
possible styles are: #notLast, #butt, #round, #projecting"
|
|
332 |
|
|
333 |
^ self subclassResponsibility
|
|
334 |
!
|
|
335 |
|
|
336 |
joinStyle
|
|
337 |
"return the current join-style for polygon-drawing"
|
|
338 |
|
|
339 |
^ joinStyle
|
|
340 |
!
|
|
341 |
|
|
342 |
joinStyle:aStyleSymbol
|
|
343 |
"set the join-style of lines in polygon-drawing;
|
|
344 |
possible styles are: #miter, #bevel, #round"
|
|
345 |
|
|
346 |
^ self subclassResponsibility
|
|
347 |
!
|
|
348 |
|
|
349 |
mask
|
|
350 |
"return the current drawing mask"
|
|
351 |
|
|
352 |
^ mask
|
|
353 |
!
|
|
354 |
|
|
355 |
mask:aForm
|
|
356 |
"set the drawing mask"
|
|
357 |
|
|
358 |
^ self subclassResponsibility
|
|
359 |
!
|
|
360 |
|
|
361 |
font
|
|
362 |
"return the current drawing font"
|
|
363 |
|
|
364 |
^ font
|
|
365 |
!
|
|
366 |
|
|
367 |
font:aFont
|
|
368 |
"set the drawing font"
|
|
369 |
|
|
370 |
^ self subclassResponsibility
|
|
371 |
!
|
|
372 |
|
|
373 |
clipRect:aRectangle
|
|
374 |
"set the drawing clip-rectangle"
|
|
375 |
|
|
376 |
^ self subclassResponsibility
|
|
377 |
!
|
|
378 |
|
|
379 |
graphicsContext
|
|
380 |
"for ST-80 compatibility"
|
|
381 |
|
|
382 |
^ self
|
2
|
383 |
!
|
|
384 |
|
|
385 |
viewOrigin
|
12
|
386 |
"return the drawables visible origin (for scrolling)"
|
|
387 |
|
2
|
388 |
^ 0@0
|
|
389 |
!
|
|
390 |
|
12
|
391 |
setMaskOrigin:aPoint
|
|
392 |
^ self
|
|
393 |
!
|
|
394 |
|
2
|
395 |
setMaskOriginX:x y:y
|
|
396 |
^ self
|
|
397 |
!
|
|
398 |
|
|
399 |
withPattern:aForm do:aBlock
|
|
400 |
'pattern drawing not implemented' printNewline.
|
|
401 |
aBlock value
|
0
|
402 |
! !
|
|
403 |
|
|
404 |
!GraphicsContext methodsFor:'displaying'!
|
|
405 |
|
|
406 |
displayRectangularBorder:aRectangle at:aPoint
|
|
407 |
"draw a rectangle - ST-80 compatibility"
|
|
408 |
|
|
409 |
self drawRectangle:(aRectangle translateBy:aPoint)
|
|
410 |
!
|
|
411 |
|
|
412 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset
|
|
413 |
"draw a line - ST-80 compatibility"
|
|
414 |
|
|
415 |
self displayLineFrom:(startPoint + anOffset)
|
|
416 |
to:(endPoint + anOffset)
|
|
417 |
!
|
|
418 |
|
|
419 |
displayRectangle:aRectangle
|
|
420 |
"draw a rectangle - ST-80 compatibility"
|
|
421 |
|
|
422 |
^ self drawRectangle:aRectangle
|
|
423 |
!
|
|
424 |
|
|
425 |
displayPolyline:aPolygon
|
|
426 |
"draw a polygon - ST-80 compatibility"
|
|
427 |
|
|
428 |
|p|
|
|
429 |
|
|
430 |
p := aPolygon collect:[:p | p x rounded @ p y rounded ].
|
|
431 |
self drawPolygon:p
|
|
432 |
!
|
|
433 |
|
|
434 |
displayPolygon:aPolygon
|
|
435 |
"draw a filled polygon - ST-80 compatibility"
|
|
436 |
|
|
437 |
|p|
|
|
438 |
|
|
439 |
p := aPolygon collect:[:p | p x rounded @ p y rounded ].
|
|
440 |
self fillPolygon:p
|
|
441 |
! !
|
|
442 |
|
|
443 |
!GraphicsContext methodsFor:'bit-blitting'!
|
|
444 |
|
|
445 |
copyFrom:aGraphicContext x:srcX y:srcY toX:dstX y:dstY width:w height:h
|
|
446 |
"copy from a drawable - maybe self"
|
|
447 |
|
|
448 |
^ self subclassResponsibility
|
|
449 |
!
|
|
450 |
|
|
451 |
copyFrom:aGraphicContext x:dstX y:dstY width:w height:h
|
|
452 |
"copy from a drawable - maybe self"
|
|
453 |
|
|
454 |
self copyFrom:aGraphicContext x:0 y:0 toX:dstX y:dstY width:w height:h
|
|
455 |
! !
|
|
456 |
|
|
457 |
!GraphicsContext methodsFor:'basic filling'!
|
|
458 |
|
|
459 |
fillPolygon:points
|
|
460 |
"fill a polygon with current paint color"
|
|
461 |
|
|
462 |
^ self subclassResponsibility
|
|
463 |
!
|
|
464 |
|
|
465 |
fillRectangleX:x y:y width:w height:h
|
|
466 |
"fill a rectangle with current paint color"
|
|
467 |
|
|
468 |
^ self subclassResponsibility
|
|
469 |
!
|
|
470 |
|
|
471 |
fillArcX:x y:y w:w h:h from:start angle:angle
|
|
472 |
"fill an arc with current paint color"
|
|
473 |
|
|
474 |
^ self subclassResponsibility
|
|
475 |
! !
|
|
476 |
|
|
477 |
!GraphicsContext methodsFor:'filling'!
|
|
478 |
|
|
479 |
fillRectangle:aRectangle
|
|
480 |
"fill a rectangle with current paint color"
|
|
481 |
|
|
482 |
self fillRectangleX:(aRectangle left)
|
|
483 |
y:(aRectangle top)
|
|
484 |
width:(aRectangle width)
|
|
485 |
height:(aRectangle height)
|
|
486 |
!
|
|
487 |
|
|
488 |
fillCircle:aPoint radius:aNumber
|
|
489 |
"draw a filled circle"
|
|
490 |
|
|
491 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber
|
|
492 |
!
|
|
493 |
|
|
494 |
fillCircleX:x y:y radius:r
|
|
495 |
"draw a filled circle"
|
|
496 |
|
|
497 |
|d|
|
|
498 |
d := 2 * r.
|
|
499 |
self fillArcX:(x - r) y:(y - r) w:d h:d from:0 angle:360
|
|
500 |
! !
|
|
501 |
|
|
502 |
!GraphicsContext methodsFor:'basic drawing'!
|
|
503 |
|
|
504 |
drawPolygon:aPolygon
|
|
505 |
"draw a polygon
|
|
506 |
- this could be recoded to draw using displayLine"
|
|
507 |
|
|
508 |
^ self subclassResponsibility
|
|
509 |
!
|
|
510 |
|
12
|
511 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle
|
0
|
512 |
"draw an arc in a box
|
|
513 |
- this could be recoded to draw using displayLine"
|
|
514 |
|
|
515 |
^ self subclassResponsibility
|
|
516 |
!
|
|
517 |
|
|
518 |
drawRectangleX:x y:y width:w height:h
|
|
519 |
"draw a rectangle
|
|
520 |
- this could be recoded to draw using displayLine"
|
|
521 |
|
|
522 |
^ self subclassResponsibility
|
|
523 |
!
|
|
524 |
|
|
525 |
drawForm:aForm x:x y:y
|
|
526 |
"draw a form at x/y; if the form has depth 1, 1's in the form are
|
|
527 |
drawn in current fg, 0's are ignored.
|
24
|
528 |
If the form has depth ~~ 1, the result is undefined"
|
|
529 |
|
|
530 |
|fg bg f|
|
|
531 |
|
|
532 |
fg := foreground.
|
|
533 |
bg := background.
|
|
534 |
f := function.
|
0
|
535 |
|
24
|
536 |
self foreground:(Color noColor) background:(Color allColor) function:#and.
|
|
537 |
self drawOpaqueForm:aForm x:x y:y.
|
|
538 |
self foreground:fg background:(Color noColor) function:#or.
|
|
539 |
self drawOpaqueForm:aForm x:x y:y.
|
|
540 |
self foreground:fg background:fg function:f.
|
|
541 |
|
|
542 |
"
|
0
|
543 |
^ self subclassResponsibility
|
24
|
544 |
"
|
0
|
545 |
!
|
|
546 |
|
|
547 |
drawOpaqueForm:aForm x:x y:y
|
|
548 |
"draw a form at x/y; if the form has depth 1, 1's in the form are
|
|
549 |
drawn in current fg, 0's in current bg color.
|
|
550 |
If the form has depth ~~ 1, it is copied as is onto the receiver"
|
|
551 |
|
|
552 |
^ self subclassResponsibility
|
|
553 |
!
|
|
554 |
|
|
555 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y
|
|
556 |
"draw part of a string with both fg and bg at x/y in current font"
|
|
557 |
|
|
558 |
^ self subclassResponsibility
|
|
559 |
!
|
|
560 |
|
|
561 |
displayString:aString from:index1 to:index2 x:x y:y
|
|
562 |
"draw part of a string with fg at x/y in current font"
|
|
563 |
|
|
564 |
^ self subclassResponsibility
|
|
565 |
! !
|
|
566 |
|
|
567 |
!GraphicsContext methodsFor:'drawing'!
|
|
568 |
|
|
569 |
displayOpaqueString:aString x:x y:y
|
|
570 |
"draw a string with both fg and bg"
|
|
571 |
|
|
572 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y
|
|
573 |
!
|
|
574 |
|
|
575 |
displayOpaqueString:aString at:aPoint
|
|
576 |
"draw a string with both fg and bg"
|
|
577 |
|
|
578 |
self displayOpaqueString:aString x:(aPoint x) y:(aPoint y)
|
|
579 |
!
|
|
580 |
|
|
581 |
displayString:aString x:x y:y
|
|
582 |
"draw a string - drawing fg only"
|
|
583 |
|
|
584 |
self displayString:aString from:1 to:(aString size) x:x y:y
|
|
585 |
!
|
|
586 |
|
|
587 |
displayString:aString at:aPoint
|
|
588 |
"draw a string - drawing fg only"
|
|
589 |
|
|
590 |
self displayString:aString x:aPoint x y:aPoint y
|
|
591 |
!
|
|
592 |
|
24
|
593 |
displayPointX:x y:y
|
0
|
594 |
"draw a point at x/y"
|
|
595 |
|
|
596 |
self displayLineFromX:x y:y toX:x y:y
|
|
597 |
!
|
|
598 |
|
24
|
599 |
displayPoint:aPoint
|
0
|
600 |
"draw a pixel"
|
|
601 |
|
24
|
602 |
self displayPointX:(aPoint x) y:(aPoint y)
|
0
|
603 |
!
|
|
604 |
|
|
605 |
displayLineFrom:point1 to:point2
|
|
606 |
"draw a line"
|
|
607 |
|
|
608 |
self displayLineFromX:(point1 x) y:(point1 y)
|
|
609 |
toX:(point2 x) y:(point2 y)
|
|
610 |
!
|
|
611 |
|
|
612 |
drawRectangle:aRectangle
|
|
613 |
"draw a rectangle"
|
|
614 |
|
|
615 |
self drawRectangleX:(aRectangle left)
|
|
616 |
y:(aRectangle top)
|
|
617 |
width:(aRectangle width)
|
|
618 |
height:(aRectangle height)
|
|
619 |
!
|
|
620 |
|
|
621 |
drawRectangleOrigin:origin corner:corner
|
|
622 |
"draw a rectangle"
|
|
623 |
|
|
624 |
|top left|
|
|
625 |
|
|
626 |
left := origin x.
|
|
627 |
top := origin y.
|
|
628 |
self drawRectangleX:left y:top
|
|
629 |
width:(corner x - left)
|
|
630 |
height:(corner y - top)
|
|
631 |
!
|
|
632 |
|
|
633 |
drawForm:aForm at:aPoint
|
|
634 |
"draw a form"
|
|
635 |
|
|
636 |
self drawForm:aForm x:(aPoint x) y:(aPoint y)
|
|
637 |
!
|
|
638 |
|
12
|
639 |
displayArcIn:aRectangle from:startAngle angle:angle
|
|
640 |
"draw an arc in a box"
|
0
|
641 |
|
12
|
642 |
self displayArcX:(aRectangle left)
|
|
643 |
y:(aRectangle top)
|
|
644 |
w:(aRectangle width)
|
|
645 |
h:(aRectangle height)
|
|
646 |
from:startAngle
|
|
647 |
angle:angle
|
0
|
648 |
!
|
|
649 |
|
12
|
650 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle
|
|
651 |
"draw an arc in a box"
|
0
|
652 |
|
|
653 |
|left top right bot|
|
|
654 |
|
|
655 |
left := origin x.
|
|
656 |
top := origin y.
|
|
657 |
right := corner x.
|
|
658 |
bot := corner y.
|
12
|
659 |
self displayArcX:left y:top
|
|
660 |
w:(right - left + 1) h:(bot - top + 1)
|
|
661 |
from:startAngle angle:angle
|
0
|
662 |
!
|
|
663 |
|
12
|
664 |
displayCircleIn:aRectangle
|
0
|
665 |
"draw a circle in a box"
|
|
666 |
|
|
667 |
self
|
12
|
668 |
displayArcX:(aRectangle left)
|
|
669 |
y:(aRectangle top)
|
|
670 |
w:(aRectangle width)
|
|
671 |
h:(aRectangle height)
|
|
672 |
from:0 angle:360
|
0
|
673 |
!
|
|
674 |
|
12
|
675 |
displayCircle:aPoint radius:r
|
|
676 |
"draw a circle around a center point"
|
0
|
677 |
|
12
|
678 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r
|
0
|
679 |
!
|
|
680 |
|
12
|
681 |
displayCircleX:x y:y radius:r
|
|
682 |
"draw a circle around a center point"
|
0
|
683 |
|
|
684 |
|d|
|
|
685 |
d := 2 * r.
|
12
|
686 |
self displayArcX:(x - r) y:(y - r)
|
|
687 |
w:d h:d
|
|
688 |
from:0 angle:360
|
0
|
689 |
! !
|