diff tools/preview.py @ 16:30bd10284fd8

added ./game to .hgignore
author ark
date 2026-10-19 23:47 +0200
parents 3dd5b745fa08
children 3a831478eda4
line wrap: on
line diff
--- a/tools/preview.py	Mon Oct 19 23:36:08 2026 +0200
+++ b/tools/preview.py	Mon Oct 19 23:47:22 2026 +0200
@@ -81,10 +81,12 @@
     return sheet
 
 
-def tower_sheet(assets, pivots):
+def tower_sheet(assets, pivots, footprint, scale):
     """
     tower levels 1-5 per row: at full size on grey, so the white fill shows,
-    and at game scale next to each other. a cross marks the rotation point.
+    and at game scale next to each other. a cross marks the rotation point,
+    which is the tower position, and a circle the footprint around it.
+    footprint is the footprint radius in map pixels, scale the sprite scale.
     """
     rows = []
     for t in range(4):
@@ -93,13 +95,14 @@
     pad = 16
     cell_w = max(im.width for r in rows for im in r) + pad
     cell_h = max(im.height for r in rows for im in r) + pad
-    small_w = cell_w // 4 + 4
+    small_w = round(cell_w * scale) + 4
+    full_r = footprint / scale
     sheet = Image.new("RGBA", (5 * cell_w + 5 * small_w + pad, 4 * cell_h + 20),
                       (170, 170, 170, 255))
     draw = ImageDraw.Draw(sheet)
     for lv in range(5):
         draw.text((lv * cell_w + pad, 4), f"level {lv + 1}", fill=(0, 0, 0))
-    draw.text((5 * cell_w + pad, 4), "game scale 0.25", fill=(0, 0, 0))
+    draw.text((5 * cell_w + pad, 4), f"game scale {scale}", fill=(0, 0, 0))
     for t, r in enumerate(rows):
         y = 20 + t * cell_h
         for lv, im in enumerate(r):
@@ -110,6 +113,13 @@
             cx, cy = x + round(im.width * px), y + round(im.height * py)
             draw.line((cx - 5, cy, cx + 5, cy), fill=(255, 0, 0))
             draw.line((cx, cy - 5, cx, cy + 5), fill=(255, 0, 0))
-            small = im.resize((max(1, im.width // 4), max(1, im.height // 4)), Image.LANCZOS)
-            sheet.alpha_composite(small, (5 * cell_w + pad + lv * small_w, y + cell_h // 3))
+            draw.ellipse((cx - full_r, cy - full_r, cx + full_r, cy + full_r),
+                         outline=(0, 0, 255), width=2)
+            small = im.resize((max(1, round(im.width * scale)), max(1, round(im.height * scale))),
+                              Image.LANCZOS)
+            sx, sy = 5 * cell_w + pad + lv * small_w, y + cell_h // 3
+            sheet.alpha_composite(small, (sx, sy))
+            scx, scy = sx + small.width * px, sy + small.height * py
+            draw.ellipse((scx - footprint, scy - footprint, scx + footprint, scy + footprint),
+                         outline=(0, 0, 255))
     return sheet