| 77 | |
| 78 | |
| 79 | def 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 | |
| 100 | def draw_leaf( |