Skip to content

Commit 922d8c5

Browse files
committed
s_shareground
1 parent 1fca3f3 commit 922d8c5

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

agrf/graphics/cv/foundation.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_left_part(left_parts, r, c, solid, scale):
3434

3535

3636
def make_foundation_subimage(
37-
img: LayeredImage, scale, left_parts, right_parts, cut_inside, zshift, solid
37+
img: LayeredImage, scale, left_parts, right_parts, s_shareground, cut_inside, zshift, solid
3838
) -> LayeredImage:
3939
if img.alpha is not None:
4040
r = np.arange(img.h)[:, np.newaxis] + img.yofs + 0.5 + zshift * scale
@@ -50,6 +50,10 @@ def make_foundation_subimage(
5050
if cut_inside:
5151
# FIXME
5252
pass
53+
54+
if not s_shareground:
55+
alphamask *= (1 - (r * 2 - c > 48 * scale) * (r * 2 + c > 48 * scale)).astype(np.uint8)
56+
5357
alpha = img.alpha * alphamask
5458
else:
5559
alpha = None
@@ -58,12 +62,14 @@ def make_foundation_subimage(
5862

5963

6064
def make_foundation(
61-
solid: LayeredImage, ground: LayeredImage, scale, left_parts, right_parts, cut_inside, zshift
65+
solid: LayeredImage, ground: LayeredImage, scale, left_parts, right_parts, s_shareground, cut_inside, zshift
6266
) -> LayeredImage:
6367
if solid is not None:
64-
solid = make_foundation_subimage(solid, scale, left_parts, right_parts, cut_inside, zshift, True)
68+
solid = make_foundation_subimage(solid, scale, left_parts, right_parts, s_shareground, cut_inside, zshift, True)
6569
if ground is not None:
66-
ground = make_foundation_subimage(ground, scale, left_parts, right_parts, cut_inside, zshift, False)
70+
ground = make_foundation_subimage(
71+
ground, scale, left_parts, right_parts, s_shareground, cut_inside, zshift, False
72+
)
6773
if solid is not None and ground is not None:
6874
return ground.copy().blend_over(solid)
6975
return solid or ground

agrf/graphics/sprites/foundation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99

1010
class FoundationSprite(grf.Sprite):
11-
def __init__(self, solid_sprite, ground_sprite, left_parts, right_parts, cut_inside, zshift, zoffset):
11+
def __init__(
12+
self, solid_sprite, ground_sprite, left_parts, right_parts, s_shareground, cut_inside, zshift, zoffset
13+
):
1214
representative = ground_sprite or solid_sprite
1315
super().__init__(
1416
representative.w,
@@ -23,6 +25,7 @@ def __init__(self, solid_sprite, ground_sprite, left_parts, right_parts, cut_ins
2325
self.ground_sprite = ground_sprite
2426
self.left_parts = left_parts
2527
self.right_parts = right_parts
28+
self.s_shareground = s_shareground
2629
self.cut_inside = cut_inside
2730
self.zshift = zshift
2831
self.zoffset = zoffset
@@ -33,6 +36,7 @@ def get_fingerprint(self):
3336
"ground_sprite": self.ground_sprite.get_fingerprint() if self.ground_sprite is not None else None,
3437
"left_parts": self.left_parts,
3538
"right_parts": self.right_parts,
39+
"s_shareground": self.s_shareground,
3640
"cut_inside": self.cut_inside,
3741
"zshift": self.zshift,
3842
"zoffset": self.zoffset,
@@ -55,6 +59,7 @@ def get_data_layers(self, context):
5559
ZOOM_TO_SCALE[(self.solid_sprite or self.ground_sprite).zoom],
5660
self.left_parts,
5761
self.right_parts,
62+
self.s_shareground,
5863
self.cut_inside,
5964
self.zshift,
6065
)

agrf/lib/building/foundation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Foundation(CachedFunctorMixin):
2121
ne_clip: bool = False
2222
sw_shareground: bool = False
2323
se_shareground: bool = False
24+
s_shareground: bool = False
2425
debug_number: int = -1
2526

2627
def __post_init__(self):
@@ -138,7 +139,14 @@ def make_foundations_subset(self, subset):
138139

139140
if s is not None or g is not None:
140141
fs = FoundationSprite(
141-
s, g, l, r, self.cut_inside, zshift=self.zshift, zoffset=(8 if style == "ground" else 0)
142+
s,
143+
g,
144+
l,
145+
r,
146+
self.s_shareground,
147+
self.cut_inside,
148+
zshift=self.zshift,
149+
zoffset=(8 if style == "ground" else 0),
142150
)
143151
alts.append(fs)
144152

@@ -173,5 +181,6 @@ def get_fingerprint(self):
173181
"ne_clip": int(self.ne_clip),
174182
"sw_shareground": int(self.sw_shareground),
175183
"se_shareground": int(self.se_shareground),
184+
"s_shareground": int(self.s_shareground),
176185
"debug_number": self.debug_number,
177186
}

0 commit comments

Comments
 (0)