taloria/art/prep/map-mock-3x/mock3x.py
torsten 0a0bdc307f art: 3x-Raster getestet — 1920×1080-Mock, Terrain-Prompts, Ramp-Paletten
Frage: bleibt die Qualität der Rohbilder, wenn jedes Element dreimal so viel
Zeichenpixel bekommt — bei gleichem Sichtfeld (20 × 11,25 Kacheln)?

- prep/map-mock-3x/: der Bildschirm mit Kachel 96, NSC 96×120, Requisiten
  96×96, Porträts 96×96 — alles aus 512er-Rohbildern; UI-Rahmen bei 3×
- Figuren gewinnen (Kette: Rohbild → 96×120 → 32×40 als Belegbild)
- Terrain trägt mit den alten Prompts nicht: „nahtloses Muster“ erzeugt ein
  Motiv, „Feld“ erzeugt Fläche; Schindeln werden bei 96 px Rauschen
- Material-Rampen statt globaler Palette, sonst Konfetti (prep/kachel-material/
  zeigt den Fehlversuch und den Unterschied)
- Kosten: 0,180 $ für 31 fal-Läufe, alles andere 0 €
2026-11-15 07:35:41 +01:00

251 lines
10 KiB
Python

#!/usr/bin/env python3
"""Wegwerf-Mock: derselbe Bildschirm, aber mit 3x-Raster (1920x1080, Kachel 96).
Zweck: pruefen, ob die Rohbild-Qualitaet erhalten bleibt, wenn jedes Element
dreimal so viel Zeichenpixel bekommt — bei **gleichem Sichtfeld** (20x11,25
Kacheln wie heute).
Echt 3x (aus 512er-Raws):
* Terrain: Erde (3 Varianten, zufaellig), Wand, Dach
* NSC 96x120, Requisiten 96x96, Portraets 96x96
* Party-Rahmen: bei 3x gezeichnet (Bevel und Linien 3 px)
Platzhalter (nicht bewerten):
* Dialog und MENU-Leiste: bei 1x gezeichnet und 3x hochgezogen
— die Schrift ist als 24x30 noch nicht gezeichnet
python3 art/prep/map-mock-3x/mock3x.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
from font_ttf import Font # noqa: E402
T = 96 # Kachel bei 3x
W, H = 1920, 1080 # 1x-Basis 640x360, dreifach
COLS, ROWS = 20, 12 # gleiches Sichtfeld wie im 1x-Mock
W1, H1 = 640, 360 # 1x-Maße fuer die UI-Platzhalter
A = HERE / "assets96"
FINAL = ART / "final"
def load96(name: str) -> Image.Image:
return Image.open(A / name).convert("RGBA").resize((T, T), Image.NEAREST)
ERDE = [load96(f"erde6_{i}.png") for i in (1, 2, 3, 4)]
stein = load96("battle_stein_96px.png")
gras = load96("battle_gras_96px.png")
wand = load96("wand_ramp_2.png")
dach = load96("dach3_4.png")
PROPS = {n: load96(f"obj_{n}_96px.png") for n in
("tuer", "truhe", "fass", "kiste", "tisch", "fackel", "tor", "treppe",
"geroell", "brunnen", "bett", "regal", "wagen", "grabstein")}
NPC = {n: Image.open(A / f"nsc_{n}_96px.png").convert("RGBA") for n in
("dorfbewohner", "dorfbewohnerin", "wache", "haendler", "druide",
"bettler")}
PORTRAITS = [Image.open(A / f"portrait_{n}_96px.png").convert("RGBA")
for n in ("krieger", "magierin", "zwerg", "elfin", "halbling",
"gelehrter")]
TH = 120 # Sprite-Hoehe (3x von 40)
# Schriftentscheidung 15.11.2026: Pirata One fuer Titel, Press Start 2P fuer UI
SCHRIFT = Font(ART / "final/Font/ttf/PressStart2P-Regular.ttf", 24)
SCHRIFT.LINE = 36 # 3x12 wie font8, damit das Dialoglayout bleibt
TITEL = Font(ART / "final/Font/ttf/PirataOne-Regular.ttf", 36)
rnd = random.Random(5)
def town() -> list[list[str]]:
g = [["." for _ in range(COLS)] for _ in range(ROWS)]
for x in range(COLS):
g[0][x] = "#"
g[ROWS - 1][x] = "#"
for y in range(ROWS):
g[y][0] = "#"
g[y][COLS - 1] = "#"
g[ROWS - 1][9] = "."
for (x0, y0, x1, y1) in ((4, 1, 7, 4), (12, 1, 17, 4),
(4, 8, 7, 10), (12, 8, 17, 10)):
for y in range(y0, y1 + 1):
for x in range(x0, x1 + 1):
g[y][x] = "B"
for (x, y) in ((6, 4), (14, 4), (6, 8), (14, 8)):
g[y][x] = "D"
for y in range(6, 8):
for x in range(8, 12):
g[y][x] = "g"
return g
def render(grid) -> Image.Image:
im = Image.new("RGBA", (COLS * T, ROWS * T))
for y in range(ROWS):
for x in range(COLS):
k = grid[y][x]
if k == ".":
im.paste(rnd.choice(ERDE), (x * T, y * T))
else:
im.paste({"#": wand, "B": dach, "D": dach, "g": gras}[k],
(x * T, y * T))
d = ImageDraw.Draw(im)
for y in range(ROWS):
for x in range(COLS):
if grid[y][x] in "#B":
if y + 1 < ROWS and grid[y + 1][x] not in "#B":
d.rectangle((x * T, (y + 1) * T, x * T + T - 1,
(y + 1) * T + 5), fill=(0, 0, 0, 80))
if x + 1 < COLS and grid[y][x + 1] not in "#B":
d.rectangle(((x + 1) * T, y * T, (x + 1) * T + 5,
y * T + T - 1), fill=(0, 0, 0, 55))
for (x0, y0, x1, y1) in ((4, 1, 7, 4), (12, 1, 17, 4), (4, 8, 7, 10),
(12, 8, 17, 10)):
px0, py0, px1, py1 = x0 * T, y0 * T, (x1 + 1) * T, (y1 + 1) * T
d.rectangle((px0, py0, px1 - 1, py1 - 1), outline=(0, 0, 0, 110), width=3)
d.rectangle((px0 + 3, py0 + 3, px1 - 4, py1 - 4),
outline=(210, 190, 150, 90), width=3)
cy = (py0 + py1) // 2
d.rectangle((px0 + 9, cy - 3, px1 - 12, cy + 2), fill=(226, 209, 176, 120))
d.rectangle((px0 + 9, cy - 6, px1 - 12, cy - 4), fill=(0, 0, 0, 70))
return im
def screen_town() -> Image.Image:
im = render(town())
for name, x, y in (("brunnen", 2, 6), ("wagen", 7, 5), ("tisch", 9, 6),
("fass", 3, 5), ("kiste", 4, 5), ("fass", 18, 5),
("grabstein", 18, 2), ("tor", 9, 11),
("tuer", 6, 4), ("tuer", 14, 4), ("tuer", 6, 8),
("tuer", 14, 8)):
im.alpha_composite(PROPS[name], (x * T, y * T))
for name, x, y in (("dorfbewohner", 2, 2), ("dorfbewohnerin", 9, 5),
("wache", 10, 10), ("haendler", 14, 5),
("druide", 2, 9), ("bettler", 11, 9)):
im.alpha_composite(NPC[name], (x * T, y * T + (T - TH)))
return im
def panel3x(d, box, fill=ui.PANEL, line=ui.LINE, w: int = 3) -> None:
"""`ui.panel` bei 3x: Linien und Bevel sind 3 px statt 1 px."""
x0, y0, x1, y1 = box
d.rectangle((x0, y0, x1, y1), fill=fill)
d.rectangle((x0, y0, x1, y0 + w - 1), fill=ui.PANEL_HI)
d.rectangle((x0, y0, x0 + w - 1, y1), fill=ui.PANEL_HI)
d.rectangle((x0, y1 - w + 1, x1, y1), fill=ui.PANEL_LO)
d.rectangle((x1 - w + 1, y0, x1, y1), fill=ui.PANEL_LO)
d.rectangle((x0, y0, x1, y1), outline=line, width=w)
def party3x() -> Image.Image:
fw, fh, gap, inset, ps = 120, 126, 12, 12, 96
n = 6
im = Image.new("RGBA", (fw, fh * n + gap * (n - 1)), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
for i in range(n):
y = i * (fh + gap)
panel3x(d, (0, y, fw - 1, y + fh - 1))
d.rectangle((9, y + 9, fw - 10, y + fh - 18), fill=ui.PANEL_LO)
im.alpha_composite(PORTRAITS[i], (inset, y + inset))
hp = (176, 140, 108, 255) if i % 2 == 0 else (156, 122, 94, 255)
by = y + fh - 15
d.rectangle((12, by, 12 + 84, by + 5), fill=hp)
d.rectangle((9, by - 1, fw - 10, by + 6), outline=ui.INK, width=3)
if i == 0:
d.rectangle((0, y, fw - 1, y + fh - 1), outline=ui.OCHRE, width=3)
return im
def ui_layer(lines: list[str], name: str) -> Image.Image:
"""Dialog und MENU bei 3x — Rahmen gezeichnet, Text aus der TTF gerastert."""
w, h = 1170, 198 # 3x von 390 x 66
lay = Image.new("RGBA", (w, h + 15), (0, 0, 0, 0))
d = ImageDraw.Draw(lay)
d.rectangle((0, 15, w - 1, h + 14), fill=ui.alpha(ui.PANEL, 238))
d.rectangle((0, 15, w - 1, h + 14), outline=ui.INK, width=3)
d.rectangle((3, 18, w - 4, h + 11), outline=ui.LINE, width=3)
d.line((6, 18, w - 7, 18), fill=ui.PANEL_LO, width=3)
tw = TITEL.text_width(name) + 48
d.rectangle((18, 0, 18 + tw, 57), fill=ui.OCHRE_D)
d.rectangle((18, 0, 18 + tw, 57), outline=ui.INK, width=3)
d.line((21, 3, 15 + tw, 3), fill=ui.OCHRE, width=3)
TITEL.draw_text(lay, 42, 12, name, ui.CREAM)
for i, line in enumerate(lines):
SCHRIFT.draw_text(lay, 33, 72 + i * SCHRIFT.LINE, line,
ui.CREAM if i < len(lines) - 1 else ui.CREAM_D)
ax, ay = w - 39, h + 3
for i in range(4):
d.line((ax - i * 3, ay - i * 3, ax + i * 3, ay - i * 3),
fill=ui.OCHRE, width=3)
return lay
def menu3x() -> Image.Image:
"""MENU-Knopf oben links, 3x von (8,8)-(55,25)."""
im = Image.new("RGBA", (169, 79), (0, 0, 0, 0))
d = ImageDraw.Draw(im)
d.rectangle((0, 0, 168, 78), fill=ui.alpha(ui.PANEL, 232))
d.rectangle((0, 0, 168, 78), outline=ui.LINE, width=3)
SCHRIFT.draw_text(im, 21, 24, "MENU", ui.CREAM)
return im
def main() -> int:
base = Image.new("RGBA", (W, H), ui.alpha(ui.INK))
base.alpha_composite(screen_town().crop((0, 0, W, H)), (0, 0))
dialog = ui_layer(["Valyria zahlt in Ferrum, nicht in Gold.",
"Was wollt Ihr in Garana?"], "WACHE")
base.alpha_composite(dialog, (24, H - 237))
base.alpha_composite(menu3x(), (24, 24))
party = party3x()
base.alpha_composite(party, (W - party.width - 12, 24))
HERE.mkdir(parents=True, exist_ok=True)
base.convert("RGB").save(HERE / "_mock_stadt_1920x1080.png")
# 1:1-Gegenprobe: Ausschnitt mit Dach, Boden, Wiese und Figur
alt = Image.open(ART / "prep/map-mock/_mock_stadt_640x360.png").convert("RGBA")
alt3 = alt.resize((W, H), Image.NEAREST)
box = (700, 380, 700 + 660, 380 + 380)
vergl = Image.new("RGBA", (660 * 2 + 30, 380 + 46), ui.alpha(ui.INK))
d = ImageDraw.Draw(vergl)
ui.draw_text(d, 10, 10, "links heute (2x auf 1080p gezogen), rechts 3x-Raster",
ui.CREAM)
ui.draw_text(d, 10, 24, "Ausschnitt 1:1, gleiche Stelle im Bild", ui.CREAM_D)
vergl.alpha_composite(alt3.crop(box), (10, 40))
vergl.alpha_composite(base.crop(box), (10 + 660 + 10, 40))
vergl.convert("RGB").save(HERE / "_vergleich_1zu1.png")
# Kette: Rohbild -> 96x120 -> 32x40, alles auf dieselbe Anzeigegroesse
roh = Image.open(Path.home() / "Dokumente/workbench_taloria/assets/raw/NPCs"
/ "nsc_wache_motiv_512_s8003_2.png").convert("RGBA")
kette = Image.new("RGBA", (3 * 300 + 40, 360 + 46), ui.alpha(ui.INK))
d = ImageDraw.Draw(kette)
for i, txt in enumerate(("Rohbild 512x640", "3x-Raster 96x120",
"heute 32x40")):
ui.draw_text(d, 10 + i * 310, 10, txt, ui.CREAM)
ui.draw_text(d, 10, 24, "dieselbe Figur, dreimal auf 300 px Hoehe", ui.CREAM_D)
kette.alpha_composite(roh.resize((240, 300), Image.LANCZOS), (35, 46))
kette.alpha_composite(Image.open(A / "nsc_wache_96px.png").convert("RGBA")
.resize((240, 300), Image.NEAREST), (345, 46))
kette.alpha_composite(Image.open(ART / "final/NPCs/nsc_wache_32px.png")
.convert("RGBA").resize((240, 300), Image.NEAREST),
(655, 46))
kette.convert("RGB").save(HERE / "_kette.png")
print(f"{HERE}/_mock_stadt_1920x1080.png, _vergleich_1zu1.png, _kette.png")
return 0
if __name__ == "__main__":
sys.exit(main())