def rectarea(r, incborder=1):
    """Returns the area of the given ``(x0, y0, x1, y1)`` rect.
    If `incborder` is true (default) then includes that in calc. Otherwise doesn't.
    If either width or height is not positive, returns 0."""
    w = r[2]-r[0] + incborder
    h = r[3]-r[1] + incborder
    if w <= 0 or h <= 0: return 0
    return w * h