missing borders

Bob Arning arning at charm.net
Wed Apr 11 19:46:01 UTC 2001


On Wed, 11 Apr 2001 12:11:03 -0700 "montgomery f. tidwell" <mtidwell at practicalmatters.com> wrote:
>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?

The pixels whose x value is "bounds right" or whose y value is "bounds bottom" are not within the bounds of your morph. Imagine a morph with bounds (0 at 0 extent: 2 at 2). The width and height are both 2 and the points that lie within the bounds are 0 at 0, 0 at 1, 1 at 0 and 1 at 1. To draw the bottom or right edge, you need to subtract 1 from the coordinate value. This works:

drawOn: aCanvas

 	aCanvas fillRectangle: (bounds insetBy: borderWidth) fillStyle: self fillStyle.
	aCanvas 
		line: bounds topLeft to: bounds topRight - (1 at 0) color: Color white;
		line: bounds topLeft to: bounds bottomLeft - (0 at 1) color: Color yellow;
		line: bounds bottomLeft - (0 at 1) to: bounds bottomRight - (1 at 1) color: Color red;
		line: bounds bottomRight - (1 at 1) to: bounds topRight - (1 at 0) color: Color blue.

The reason you didn't see the lines normally was that the clipping rectangle was set to the bounds of the morph and any drawing you did outside those bounds was ignored.

The reason you saw the lines when you covered it with something else and then uncovered it was that  the screen refresh logic had set the clipping rectangle to the larger damage rectangle and the lines you drew were included in the refresh of the screen.

Cheers,
Bob





More information about the Squeak-dev mailing list