From 2087ce9960b214f7d89ab381a2c367c6c4758dc0 Mon Sep 17 00:00:00 2001 From: Otto Date: Sat, 24 Oct 2026 20:38:04 +0000 Subject: [PATCH] Fog: current view is transparent outside its shape so explored ground stays visible Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01HJhXuLD2Z6hv3Wqeq9UL9K --- backend/app/vision.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/app/vision.py b/backend/app/vision.py index 87f68a4..d1f3752 100644 --- a/backend/app/vision.py +++ b/backend/app/vision.py @@ -124,7 +124,7 @@ def inside_any(pt, polys) -> bool: def cut(path, polys, key): - """The part of the image inside the polygon (everything else black), cropped to its bounding box. + """The part of the image inside the polygon (everything else transparent), cropped to its bounding box. Returns (webp bytes, (x, y, w, h)).""" hit = _cuts.fetch(key) if hit: @@ -139,7 +139,8 @@ def cut(path, polys, key): for poly in polys: if len(poly) > 2: draw.polygon([(x - x0, y - y0) for x, y in poly], fill=255) - piece = Image.composite(im.crop((x0, y0, x0 + w, y0 + h)), Image.new("RGB", (w, h), (0, 0, 0)), mask) + piece = im.crop((x0, y0, x0 + w, y0 + h)).convert("RGBA") + piece.putalpha(mask) # transparent outside the view, so remembered (dimmed) ground underneath stays visible out = io.BytesIO() piece.save(out, "WEBP", quality=82, method=1) res = (out.getvalue(), (x0, y0, w, h))