def rectangle(c, w, h, angle=0, center=True):
    '\n    create rotated rectangle\n    for input into PIL ImageDraw.polygon\n    to make a rectangle polygon mask\n\n    Rectagle is created and rotated with center\n    at zero, and then translated to center position\n\n    accepters centers\n    Default : center\n    tl, tr, bl, br\n    '
    (cx, cy) = c
    x = (((- w) / 2.0), ((+ w) / 2.0), ((+ w) / 2.0), ((- w) / 2.0))
    y = (((+ h) / 2.0), ((+ h) / 2.0), ((- h) / 2.0), ((- h) / 2.0))
    if (center is not True):
        if (center[0] == 'b'):
            cy = (cy + (h / 2.0))
        else:
            cy = (cy - (h / 2.0))
        if (center[1] == 'l'):
            cx = (cx + (w / 2.0))
        else:
            cx = (cx - (w / 2.0))
    R = rot_matrix(((angle * np.pi) / 180.0))
    c = []
    for i in range(4):
        (xr, yr) = np.dot(R, np.asarray([x[i], y[i]])).A.ravel()
        c.append(((cx + xr), (cy + yr)))
    return c
create rotated rectangle
for input into PIL ImageDraw.polygon
to make a rectangle polygon mask

Rectagle is created and rotated with center
at zero, and then translated to center position

accepters centers
Default : center
tl, tr, bl, br
def rectangle(c, w, h, angle=0, center=True):
    '\n    create rotated rectangle\n    for input into PIL ImageDraw.polygon\n    to make a rectangle polygon mask\n\n    Rectagle is created and rotated with center\n    at zero, and then translated to center position\n\n    accepters centers\n    Default : center\n    tl, tr, bl, br\n    '
    (cx, cy) = c
    x = (((- w) / 2.0), ((+ w) / 2.0), ((+ w) / 2.0), ((- w) / 2.0))
    y = (((+ h) / 2.0), ((+ h) / 2.0), ((- h) / 2.0), ((- h) / 2.0))
    if (center is not True):
        if (center[0] == 'b'):
            cy = (cy + (h / 2.0))
        else:
            cy = (cy - (h / 2.0))
        if (center[1] == 'l'):
            cx = (cx + (w / 2.0))
        else:
            cx = (cx - (w / 2.0))
    R = rot_matrix(((angle * np.pi) / 180.0))
    c = []
    for i in range(4):
        (xr, yr) = np.dot(R, np.asarray([x[i], y[i]])).A.ravel()
        c.append(((cx + xr), (cy + yr)))
    return c