Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -108,16 +108,6 @@ if st.session_state["layout_image"] is None:
|
|
108 |
st.session_state["layout_image"] = layout_image
|
109 |
st.session_state["canvas"] = canvas
|
110 |
|
111 |
-
# Display map with scroll and zoom controls
|
112 |
-
if st.session_state["layout_image"] is not None:
|
113 |
-
st.image(
|
114 |
-
st.session_state["layout_image"],
|
115 |
-
caption="Generated Dungeon Map Layout",
|
116 |
-
use_container_width=True,
|
117 |
-
output_format="PNG",
|
118 |
-
clamp=True,
|
119 |
-
)
|
120 |
-
|
121 |
# Sidebar Controls
|
122 |
st.sidebar.title("Map Controls")
|
123 |
if st.sidebar.button("💾 Save Map"):
|
@@ -134,14 +124,29 @@ if st.sidebar.button("🗺️ Regenerate Map"):
|
|
134 |
st.session_state["canvas"] = canvas
|
135 |
st.rerun()
|
136 |
|
137 |
-
# Zoom
|
138 |
st.sidebar.title("Zoom")
|
|
|
139 |
zoom_level = st.sidebar.slider("Zoom Level", min_value=0.5, max_value=2.0, value=1.0, step=0.1)
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
st.session_state["layout_image"] = layout_image
|
109 |
st.session_state["canvas"] = canvas
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
# Sidebar Controls
|
112 |
st.sidebar.title("Map Controls")
|
113 |
if st.sidebar.button("💾 Save Map"):
|
|
|
124 |
st.session_state["canvas"] = canvas
|
125 |
st.rerun()
|
126 |
|
127 |
+
# Zoom Controls
|
128 |
st.sidebar.title("Zoom")
|
129 |
+
show_zoomed = st.sidebar.checkbox("Show Zoomed Version")
|
130 |
zoom_level = st.sidebar.slider("Zoom Level", min_value=0.5, max_value=2.0, value=1.0, step=0.1)
|
131 |
+
|
132 |
+
if show_zoomed and st.session_state["canvas"] is not None:
|
133 |
+
zoomed_canvas = st.session_state["canvas"].resize(
|
134 |
+
(int(canvas_size * zoom_level), int(canvas_size * zoom_level)),
|
135 |
+
resample=Image.Resampling.LANCZOS,
|
136 |
+
)
|
137 |
+
buffer = BytesIO()
|
138 |
+
zoomed_canvas.save(buffer, format="PNG")
|
139 |
+
buffer.seek(0)
|
140 |
+
st.image(
|
141 |
+
buffer,
|
142 |
+
caption=f"Zoomed Dungeon Map Layout (Zoom Level: {zoom_level}x)",
|
143 |
+
use_container_width=False,
|
144 |
+
output_format="PNG",
|
145 |
+
)
|
146 |
+
else:
|
147 |
+
st.image(
|
148 |
+
st.session_state["layout_image"],
|
149 |
+
caption="Generated Dungeon Map Layout",
|
150 |
+
use_container_width=True,
|
151 |
+
output_format="PNG",
|
152 |
+
)
|