def rect_overlap(r1, r2):
    """Return the area of the intersection of two rectangles.

    Args:
        r1: an object with attributes left, top, width, height
        r2: an object with attributes left, top, width, height
    Returns:
        float
    """
    left = float(max(r1.left, r2.left))
    right = float(min(r1.left + r1.width, r2.left + r2.width))
    top = float(max(r1.top, r2.top))
    bottom = float(min(r1.top + r1.height, r2.top + r2.height))
    if left >= right or top >= bottom:
        return 0.
    return (right - left) * (bottom - top)