-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize.py
More file actions
33 lines (27 loc) · 877 Bytes
/
visualize.py
File metadata and controls
33 lines (27 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# visualize.py
from matplotlib.patches import Rectangle as PatchRectangle
def draw_rect(ax, rect, color):
patch = PatchRectangle(
(rect.x, rect.y),
rect.width,
rect.height,
linewidth=1,
edgecolor="black",
facecolor=color,
alpha=0.6
)
ax.add_patch(patch)
def visualize_layout(buildings, plaza, ax, site_width=200, site_height=140):
ax.clear()
ax.set_xlim(0, site_width)
ax.set_ylim(0, site_height)
if plaza:
draw_rect(ax, plaza, "lightgreen")
for b in buildings:
color = "skyblue" if b["type"] == "A" else "orange"
draw_rect(ax, b["rect"], color)
cx = b["rect"].x + b["rect"].width / 2
cy = b["rect"].y + b["rect"].height / 2
ax.text(cx, cy, b["type"], ha="center", va="center", fontsize=9)
ax.set_aspect("equal")
ax.grid(True)