Spaces:
Running
Running
Scope graphics
Browse files- battlewords/scope.gif +0 -0
- battlewords/scope_blue.gif +0 -0
- battlewords/scope_blue.png +0 -0
- battlewords/ui.py +16 -6
battlewords/scope.gif
ADDED
|
battlewords/scope_blue.gif
ADDED
|
battlewords/scope_blue.png
ADDED
|
battlewords/ui.py
CHANGED
|
@@ -296,6 +296,14 @@ def _render_sidebar():
|
|
| 296 |
_sort_wordlist(st.session_state.selected_wordlist)
|
| 297 |
else:
|
| 298 |
st.info("No word lists found in words/ directory. Using built-in fallback.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
def _create_radar_scope(size=4, bgcolor="none", scope_color="green"):
|
| 301 |
fig, ax = plt.subplots(figsize=(size, size), dpi=100)
|
|
@@ -368,18 +376,20 @@ def _render_radar(puzzle: Puzzle, size: int, r_max: float = 0.85, max_frames: in
|
|
| 368 |
|
| 369 |
rgba_labels = mcolors.to_rgba("#FFFFFF", 0.7)
|
| 370 |
rgba_ticks = mcolors.to_rgba("#FFFFFF", 0.66)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
plt.close(fig)
|
| 375 |
-
fig, ax = plt.subplots(figsize=(3, 3))
|
| 376 |
ax.set_xlim(0.2, size)
|
| 377 |
ax.set_ylim(size, 0.2)
|
| 378 |
ax.set_xticks(range(1, size + 1))
|
| 379 |
ax.set_yticks(range(1, size + 1))
|
| 380 |
ax.tick_params(axis="both", which="both", labelcolor=rgba_labels)
|
| 381 |
ax.tick_params(axis="both", which="both", colors=rgba_ticks)
|
| 382 |
-
ax.grid(True, which="both", linestyle="--", alpha=0.3)
|
| 383 |
# ax.set_title("Radar")
|
| 384 |
ax.set_aspect('equal', adjustable='box')
|
| 385 |
|
|
@@ -423,7 +433,7 @@ def _render_radar(puzzle: Puzzle, size: int, r_max: float = 0.85, max_frames: in
|
|
| 423 |
bg_ax.axis('off')
|
| 424 |
|
| 425 |
# Overlay the radar scope image centered in the main axes
|
| 426 |
-
scope_ax = fig.add_axes([-0.075, -0.075, 1.15, 1.15], zorder=1)
|
| 427 |
scope_ax.imshow(imgscope, aspect='auto', interpolation='lanczos')
|
| 428 |
scope_ax.axis('off')
|
| 429 |
|
|
|
|
| 296 |
_sort_wordlist(st.session_state.selected_wordlist)
|
| 297 |
else:
|
| 298 |
st.info("No word lists found in words/ directory. Using built-in fallback.")
|
| 299 |
+
def get_scope_image(size=4, bgcolor="none", scope_color="green", img_name="scope.gif"):
|
| 300 |
+
scope_path = os.path.join(os.path.dirname(__file__), img_name)
|
| 301 |
+
if not os.path.exists(scope_path):
|
| 302 |
+
fig, ax = _create_radar_scope(size=size, bgcolor=bgcolor, scope_color=scope_color)
|
| 303 |
+
imgscope = fig_to_pil_rgba(fig)
|
| 304 |
+
imgscope.save(scope_path)
|
| 305 |
+
plt.close(fig)
|
| 306 |
+
return Image.open(scope_path)
|
| 307 |
|
| 308 |
def _create_radar_scope(size=4, bgcolor="none", scope_color="green"):
|
| 309 |
fig, ax = plt.subplots(figsize=(size, size), dpi=100)
|
|
|
|
| 376 |
|
| 377 |
rgba_labels = mcolors.to_rgba("#FFFFFF", 0.7)
|
| 378 |
rgba_ticks = mcolors.to_rgba("#FFFFFF", 0.66)
|
| 379 |
+
bgcolor="#4b7bc4"
|
| 380 |
+
scope_size=3
|
| 381 |
+
scope_color="#ffffff"
|
| 382 |
+
|
| 383 |
|
| 384 |
+
imgscope = get_scope_image(size=scope_size, bgcolor=bgcolor, scope_color=scope_color, img_name="scope_blue.png")
|
| 385 |
+
fig, ax = plt.subplots(figsize=(scope_size, scope_size))
|
|
|
|
|
|
|
| 386 |
ax.set_xlim(0.2, size)
|
| 387 |
ax.set_ylim(size, 0.2)
|
| 388 |
ax.set_xticks(range(1, size + 1))
|
| 389 |
ax.set_yticks(range(1, size + 1))
|
| 390 |
ax.tick_params(axis="both", which="both", labelcolor=rgba_labels)
|
| 391 |
ax.tick_params(axis="both", which="both", colors=rgba_ticks)
|
| 392 |
+
#ax.grid(True, which="both", linestyle="--", alpha=0.3)
|
| 393 |
# ax.set_title("Radar")
|
| 394 |
ax.set_aspect('equal', adjustable='box')
|
| 395 |
|
|
|
|
| 433 |
bg_ax.axis('off')
|
| 434 |
|
| 435 |
# Overlay the radar scope image centered in the main axes
|
| 436 |
+
scope_ax = fig.add_axes([-0.075, -0.075, 1.15, 1.15], zorder=1)
|
| 437 |
scope_ax.imshow(imgscope, aspect='auto', interpolation='lanczos')
|
| 438 |
scope_ax.axis('off')
|
| 439 |
|