Files
windroost/tools/create_filler_sprites.py
T
wushenghua 2d513bffb7 art: give every launch character a visible runtime sprite
Only H01, EG01 and B01 had reviewed pixel art, leaving most of the launch
roster invisible in the battle stage. create_filler_sprites.py generates
deterministic 96px silhouettes for the remaining five heroes and eight
enemies, keyed by signature so each role reads differently. They are written
with status "temporary_placeholder" in their manifests and must be replaced
with reviewed art before release; they are not being passed off as final.

Adding art for all characters exposed a real cap bug: the stage limited enemy
units to five but let all six hero units spawn. The HUD now clamps both to
five, and the visible-node test asserts exactly five hero units under an
over-cap input.

tools/run_p2_checks.sh still runs 15 gates; all pass.
2026-11-17 02:07:40 +08:00

172 lines
7.3 KiB
Python

#!/usr/bin/env python3
"""Generate deterministic placeholder pixel sprites for unpolished characters.
H01, EG01 and B01 have reviewed AI pixel art. The rest of the launch roster
has none, which leaves empty slots in the battle stage. This generator draws
simple, distinct 96px silhouettes from each character's signature and origin
so every unit is visible. These are *labelled temporary art*, not reviewed
assets: replace them with authored sprites before release.
Outputs use the same animation-atlas contract as pack_animation_strip.py so
UnitView can load them without any special case.
"""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
from typing import Dict, List, Tuple
from PIL import Image, ImageDraw
ROOT = Path("PRODUCTION/source/pixel_pilot/characters")
CELL = 96
FOOT = 84
# role -> (body width, shoulder width, palette seed, prop kind)
ROLE = {
"break": (16, 22, 0, "hammer"),
"single": (12, 16, 1, "bow"),
"aoe": (14, 18, 2, "staff"),
"click": (13, 18, 3, "gear"),
"tempo": (11, 15, 4, "dagger"),
"sustain": (15, 20, 5, "totem"),
"aoe_enemy": (18, 22, 6, "fangs"),
"click_enemy": (14, 18, 7, "mask"),
"break_enemy": (20, 26, 8, "shield"),
"sustain_enemy": (16, 20, 9, "vines"),
"single_enemy": (15, 19, 10, "claws"),
}
PALETTES: List[Tuple[Tuple[int, int, int], ...]] = [
((196, 122, 68), (232, 201, 120), (92, 58, 40)),
((104, 158, 110), (226, 214, 150), (52, 84, 60)),
((142, 96, 178), (232, 190, 232), (70, 46, 96)),
((198, 150, 84), (246, 218, 150), (96, 72, 40)),
((92, 116, 176), (186, 214, 246), (44, 60, 100)),
((138, 158, 86), (214, 224, 158), (66, 80, 44)),
((190, 92, 92), (242, 178, 150), (100, 44, 44)),
((168, 132, 92), (226, 200, 160), (88, 68, 48)),
((128, 142, 158), (206, 216, 226), (64, 74, 88)),
((96, 158, 132), (176, 228, 192), (44, 84, 70)),
((164, 108, 168), (228, 184, 226), (84, 52, 92)),
]
HEROES = [
("H02", "single", "attack"), ("H03", "aoe", "attack"),
("H04", "click", "attack"), ("H05", "tempo", "attack"),
("H06", "sustain", "attack"),
]
# Enemy art bindings mirror data/mvp_content_fixture.json; each distinct enemy
# gets its own silhouette so the stage reads as a mixed encounter.
ENEMIES = [
("E-R1-F2-V1", "click_enemy"), ("E-R1-F4-V1", "sustain_enemy"),
("E-R1-F5-V1", "break_enemy"), ("E-R1-F6-V1", "aoe_enemy"),
("E-R1-F7-V1", "single_enemy"), ("E-R1-F8-V1", "break_enemy"),
("E-R1-F9-V1", "aoe_enemy"), ("E-R1-F10-V1", "single_enemy"),
]
def draw_unit(role: str, frame: int, hero: bool) -> Image.Image:
image = Image.new("RGBA", (CELL, CELL), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
body_w, shoulder_w, seed, prop = ROLE[role]
main, light, dark = PALETTES[seed]
cx = CELL // 2
head_y = FOOT - 52
body_y = head_y + 12
leg_y = FOOT - 12
if frame == 1 and hero:
head_y -= 2
body_y -= 2
# Legs
draw.rectangle((cx - body_w // 2 + 2, leg_y, cx - 3, FOOT), fill=dark + (255,))
draw.rectangle((cx + 3, leg_y, cx + body_w // 2 - 2, FOOT), fill=dark + (255,))
# Torso with hard pixel shoulders
draw.rectangle((cx - body_w // 2, body_y, cx + body_w // 2, leg_y + 2), fill=main + (255,))
draw.rectangle((cx - shoulder_w // 2, body_y, cx + shoulder_w // 2, body_y + 4), fill=light + (255,))
# Head
draw.rectangle((cx - 7, head_y, cx + 7, head_y + 12), fill=main + (255,))
draw.rectangle((cx - 7, head_y, cx + 7, head_y + 3), fill=light + (255,))
draw.rectangle((cx - 4, head_y + 5, cx - 2, head_y + 6), fill=(20, 24, 32, 255))
draw.rectangle((cx + 2, head_y + 5, cx + 4, head_y + 6), fill=(20, 24, 32, 255))
# Role prop: two to three hard pixel clusters, no antialiasing.
px = cx + shoulder_w // 2 + 2
if prop == "hammer":
draw.rectangle((px, body_y - 6, px + 2, leg_y), fill=dark + (255,))
draw.rectangle((px - 4, body_y - 10, px + 6, body_y - 4), fill=light + (255,))
elif prop == "bow":
for dy in range(-10, 12, 3):
draw.point((px + (4 - abs(dy) // 3), body_y + dy), fill=light + (255,))
elif prop == "staff":
draw.rectangle((px, body_y - 14, px + 2, leg_y), fill=dark + (255,))
draw.rectangle((px - 2, body_y - 18, px + 4, body_y - 12), fill=light + (255,))
elif prop == "gear":
draw.rectangle((px - 2, body_y + 2, px + 6, body_y + 10), fill=light + (255,))
draw.rectangle((px, body_y + 4, px + 4, body_y + 8), fill=dark + (255,))
elif prop == "dagger":
draw.rectangle((px, body_y + 2, px + 2, body_y + 12), fill=light + (255,))
elif prop == "totem":
draw.rectangle((px - 2, leg_y - 20, px + 6, leg_y), fill=dark + (255,))
draw.rectangle((px, leg_y - 16, px + 4, leg_y - 4), fill=light + (255,))
elif prop == "fangs":
draw.polygon([(cx - 7, head_y - 6), (cx - 2, head_y + 2), (cx - 11, head_y + 2)], fill=light + (255,))
draw.polygon([(cx + 7, head_y - 6), (cx + 2, head_y + 2), (cx + 11, head_y + 2)], fill=light + (255,))
elif prop == "mask":
draw.rectangle((cx - 5, head_y + 4, cx + 5, head_y + 10), fill=light + (255,))
elif prop == "shield":
draw.rectangle((cx - body_w // 2 - 8, body_y + 2, cx - body_w // 2 - 1, leg_y - 2), fill=light + (255,))
elif prop == "vines":
for dy in range(0, 22, 4):
draw.point((cx + shoulder_w // 2 + (dy // 4) % 3, body_y + dy), fill=light + (255,))
elif prop == "claws":
for dx in (-6, 0, 6):
draw.rectangle((cx + dx - 1, leg_y - 6, cx + dx + 1, FOOT), fill=light + (255,))
return image
def write_atlas(character_id: str, state: str, frames: List[Image.Image]) -> None:
folder = ROOT / character_id
folder.mkdir(parents=True, exist_ok=True)
sheet = Image.new("RGBA", (CELL * len(frames), CELL), (0, 0, 0, 0))
for index, frame in enumerate(frames):
sheet.alpha_composite(frame, (index * CELL, 0))
name = f"{character_id}_{state}_anim"
path = folder / f"{name}.png"
sheet.save(path)
manifest = {
"schema": 1, "status": "temporary_placeholder",
"character_id": character_id, "state": state,
"frame_count": len(frames), "fps": 8 if state == "idle" else 12,
"loop": state == "idle", "cell_size": [CELL, CELL],
"atlas_size": list(sheet.size), "foot_y": FOOT,
"resample": "nearest", "low_power_frame_step": 1,
"frames": [
{"name": f"frame-{i}", "atlas_rect": [i * CELL, 0, CELL, CELL]}
for i in range(len(frames))
],
"sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
"note": "Temporary deterministic placeholder. Replace with reviewed pixel art before release.",
}
(folder / f"{name}.manifest.json").write_text(
json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8"
)
print(f"placeholder {character_id}/{state}: {len(frames)} frame(s)")
def main() -> int:
for hero_id, role, alt_state in HEROES:
write_atlas(hero_id, "idle", [draw_unit(role, 0, True)])
write_atlas(hero_id, alt_state, [draw_unit(role, 1, True)])
for enemy_id, role in ENEMIES:
write_atlas(enemy_id, "idle", [draw_unit(role, 0, False)])
write_atlas(enemy_id, "hit", [draw_unit(role, 1, False)])
return 0
if __name__ == "__main__":
raise SystemExit(main())