Files
Claude 5afde00ab7 Base-map tile pipeline and shared-canvas Leaflet viewer
Extracts only the base map art from re3mr PSDs (the top-level LOCATION
group), tiles it to WebP, and renders every map on one shared world canvas.

Pipeline: psd_tree -> export_base -> tile -> build -> preview, driven
entirely by maps.json. Adding a map is a config change.

Maps are placed on an 8192px grid (tileSize * 2^maxZoom) so a cell's tile
index shift is exactly cell * 2^z at every zoom. Each map keeps its own
locally numbered pyramid and the browser translates on the fly, so adding
a map never re-tiles the others.

excludeLayers works around psd-tools rendering stroke-only vector shapes
as solid fills, which otherwise buries Customs under a white fill.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-07 23:22:21 -07:00

49 lines
1.4 KiB
Python

"""Print a PSD's layer tree. Run this first when onboarding a new map.
python tools/psd_tree.py sources/customs/customs.psd
python tools/psd_tree.py sources/customs/customs.psd --depth 3
You are looking for two things:
1. the name of the top-level group holding the map art -> `baseGroup`
2. any `shape` layers inside it -> likely `excludeLayers` candidates,
because psd-tools fills stroke-only vector shapes as solid colour.
Legend: [V] visible [.] hidden
"""
from __future__ import annotations
import sys
from pathlib import Path
from psd_tools import PSDImage
def walk(node, depth: int, limit: int) -> None:
for layer in node:
flag = "V" if layer.visible else "."
pad = " " * depth
print(f"{pad}[{flag}] {layer.kind:<11} {layer.name[:44]!r:<46} "
f"blend={layer.blend_mode.name.lower():<12} bbox={layer.bbox}")
if layer.is_group() and depth < limit:
walk(layer, depth + 1, limit)
def main() -> None:
args = [a for a in sys.argv[1:] if not a.startswith("--")]
if not args:
raise SystemExit(__doc__)
limit = 2
if "--depth" in sys.argv:
limit = int(sys.argv[sys.argv.index("--depth") + 1])
path = Path(args[0])
psd = PSDImage.open(path)
print(f"{path.name}: {psd.size[0]}x{psd.size[1]}, {psd.depth}-bit\n")
walk(psd, 0, limit)
if __name__ == "__main__":
main()