Rects are generally represented as a left, top, right and bottom
coordinate. However there are other methods of representing them
that may be more useful depending on the information you have at
hand.
For instance you may know the top left position, the width and
the height of your Rect. To turn this into a Rect you would have to
work out the bottom right corner by adding the width and height
onto the top left position.
Or you may know the top left and bottom right positions but want
to move the Rect down and across by a few pixels. Or again you may
know the top left position and just want the rest of the rectangle
to fill whatever is left of the Canvas.
You can work out all of these quite easily but to save you time
a number of facilities exist to work out what you want
automatically from the information you provide.
You can specify a Rect in a number of other ways. For instance
you can specify:
- A Position (top left).
- A Size (width and height).
- A Move (shift the supplied Rect
horizontally and vertically).
- An Inset (shrink the rectangle by
a number of pixels).
If no information is provided the Rect is assumed to fill the
Canvas. If only a position is provided the Rect is assumed to be
offset by this position. If only a size is provided we assume the
position is at 0,0.
|