Rotation of a rectangle occurs about a centroid which is defined as the center of the rectangle, or more formally as (x+w/2, y+h/2).
The following contains an example that will add a rectangle with a border to a canvas. The blue lines represent the x and y axes, and show through since an alpha value of 0.9 is used.
Rectangle drawn by example code below