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

Function draw_leaf

experiments/human_eval/draw_llm_token_cost_tree.py:100–118  ·  view source on GitHub ↗
(
    draw: ImageDraw.ImageDraw,
    y: float,
    name: str,
    value: int,
    color: tuple[int, int, int],
    highlight: bool = False,
)

Source from the content-addressed store, hash-verified

98
99
100def draw_leaf(
101 draw: ImageDraw.ImageDraw,
102 y: float,
103 name: str,
104 value: int,
105 color: tuple[int, int, int],
106 highlight: bool = False,
107) -> None:
108 label_color = PAPERFLOW if highlight else TEXT
109 draw.text((LEAF_X, y - 14), name, font=F_MODEL, fill=label_color)
110
111 bar_x = VALUE_X - MAX_BAR_W - 20
112 bar_y = y - 9
113 bar_w = round((value / MAX_VALUE) * MAX_BAR_W)
114 draw.rounded_rectangle((bar_x, bar_y, bar_x + MAX_BAR_W, bar_y + 18), radius=5, fill=BAR_BG)
115 draw.rounded_rectangle((bar_x, bar_y, bar_x + bar_w, bar_y + 18), radius=5, fill=color)
116
117 value_text = f"{value / 1_000_000:.1f}M"
118 draw.text((VALUE_X, y - 13), value_text, font=F_VALUE, fill=color)
119
120
121def draw_branch(

Callers 1

draw_pngFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected