art/prep: Haus-POC — Dach + Wand + Fenster + flache Tür

- mock_haus.py zeichnet ein Haus als ein Sprite (kein Kachel-Teppich):
  geschindeltes Dach, 96-px-Fassade, zwei Fenster, flache Tür
- Granularitätsvergleich Erde/Gras (flatten 6/4 gegen 2/0)
- Belege: _haus_poc_1920x1080.png, _haus_poc_detail.png
This commit is contained in:
torsten 2026-11-15 15:30:32 +01:00
parent 84bafd6315
commit 945a1b70a1
4 changed files with 202 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

202
art/prep/ui3/mock_haus.py Normal file
View file

@ -0,0 +1,202 @@
#!/usr/bin/env python3
"""Haus-POC: Dach + Wand + Fenster + flache Tür, ohne Perspektive.
Der aktuelle Stadt-Mock füllt jeden Hausblock mit einer **Wandkachel** (dem
Fachwerk-Muster) und legt eine 3/4-Tür darauf. Das liest sich als Textur-
Absturz: kein Dach, keine Fassade, keine Fenster, und die Tür steht schief.
Dieser Entwurf zeichnet ein Haus als **ein** Sprite: geschindeltes Dach oben,
eine 96-px-Fassade unten (Ploster, Balken, Steinsockel), zwei flache Fenster
und eine flache Tür. Keine Perspektive, keine Kachel-Wiederholung im Dach.
python3 art/prep/ui3/mock_haus.py
"""
from __future__ import annotations
import random
import sys
from pathlib import Path
from PIL import Image, ImageDraw
HERE = Path(__file__).resolve().parent
ART = HERE.parent.parent
sys.path.insert(0, str(ART / "tools"))
import ui # noqa: E402
import ui3 # noqa: E402
T = 96
W, H = 1920, 1080
# Palette (Weltpalette / UI-Anker)
INK = ui.INK
BEAM = (58, 47, 39, 255)
BEAM_HI = (76, 64, 51, 255)
PLASTER = (216, 200, 168, 255)
PLASTER_D = (176, 160, 130, 255)
STONE = (93, 95, 84, 255)
STONE_D = (61, 61, 53, 255)
ROOF = [(58, 47, 39, 255), (76, 64, 51, 255), (107, 87, 68, 255),
(124, 103, 78, 255)]
GLASS = (33, 41, 46, 255)
GLASS_HI = (76, 94, 106, 255)
WOOD = (122, 90, 46, 255)
WOOD_HI = (163, 118, 60, 255)
IRON = (61, 61, 53, 255)
GOLD = (216, 180, 104, 255)
def shingle_roof(w: int, h: int) -> Image.Image:
"""Geschindeltes Dach, 1 Sprite — keine Kachel-Wiederholung."""
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
d.rectangle((0, 0, w - 1, h - 1), fill=ROOF[1])
row_h, shard_w = 16, 32
for row, y in enumerate(range(0, h - 18, row_h)):
off = (shard_w // 2) if row % 2 else 0
for x in range(-shard_w, w + shard_w, shard_w):
x0 = x + off
c = ROOF[(row + x // shard_w) % len(ROOF)]
d.rectangle((x0 + 1, y + 1, x0 + shard_w - 2, y + row_h - 2),
fill=c)
d.line((x0 + 1, y + 1, x0 + shard_w - 2, y + 1),
fill=BEAM_HI, width=2)
d.line((x0 + 1, y + row_h - 2, x0 + shard_w - 2, y + row_h - 2),
fill=INK, width=2)
# First (oben) und Traufe (unten)
d.rectangle((0, 0, w - 1, 8), fill=ROOF[3])
d.line((0, 8, w - 1, 8), fill=INK, width=3)
d.rectangle((0, h - 18, w - 1, h - 1), fill=ROOF[0])
d.line((0, h - 18, w - 1, h - 18), fill=BEAM, width=3)
return im
def window() -> Image.Image:
"""Flaches Sprossenfenster, 48x48."""
im = Image.new("RGBA", (48, 48), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
d.rectangle((0, 0, 47, 47), fill=GLASS)
d.rectangle((0, 0, 47, 47), outline=BEAM, width=3)
d.rectangle((6, 6, 41, 41), outline=BEAM_HI, width=3)
d.line((24, 6, 24, 41), fill=PLASTER_D, width=3)
d.line((6, 24, 41, 24), fill=PLASTER_D, width=3)
d.line((9, 9, 18, 9), fill=GLASS_HI, width=3)
d.rectangle((0, 44, 47, 47), fill=STONE)
return im
def door() -> Image.Image:
"""Flache Tür, 60x84 — Planken, Bänder, Ring. Keine Perspektive."""
im = Image.new("RGBA", (60, 84), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
d.rectangle((0, 0, 59, 83), fill=WOOD)
for x in range(6, 60, 12):
d.line((x, 3, x, 80), fill=BEAM, width=3)
d.line((x + 3, 3, x + 3, 80), fill=WOOD_HI, width=2)
d.rectangle((0, 0, 59, 83), outline=BEAM, width=3)
d.rectangle((3, 3, 56, 80), outline=BEAM_HI, width=2)
for y in (18, 54):
d.rectangle((3, y, 56, y + 6), fill=IRON)
d.rectangle((6, y + 2, 12, y + 4), fill=BEAM_HI)
d.ellipse((40, 38, 50, 48), outline=GOLD, width=3)
return im
def facade(w: int, door_x: int | None, windows: list[int]) -> Image.Image:
"""Frontwand, 96 px hoch: Ploster, Balken, Steinsockel, Fenster, Tür."""
im = Image.new("RGBA", (w, T), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
d.rectangle((0, 0, w - 1, T - 1), fill=PLASTER)
# Steinsockel
d.rectangle((0, T - 20, w - 1, T - 1), fill=STONE)
d.line((0, T - 20, w - 1, T - 20), fill=STONE_D, width=3)
for x in range(0, w, 36):
d.line((x, T - 20, x, T - 1), fill=STONE_D, width=2)
for x in range(18, w, 36):
d.line((x, T - 20, x, T - 1), fill=STONE_D, width=2)
# Rähm und Pfosten
d.rectangle((0, 0, w - 1, 9), fill=BEAM)
d.line((0, 9, w - 1, 9), fill=BEAM_HI, width=2)
for x in range(0, w, 96):
d.rectangle((x, 0, x + 8, T - 20), fill=BEAM)
d.rectangle((w - 9, 0, w - 1, T - 20), fill=BEAM)
# Fenster
for x in windows:
im.alpha_composite(window(), (x, 22))
# Tür
if door_x is not None:
im.alpha_composite(door(), (door_x, T - 84))
return im
def house(w_tiles: int, h_tiles: int, door: bool = True,
windows: list[int] | None = None) -> Image.Image:
w, h = w_tiles * T, h_tiles * T
roof_h = h - T
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
im.alpha_composite(shingle_roof(w, roof_h), (0, 0))
# Traufschatten auf die Wand
d = ImageDraw.Draw(im)
d.rectangle((0, roof_h, w - 1, roof_h + 9), fill=(0, 0, 0, 90))
# Standardfenster: zwei je 4 Kacheln, sonst gleichmäßig
if windows is None:
windows = [40, w - 88] if w <= 384 else [40, w // 2 - 24, w - 88]
im.alpha_composite(facade(w, (w - 60) // 2 if door else None, windows),
(0, roof_h))
# Kontur
d.rectangle((0, 0, w - 1, h - 1), outline=INK, width=3)
return im
def ground() -> Image.Image:
erde = [Image.open(ART / "final3x/Terrain" / f"boden_erde_{i}_96px.png")
.convert("RGBA") for i in (1, 2, 3, 4)]
gras = Image.open(ART / "final3x/Terrain/battle_gras_96px.png").convert("RGBA")
rnd = random.Random(3)
im = Image.new("RGBA", (W, H))
for y in range(0, H, T):
for x in range(0, W, T):
im.paste(rnd.choice(erde), (x, y))
for y in range(5, 8):
for x in range(1, 6):
im.paste(gras, (x * T, y * T))
return im
def main() -> int:
im = ground()
# Schatten und Häuser
h1 = house(4, 4, windows=[40, 248])
h2 = house(6, 4, windows=[40, 392])
for hx, hy, spr in ((4 * T, 1 * T, h1), (12 * T, 1 * T, h2),
(4 * T, 8 * T, h1), (12 * T, 8 * T, h2)):
sh = Image.new("RGBA", (spr.width + 18, spr.height + 18), (0, 0, 0, 0))
ImageDraw.Draw(sh).rectangle((12, 12, spr.width + 11, spr.height + 11),
fill=(0, 0, 0, 80))
im.alpha_composite(sh, (hx, hy - 6))
im.alpha_composite(spr, (hx, hy))
# ein paar Requisiten
for name, x, y in (("brunnen", 2, 6), ("fass", 3, 5), ("kiste", 4, 5),
("tisch", 9, 6), ("wagen", 7, 5)):
im.alpha_composite(Image.open(ART / "final3x/Objects" /
f"objekt_{name}_96px.png").convert("RGBA"),
(x * T, y * T))
# Figuren
for name, x, y in (("dorfbewohner", 2, 3), ("dorfbewohnerin", 9, 5),
("wache", 10, 10), ("haendler", 14, 5)):
im.alpha_composite(Image.open(ART / "final3x/NPCs" /
f"nsc_{name}_96px.png").convert("RGBA"),
(x * T, y * T - 24))
im.convert("RGB").save(HERE / "_haus_poc_1920x1080.png")
# Detail: ein Haus 1:1 und doppelt
crop = im.crop((4 * T - 24, 1 * T - 24, 8 * T + 24, 5 * T + 24))
crop.convert("RGB").save(HERE / "_haus_poc_detail.png")
print(HERE / "_haus_poc_1920x1080.png")
print(HERE / "_haus_poc_detail.png")
return 0
if __name__ == "__main__":
sys.exit(main())