Bug in Rectangle>>containsPoint:?

Alan C. Kay alank at wdi.disney.com
Sat Apr 25 13:31:10 UTC 1998


Tim --

I think you are right. You know, when Bill Atkinson did QuickDraw for the Mac, he came up with a useful insight: to have the coordinates be zero width and be located between the pixels, instead of being on the pixels. This has many felicitous properties and perhaps someday we should convert over to this convention for Squeak ....

Cheers,

Alan

-----

At 8:03 AM -0500 4/25/98, Tim Olson wrote:
>Hi, Chris:
>
>>I seem to have found a bug in Rectangle.  In the method 
>>
>>containsPoint: aPoint 
>>	       "Answer whether aPoint is within the receiver."
>>	       ^origin <= aPoint and: [aPoint < corner]
>>                                             ^^^
>>
>>the second comparison is a "<".  I think it should be a "<=" instead.
>
>I think the definition as it exists is correct (or at least internally 
>correct and consistent as used in Squeak).  It's not explicitly stated 
>anywhere, but a Rectangle consists of the set of points bounded by its 
>origin and its corner, up to but not including the points on the corner's 
>edges (right and bottom edges).
>
>This is because rectangles are frequently tiled, and if the exclusion 
>didn't exist, there would be certain points that would be members of 
>ajoining Rectangles, instead of belonging solely to one or the other.  
>However, exclusion is fundamental to things like mouse hit detection, 
>view layout, etc.
>
>Think of it this way:  if you are told to paint a rectangle on a tiled 
>floor, starting in the corner (corner: 0 at 0) and going for one tile's 
>length in both directions (extent: 1 at 1), you would end up with a single 
>tile painted, and would respond "no" to the question of whether the tile 
>at 1 at 1 was painted.
>
>
>
>     -- tim





More information about the Squeak-dev mailing list