def drectangle(p, x1, x2, y1, y2):
    """Signed distance function for rectangle with corners (x1,y1), (x2,y1),
    (x1,y2), (x2,y2).

    This has an incorrect distance to the four corners. See drectangle0 for a
    true distance function.
    """
    return -min(min(min(-y1 + p[:, (1)], y2 - p[:, (1)]), -x1 + p[:, (0)]),
        x2 - p[:, (0)])
