[Newbies] (no subject)
Ralph Boland
rpboland at gmail.com
Sat May 27 15:56:05 UTC 2017
>> I just attempted to draw a rectangle with dimensions 3 at 3 corner: 9 at 3.
>> Nothing gets drawn. The reason that nothing is drawn is that the width of
>> the rectangle is 0. This makes sense for real numbers but for a pixelated
>> screen or other display medium the dimensions of the rectangle
>> should be 1 x 7 not 0 x 6!?. This is 7 pixels needed to draw, not 0.
>>
>> The same issues occur for the height of the rectangles.
>>
>> I would think that the way things work would cause all kinds of problems
>> but since Rectangles are pretty basic, either I am wrong,
>> or every bit of Squeak code using rectangles has adjusted accordingly.
>>
>> Please clarify.
>>
> The coordinates refer to the imaginary lines between pixels. Thus, if you
> draw a rectangle from x=4 to x=5 its width is 1. This is so that if you
> draw multiple rectangles, they do not overlap (imagine drawing from 5 to 12
> and from 12 to 19).
But I would expect these rectangles to overlap just like I would expect the
intervals (3 to: 5) and (5 to: 7) to overlap; and they do (the intervals).
But of course we are doing computer graphics here, not mathematics.
In the next couple of days I will write code to draw a line segment and see
what happens. My guess is that if I draw a line from 3 @ 3 to 3 @ 5
only two pixels will be changed (analogous to how Rectangle works)
and not three (my intuition prior to this conversation).
> How do Java and other languages handle this?
>
Same. There's a nice illustration on this page:
http://math.hws.edu/~bridgeman/courses/124/f13/doc/paint/paint.html
Regardless of my protestations on the right way to do this I must obviously
conform to convention.
Thanks for the clarification.
Ralph Boland
More information about the Beginners
mailing list