MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / centered_node

Function centered_node

experiments/human_eval/draw_llm_token_cost_tree.py:79–97  ·  view source on GitHub ↗
(
    draw: ImageDraw.ImageDraw,
    x: float,
    y: float,
    text: str,
    font: ImageFont.FreeTypeFont,
    fill: tuple[int, int, int],
)

Source from the content-addressed store, hash-verified

77
78
79def centered_node(
80 draw: ImageDraw.ImageDraw,
81 x: float,
82 y: float,
83 text: str,
84 font: ImageFont.FreeTypeFont,
85 fill: tuple[int, int, int],
86) -> tuple[int, int, int, int]:
87 tw, th = text_size(draw, text, font)
88 pad_x, pad_y = 18, 8
89 box = (
90 round(x - tw / 2 - pad_x),
91 round(y - th / 2 - pad_y),
92 round(x + tw / 2 + pad_x),
93 round(y + th / 2 + pad_y),
94 )
95 draw.rounded_rectangle(box, radius=8, outline=fill, width=2, fill="white")
96 draw.text((x - tw / 2, y - th / 2 - 1), text, font=font, fill=fill)
97 return box
98
99
100def draw_leaf(

Callers 1

draw_pngFunction · 0.85

Calls 1

text_sizeFunction · 0.70

Tested by

no test coverage detected