Room floor plan: seen from above with forward (-Z) at the top; it had +Z at the top with +X still on the right, i.e. the room mirrored

This commit is contained in:
spoopyghosty0 committed 2026-10-18 20:28:38 -04:00
1 parent 24e9ca3cb5
commit 4f871b2033
2 files changed
+11 -2

No files matched your search

+2 -2
View File
@@ -284,8 +284,8 @@ def preview_svg(room: Room) -> str:
xmin, xmax = min(x for x, _ in points), max(x for x, _ in points)
zmin, zmax = min(z for _, z in points), max(z for _, z in points)
scale = 440 / max(xmax-xmin, zmax-zmin, .1)
def point(x, z):
return f"{30+(x-xmin)*scale:.2f},{30+(zmax-z)*scale:.2f}"
def point(x, z): # seen from above: +X right, forward (-Z) at the top (+Z at the top would mirror the room)
return f"{30+(x-xmin)*scale:.2f},{30+(z-zmin)*scale:.2f}"
def polygon(poly):
return " ".join(point(x, z) for x, z in poly)
out = ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500" role="img">',
+9
View File
@@ -90,3 +90,12 @@ def test_clockwise_outline_and_wall_directions_are_repaired():
got = parse(dumps(r))
edges = list(zip(got.outline, got.outline[1:] + got.outline[:1], strict=True))
assert all(((w.x0, w.z0), (w.x1, w.z1)) in edges for w in got.walls)
def test_preview_is_seen_from_above_with_forward_at_the_top():
# a table in front of the play area (-Z) on the right (+X) must be drawn top right, not mirrored to bottom right
r = box_room(4, 4, 2.5)
r.volumes.append(Volume("a"*32, "TABLE", 1.5, -1.5, .8, 0, .5, .5, .8))
root = ET.fromstring(preview_svg(r))
label = next(e for e in root.iter() if e.text == "TABLE")
assert float(label.get("x")) > 250 and float(label.get("y")) < 250