As well as specifying Points on your Canvas you often need to specify areas. One of the most common constructs is a Rectangle.

You can use a rectangle to specify an area of the Canvas. For instance:

  • To specify an area into which to draw text.
  • Or an area into which to draw a picture.
  • Or to find out the area of a Canvas that a specific piece of text would take up.

A rectangle is described by two Points - the top left corner of the rectangle and the bottom right of the rectangle. Often these are just referred to as the left, top, right and bottom coordinates of the rectangle.

If the top left of the rectangle is the same as the bottom right (or if the top left is below or to the right of the bottom right) this is referred to as an Empty rectangle.