264 p displayStrokedOn:v. |
264 p displayStrokedOn:v. |
265 [exEnd] |
265 [exEnd] |
266 " |
266 " |
267 ! ! |
267 ! ! |
268 |
268 |
|
269 !Geometric class methodsFor:'initialization'! |
|
270 |
|
271 initialize |
|
272 "setup class constants" |
|
273 |
|
274 "/ these are note used in ST/X; |
|
275 "/ (acc. to a testers note, ST-80 internally uses |
|
276 "/ integer valued coordinates, scaling coordinates by |
|
277 "/ the Scale constant. ST/X does not do this. However, |
|
278 "/ user suppied subclasses may depend on those values being |
|
279 "/ present ...) |
|
280 |
|
281 Scale := 4096. |
|
282 InverseScale := 1.0 / Scale |
|
283 |
|
284 " |
|
285 Geometric initialize |
|
286 " |
|
287 |
|
288 "Modified: 12.2.1997 / 13:11:31 / cg" |
|
289 ! ! |
|
290 |
|
291 !Geometric class methodsFor:'helper functions'! |
|
292 |
|
293 boundingRectangleForPoints:aSequencableCollectionOfPoints |
|
294 "given a bunch of point, compute the boundingRectangle |
|
295 (i.e. the smallest rectangle which encloses all of those points)" |
|
296 |
|
297 |p minX minY maxX maxY n "{ Class: SmallInteger }" |
|
298 x y | |
|
299 |
|
300 p := aSequencableCollectionOfPoints first. |
|
301 minX := maxX := p x. |
|
302 minY := maxY := p y. |
|
303 |
|
304 n := aSequencableCollectionOfPoints size. |
|
305 1 to:n do:[:idx | |
|
306 p := aSequencableCollectionOfPoints at:idx. |
|
307 x := p x. |
|
308 y := p y. |
|
309 x < minX ifTrue:[ |
|
310 minX := x |
|
311 ] ifFalse:[ |
|
312 x > maxX ifTrue:[ |
|
313 maxX := x |
|
314 ] |
|
315 ]. |
|
316 y < minY ifTrue:[ |
|
317 minY := y |
|
318 ] ifFalse:[ |
|
319 y > maxY ifTrue:[ |
|
320 maxY := y |
|
321 ] |
|
322 ]. |
|
323 ]. |
|
324 |
|
325 ^ Rectangle left:minX top:minY right:maxX bottom:maxY |
|
326 |
|
327 "Modified: 12.2.1997 / 12:10:12 / cg" |
|
328 ! ! |
|
329 |
269 !Geometric methodsFor:'converting'! |
330 !Geometric methodsFor:'converting'! |
270 |
331 |
271 asFiller |
332 asFiller |
272 "return a wrapper which displays the receiver in its filled form" |
333 "return a wrapper which displays the receiver in its filled form" |
273 |
334 |
274 ^ FillingWrapper on:self |
335 self canBeFilled ifTrue:[ |
275 |
336 ^ FillingWrapper on:self |
276 "Created: 8.5.1996 / 14:38:59 / cg" |
337 ]. |
277 "Modified: 8.5.1996 / 18:22:56 / cg" |
338 ^ self shouldNotImplement |
|
339 |
|
340 "Modified: 12.2.1997 / 11:47:22 / cg" |
278 ! |
341 ! |
279 |
342 |
280 asRectangle |
343 asRectangle |
281 "return the enclosing rectangle; same as #bounds" |
344 "return the enclosing rectangle; same as #bounds" |
282 |
345 |
332 ! ! |
395 ! ! |
333 |
396 |
334 !Geometric methodsFor:'queries'! |
397 !Geometric methodsFor:'queries'! |
335 |
398 |
336 bounds |
399 bounds |
337 "return the smallest enclosing rectangle" |
400 "return the smallest enclosing rectangle. |
338 |
401 This resends computeBounds, to allow caching of bounds in |
339 ^ self subclassResponsibility |
402 case this computation is expensive." |
|
403 |
|
404 ^ self computeBounds |
340 |
405 |
341 "Created: 8.5.1996 / 13:56:08 / cg" |
406 "Created: 8.5.1996 / 13:56:08 / cg" |
342 "Modified: 8.5.1996 / 14:06:31 / cg" |
407 "Modified: 12.2.1997 / 11:41:38 / cg" |
343 ! |
408 ! |
344 |
409 |
345 canBeFilled |
410 canBeFilled |
346 "return true, if the receiver can be drawn as a filled geometric. |
411 "return true, if the receiver can be drawn as a filled geometric. |
347 Return false here, since we dont know." |
412 Return false here, since we dont know." |
348 |
413 |
349 ^ false |
414 ^ false |
350 |
415 |
351 "Created: 1.6.1996 / 11:28:58 / cg" |
416 "Created: 1.6.1996 / 11:28:58 / cg" |
|
417 ! |
|
418 |
|
419 computeBounds |
|
420 "return the smallest enclosing rectangle." |
|
421 |
|
422 ^ self subclassResponsibility |
|
423 |
|
424 "Created: 12.2.1997 / 11:41:58 / cg" |
352 ! |
425 ! |
353 |
426 |
354 outlineIntersects:aRectangle |
427 outlineIntersects:aRectangle |
355 "return true, if the receivers image intersects |
428 "return true, if the receivers image intersects |
356 aRectangle, when drawn as an outline. |
429 aRectangle, when drawn as an outline. |