G
Guest
I am having a hard time understanding the logic behind the Rectangle object.
My problem has to do with the way the rectangle treats the "Width" property.
For example, take the following rectangle object.
Rectangle myRec = new Rectangle(0, 0, 2, 2);
If you draw this rectangle on the screen you will end up with a rectangle
like the one shown below (The character "X" represents a pixel used to draw
the rectangle and the character "O" is an untouched pixel):
XXX
XOX
XXX
Take a close look at that rectangle. I in my head, this rectangle is not 2
pixels width, for me, this rectangle is actually 3 pixels width. So here is
my first question. Do you agree with me that this rectangle is really 3
pixels with and not 2?
Things get more confusing when you try to draw something inside the
rectangle using a function such as DrawIcon() or FillRectangle(). For
example if you use the FillRectangle() function and pass it the rectangle
object created above the program will draw the following filled rectangle
(The character "X" represents a pixel used to draw the filled rectangle and
the character "O" is an untouched pixel):
XXO
XXO
OOO
Although my rectangle was 3 pixels width, the function is ignoring the right
and bottom edge of the rectangle area. Is there any logic behind this
behavior?
Thanks.
My problem has to do with the way the rectangle treats the "Width" property.
For example, take the following rectangle object.
Rectangle myRec = new Rectangle(0, 0, 2, 2);
If you draw this rectangle on the screen you will end up with a rectangle
like the one shown below (The character "X" represents a pixel used to draw
the rectangle and the character "O" is an untouched pixel):
XXX
XOX
XXX
Take a close look at that rectangle. I in my head, this rectangle is not 2
pixels width, for me, this rectangle is actually 3 pixels width. So here is
my first question. Do you agree with me that this rectangle is really 3
pixels with and not 2?
Things get more confusing when you try to draw something inside the
rectangle using a function such as DrawIcon() or FillRectangle(). For
example if you use the FillRectangle() function and pass it the rectangle
object created above the program will draw the following filled rectangle
(The character "X" represents a pixel used to draw the filled rectangle and
the character "O" is an untouched pixel):
XXO
XXO
OOO
Although my rectangle was 3 pixels width, the function is ignoring the right
and bottom edge of the rectangle area. Is there any logic behind this
behavior?
Thanks.