missing borders

Ned Konz ned at bike-nomad.com
Wed Apr 11 19:31:05 UTC 2001


On Wednesday 11 April 2001 12:11, montgomery f. tidwell wrote:
> Howdy,
>
> when i create an XYZ morph (see below) none of the borders are
> displayed. if i pick it up and move it, then the top and left
> borders are displayed, but not the right or bottom. all of
> the borders show up if i cover the morph with something else
> and then uncover it. why?

because you're drawing outside your Morph's bounds.

self bounds bottomRight is the pixel just outside your actual bounds.

Imagine your Morph being 4 pixels wide, located at 0 at 0. Then your bounds 
would be 0 at 0 corner: 4 at 4. But since your extent is 4 at 4, this only includes 
the pixels from 0 at 0 to 3 at 3.

> drawOn: aCanvas
>
>  	aCanvas fillRectangle: (self bounds insetBy: borderWidth) fillStyle:
> self fillStyle.
> 	aCanvas line: (self bounds topLeft) to: (self bounds topRight) color:
> Color white.
> 	aCanvas line: (self bounds topLeft) to: (self bounds bottomLeft) color:
> Color yellow.
> 	aCanvas line: (self bounds bottomLeft) to: (self bounds bottomRight)
> color: Color red.
> 	aCanvas line: (self bounds bottomRight) to: (self bounds topRight)
> color: Color blue.
> ! !

Should be more like (untested):

drawOn: aCanvas
 	| innerBounds |
	innerBounds _ Rectangle origin: bounds origin extent: bounds extent - (1 at 1).
        aCanvas fillRectangle: (self bounds insetBy: borderWidth) fillStyle:
 self fillStyle.
         aCanvas line: (innerBounds topLeft) to: (innerBounds topRight) color:
 Color white.
         aCanvas line: (innerBounds topLeft) to: (innerBounds bottomLeft) 
color:
 Color yellow.
         aCanvas line: (innerBounds bottomLeft) to: (innerBounds bottomRight)
 color: Color red.
         aCanvas line: (innerBounds bottomRight) to: (innerBounds topRight)
 color: Color blue.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list