comparison tools/preview.py @ 2:3dd5b745fa08

updated art with inked drawings
author ark
date 2026-10-18 15:08 +0200
parents 5492efd60e2c
children 30bd10284fd8
comparison
equal deleted inserted replaced
1:5492efd60e2c 2:3dd5b745fa08
79 for k, p in enumerate(panels): 79 for k, p in enumerate(panels):
80 sheet.paste(p, ((k % cols) * pw, (k // cols) * ph)) 80 sheet.paste(p, ((k % cols) * pw, (k // cols) * ph))
81 return sheet 81 return sheet
82 82
83 83
84 def tower_sheet(assets): 84 def tower_sheet(assets, pivots):
85 """ 85 """
86 tower levels 1-5 per row: at full size on grey, so the white fill shows, 86 tower levels 1-5 per row: at full size on grey, so the white fill shows,
87 and at game scale next to each other. 87 and at game scale next to each other. a cross marks the rotation point.
88 """ 88 """
89 rows = [] 89 rows = []
90 for t in range(4): 90 for t in range(4):
91 names = [f"t{t}"] + [f"t{t}_{lv}" for lv in range(2, 6)] 91 names = [f"t{t}"] + [f"t{t}_{lv}" for lv in range(2, 6)]
92 rows.append([Image.open(assets / f"{n}.png") for n in names]) 92 rows.append([Image.open(assets / f"{n}.png") for n in names])
102 draw.text((5 * cell_w + pad, 4), "game scale 0.25", fill=(0, 0, 0)) 102 draw.text((5 * cell_w + pad, 4), "game scale 0.25", fill=(0, 0, 0))
103 for t, r in enumerate(rows): 103 for t, r in enumerate(rows):
104 y = 20 + t * cell_h 104 y = 20 + t * cell_h
105 for lv, im in enumerate(r): 105 for lv, im in enumerate(r):
106 x = lv * cell_w + pad // 2 106 x = lv * cell_w + pad // 2
107 # cross at the image centre, the default rotation point
108 sheet.alpha_composite(im, (x, y)) 107 sheet.alpha_composite(im, (x, y))
109 cx, cy = x + im.width // 2, y + im.height // 2 108 name = f"t{t}" if lv == 0 else f"t{t}_{lv + 1}"
109 px, py = pivots.get(name, (0.5, 0.5))
110 cx, cy = x + round(im.width * px), y + round(im.height * py)
110 draw.line((cx - 5, cy, cx + 5, cy), fill=(255, 0, 0)) 111 draw.line((cx - 5, cy, cx + 5, cy), fill=(255, 0, 0))
111 draw.line((cx, cy - 5, cx, cy + 5), fill=(255, 0, 0)) 112 draw.line((cx, cy - 5, cx, cy + 5), fill=(255, 0, 0))
112 small = im.resize((max(1, im.width // 4), max(1, im.height // 4)), Image.LANCZOS) 113 small = im.resize((max(1, im.width // 4), max(1, im.height // 4)), Image.LANCZOS)
113 sheet.alpha_composite(small, (5 * cell_w + pad + lv * small_w, y + cell_h // 3)) 114 sheet.alpha_composite(small, (5 * cell_w + pad + lv * small_w, y + cell_h // 3))
114 return sheet 115 return sheet