Pharo 5.0

It seems like a bug to me, but perhaps I misunderstand something.

1) Comment in Rectangle class >> origin:corner: method shows 'origin'
should be top left and 'corner' should be bottom right. This method calls
Rectangle >> setPoint:point:. But this method calculates 'origin' to be
bottom left corner and 'corner' to be top right. Now all the edge and
corner methods are wrong.

r := Rectangle origin: 0@0 corner: 10@10.
r topLeft.  => (0@0)   "should be 0@10"
r bottomRight.  => (10@10)  "should be 10@0"
r top.  => 0  "should be 10"
r bottom.  => 10  " should be 0"


2) Why Polygon >> bounds (which is PathShape >> bounds) returns a rectangle
with a corner 1 point larger than the actual boundary?

p1 := Polygon vertices: {0@0 . 0@10 . 10@10 . 10@0}.
p1 bounds.  => (0@0) corner: (11@11).  "should be 0@0 and 10@10"

This seems to be a fix to Rectangle >> containsPoint: strange behavior. By
strange behavior, I mean:

r := Rectangle point: 0@0 point: 10@10.
r containsPoint: 0@0.  => true
r containsPoint: 10@10.  => false  "should be true"
{ r topLeft . r topRight . r bottomLeft . r bottomRight } allSatisfy [
:corner | r containsPoint: corner ].  => false  "should be true"


I want to fix this in my image, but Rectangle is used all over the place
and I'm worry I'll break a lot of things. I wonder if I just misunderstood
how these are supposed to be used. Can anybody help me understand if this
is intentional or a bug?

PS: I looked at RectangleTest and I'm not sure I understand why they are
testing what they are testing.

--
Andreas Sunardi

Reply via email to