area
"Answer the receiver's area, the product of width and height."
| w |
(w := self width) <= 0 ifTrue: [ ^ 0 ].
^ w * self height max: 0
what i found that rectangles don't like if corner point having
coordinates (either x or y)
which is below the origin.
many places in code (and especially in morphic) assuming that for any rectangle:
rect origin >= rect corner.
On 6 April 2011 13:51, Andre Hora <[email protected]> wrote:
> Hello,
>
> VW:
> (Rectangle origin: (0@0) corner: (10@10)) area. 100
> (Rectangle origin: (0@10) corner: (10@0)) area. -100
> (Rectangle origin: (10@10) corner: (0@0)) area. 100
> (Rectangle origin: (10@0) corner: (0@10)) area. -100
>
> Pharo:
> (Rectangle origin: (0@0) corner: (10@10)) area. 100
> (Rectangle origin: (0@10) corner: (10@0)) area. 0
> (Rectangle origin: (10@10) corner: (0@0)) area. 0
> (Rectangle origin: (10@0) corner: (0@10)) area. 0
>
> On Wed, Apr 6, 2011 at 1:05 PM, Stéphane Ducasse <[email protected]>
> wrote:
>>
>> Give us the code!
>> In VW and Pharo side by side and their results
>>
>> Stef
>>
>> On Apr 6, 2011, at 10:31 AM, Andre Hora wrote:
>>
>> > Hello,
>> >
>> > To create a Rectangle in Pharo with the method
>> > Rectangle>>origin:corner:, you must provide the top left and the bottom
>> > right points. With others you have a Rectangle with area equals to zero.
>> > I just noticed that in VW it is possible create a Rectangle with other
>> > points (bottom right and top left, bottom left and top right, ...).
>> > So, shouldn't Pharo Rectangle allow the same?
>> >
>> > regards,
>> >
>> > --
>> > Andre Hora
>> >
>>
>>
>
>
>
> --
> Andre Hora
>
>
--
Best regards,
Igor Stasenko AKA sig.