def render_callout_info()

in web-app-pix2info-python/src/backend/render.py [0:0]


def render_callout_info(demo: Demo) -> ImageIterator:
    for vertices, text, r, text_xy, bg_color, fg_color in callout_info(demo):
        if vertices is not None:
            if demo.rendering:
                # Draw the reference item
                render_vertices(demo, vertices, fg_color)
                demo.draw.polygon(vertices, outline=fg_color, width=2)
            yield from show_if_animated(demo)

            # Highlight the path from the item to its callout
            if demo.rendering:
                path_xy = (vertices[1], (r[0], r[1]), (r[0], r[3]), vertices[2])
                render_vertices(demo, path_xy, fg_color)
            yield from show_if_animated(demo)

        # Draw the callout
        if demo.rendering:
            demo.draw.rectangle(r, fill=bg_color, outline=fg_color, width=2)
            demo.draw.text(
                text_xy, text, fill=DEFAULT_TEXT_COLOR, font=demo.font_median
            )
        yield from show_if_animated(demo)