"""Offline clean, tightly bounded furniture frames for the native MASM hall.""" import json from pathlib import Path from PIL import Image from pack_arrival_assets import solid_alpha, write_pack import pack_arrival_assets as packs from pack_world_v4 import clean_cell ROOT = Path(__file__).resolve().parents[2] def frame(source, bounds, size): item = clean_cell(solid_alpha(source.crop(bounds).convert("RGBA"))) # Independent frames have no nominal atlas-grid margins or neighboring limbs. item = item.resize(size, Image.Resampling.NEAREST) return solid_alpha(item) def main(): packs.OUTPUT = ROOT / "assets/animations/hall" atlas = Image.open(ROOT / "assets/sprites/casino-atlas-v1.png") assert atlas.size == (1254, 1254) def atlas_bounds(box): return tuple(round(value * 1254 / 1280) for value in box) items = [ ("card-table", atlas, atlas_bounds((933, 415, 1266, 631)), (320, 208)), ("roulette-table", atlas, atlas_bounds((0, 646, 315, 938)), (288, 268)), ("backroom-table", atlas, atlas_bounds((320, 700, 625, 937)), (304, 236)), ] source = Image.open(ROOT / "assets/sprites/hall/furniture-v5.png") assert source.size == (1536, 1024) items += [ ("skill-cabinet", source, (210, 0, 635, 585), (224, 368)), ("lounge-chair", source, (907, 42, 1410, 579), (240, 256)), ("lamp-table", source, (241, 584, 627, 1024), (192, 224)), ("velvet-rope", source, (860, 584, 1439, 1024), (288, 192)), ] manifest = {} output = ROOT / "build/hall" output.mkdir(parents=True, exist_ok=True) for name, image, bounds, size in items: result = frame(image, bounds, size) write_pack(name + "-v5.bin", [result]) result.save(output / (name + "-v5.png")) manifest[name] = {"size": size, "bounds": bounds, "frames": 1} slots = [frame(atlas, atlas_bounds(box), (224, 256)) for box in [(38, 348, 294, 643), (352, 348, 618, 643), (674, 348, 931, 643)]] write_pack("slot-cabinets-v5.bin", slots) manifest["slot-cabinets"] = {"size": (224, 256), "frames": 3} (packs.OUTPUT / "manifest-furniture-v5.json").write_text( json.dumps(manifest, indent=2) + "\n", encoding="ascii") print("Packed seven separate furniture assets without atlas bleed") if __name__ == "__main__": main()