def rounded_box_path(context, radii):
    """Draw the path of the border radius box.

    ``widths`` is a tuple of the inner widths (top, right, bottom, left) from
    the border box. Radii are adjusted from these values. Default is (0, 0, 0,
    0).

    Inspired by Cairo Cookbook
    http://cairographics.org/cookbook/roundedrectangles/

    """
    x, y, w, h, tl, tr, br, bl = radii

    if 0 in tl:
        tl = (0, 0)
    if 0 in tr:
        tr = (0, 0)
    if 0 in br:
        br = (0, 0)
    if 0 in bl:
        bl = (0, 0)

    if (tl, tr, br, bl) == 4 * ((0, 0),):
        # No radius, draw a rectangle
        context.rectangle(x, y, w, h)
        return

    context.move_to(x, y)
    for i, (w, h, (rx, ry)) in enumerate((
            (0, 0, tl), (w, 0, tr), (w, h, br), (0, h, bl))):
        context.save()
        context.translate(x + w, y + h)
        radius = max(rx, ry)
        if radius:
            context.scale(min(rx / ry, 1), min(ry / rx, 1))
        context.arc(
            (-1 if w else 1) * radius, (-1 if h else 1) * radius, radius,
            (2 + i) * math.pi / 2, (3 + i) * math.pi / 2)
        context.restore()
dataset/ETHPy150Open Kozea/WeasyPrint/weasyprint/draw.py/rounded_box_path/original