feat(m4): cap map images at Full HD and shrink on import (#85)

The owner fixed the map cap at 1920 px on the long side and 1080 px on the
short side (either orientation). fff-vtt import now shrinks a larger source
with ImageMagick Lanczos before tiling (alpha kept, proportions preserved,
no upscaling), prints `scaled WxH -> WxH`, and records the shrunk w/h; a
source at or below the cap is untouched, so the pixel-identity tests still
hold. A scene row already above the cap is not rewritten: the server logs
`map_above_cap` at startup and serve prints the re-import advice.

Docs: ADR-0023, DESIGN 3.3/5.3/8/11.1/13/14, TESTING 5.3/13, README,
HANDOFF-M4, client README. The M4 phone gate and the fogbench measurement
now use the Full HD maximum; the 16384 px / 262144-cell bench and test rows
stay as labelled server stress references. import-scale now proves a 16384²
input is shrunk to 1080x1080 (289 tiles at 64 px) quickly and bounded.

Part of #63, #85. #77 is blocked by this issue.
This commit is contained in:
2026-11-21 22:16:08 +01:00
parent 30b35592c7
commit 43947d1197
22 changed files with 515 additions and 193 deletions
+20
View File
@@ -131,6 +131,11 @@ type
const
DefaultSceneId* = 1
## The seeded v1 scene (migration step 3). Exactly one scene exists in v1 (Q3).
MapCapLongSide* = 1920
MapCapShortSide* = 1080
## The Full HD map cap (FIXED owner decision 2026-11-21, #85): at most this many px on the
## long side and on the short side, either orientation. The import shrinks a larger source;
## a scene row above it is never rewritten, only warned about at startup.
WallPositions* = [wpCenter, wpLeft, wpRight]
SightDirs* = [sdBoth, sdLeft, sdRight]
Presets* = [pwWall, pwDoor, pwWindow, pwOneWay]
@@ -139,6 +144,21 @@ const
WallLabelMaxLen* = 64
## `wall.label`: the 6.5 text rule, 1..64 code points, trimmed, no control characters (#55).
proc exceedsMapCap*(w, h: float): bool =
## True when a scene/image is larger than the Full HD cap, either orientation (#85). Written so
## NaN compares false (a corrupt dimension is not quietly "over the cap").
w > 0 and h > 0 and (max(w, h) > float(MapCapLongSide) or min(w, h) > float(MapCapShortSide))
proc cappedMapSize*(w, h: int): tuple[w, h: int] =
## The dimensions a source larger than the cap is shrunk to, preserving proportions and rounding
## to whole pixels: `4000x3000 -> 1440x1080`, `16384x16384 -> 1080x1080`. A source at or below
## the cap is returned unchanged (no upscaling).
result = (w, h)
if w <= 0 or h <= 0 or not exceedsMapCap(float(w), float(h)): return
let scale = min(1.0, min(float(MapCapLongSide) / max(float(w), float(h)),
float(MapCapShortSide) / min(float(w), float(h))))
result = (max(1, int(round(float(w) * scale))), max(1, int(round(float(h) * scale))))
proc defaultWall*(a, b: Vec): WallRec =
## The `wall` preset's switches: both blocks on, both-way sight, no marker, no door settings,
## zero thickness, centre placement and full height (DESIGN 5.8, 6.1).