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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user