Fog: current view is transparent outside its shape so explored ground stays visible

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJhXuLD2Z6hv3Wqeq9UL9K
This commit is contained in:
2026-10-24 20:38:04 +00:00
co-authored by Claude Sonnet 5.5
parent 1405381096
commit 2087ce9960
+3 -2
View File
@@ -124,7 +124,7 @@ def inside_any(pt, polys) -> bool:
def cut(path, polys, key): 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)).""" Returns (webp bytes, (x, y, w, h))."""
hit = _cuts.fetch(key) hit = _cuts.fetch(key)
if hit: if hit:
@@ -139,7 +139,8 @@ def cut(path, polys, key):
for poly in polys: for poly in polys:
if len(poly) > 2: if len(poly) > 2:
draw.polygon([(x - x0, y - y0) for x, y in poly], fill=255) 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() out = io.BytesIO()
piece.save(out, "WEBP", quality=82, method=1) piece.save(out, "WEBP", quality=82, method=1)
res = (out.getvalue(), (x0, y0, w, h)) res = (out.getvalue(), (x0, y0, w, h))