Skip to content

Commit 2299c8b

Browse files
committed
erge branch 'main' into shareground
2 parents f1b5698 + 863abeb commit 2299c8b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

agrf/graphics/helpers/blend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ def blend_alternative_sprites(a, b):
1313
continue
1414
fs = BlendSprite(sa, sb)
1515
alts.append(fs)
16+
assert len(alts) > 0
1617

1718
return grf.AlternativeSprites(*alts)

agrf/graphics/helpers/map.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ def map_alternative_sprites(a, f, name, xofs=0, yofs=0):
2020
for scale in [1, 2, 4]:
2121
for bpp in [8, 32]:
2222
sa = tuple(b.get_sprite(zoom=SCALE_TO_ZOOM[scale], bpp=bpp) for b in a)
23-
if all(x is None for x in sa):
23+
if any(x is None for x in sa):
2424
continue
2525
fs = MapSprite(
2626
sa, (lambda x, scale=scale, bpp=bpp: f(x, scale, bpp)), name, xofs=xofs * scale, yofs=yofs * scale
2727
)
2828
alts.append(fs)
2929

30+
assert len(alts) > 0
31+
3032
return MapAlternativeSprites(name, a, *alts)

agrf/graphics/layered_image.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ def copy_from(self, other):
6666
return self
6767

6868
def apply_mask(self):
69-
if self.rgb is None or self.mask is None:
69+
if self.mask is None:
70+
return
71+
if self.rgb is None:
72+
self.rgb = NUMPY_PALETTE[self.mask]
73+
assert self.alpha is None
74+
self.alpha = self.mask > 0
75+
self.mask = None
7076
return
7177
v = np.min(self.rgb, axis=2, keepdims=True)
7278
mask_colour = NUMPY_PALETTE[self.mask].astype(np.uint16)

0 commit comments

Comments
 (0)