Zwei Bilder derselben Karte, derselben Positionen und UI: - bewusst grafisch: flache Töne, Raster, posterierte Sprites - gedämpft realistisch: echte Kacheln, Übergänge, gemalte Sprites, Grade Beide bleiben TileMap/JSON und damit voll editierbar; kein gemaltes Hintergrundbild. Erzeugung: art/prep/stilprobe/stilprobe.py.
507 lines
19 KiB
Python
507 lines
19 KiB
Python
#!/usr/bin/env python3
|
|
"""Stilprobe: derselbe Marktplatz zweimal — grafisch und gedämpft.
|
|
|
|
Beide Bilder benutzen **dieselbe Karte** (`data/maps/garana.json`), **dieselben
|
|
Positionen** und **dieselbe UI**. Nur die Weltdarstellung unterscheidet sich:
|
|
|
|
* `_grafik_1920x1080.png` — bewusst grafisch: flache Töne, sichtbares Raster,
|
|
harte Schatten, Figuren als Silhouetten, keine Vignette.
|
|
* `_gedaempft_1920x1080.png` — gedämpft realistisch: vorhandene Kacheln,
|
|
Übergänge, gemalte Figuren/Requisiten, Farbgrade, warmes Licht, Vignette.
|
|
|
|
Beides bleibt eine **TileMap**: Die Geometrie steht im Zeichenraster, die
|
|
Kacheln sind 96x96-PNGs. Es wird kein Hintergrundbild gebacken.
|
|
|
|
python3 art/prep/stilprobe/stilprobe.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import random
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from PIL import Image, ImageDraw, ImageEnhance, ImageFilter
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
ART = HERE.parent.parent
|
|
ROOT = ART.parent
|
|
sys.path.insert(0, str(ART / "tools"))
|
|
import ui # noqa: E402
|
|
from font_ttf import Font # noqa: E402
|
|
|
|
T = 96
|
|
W, H = 1920, 1080
|
|
MAP = ROOT / "game/data/maps/garana.json"
|
|
TERRAIN = ART / "final/Terrain"
|
|
OBJECTS = ART / "final/Objects"
|
|
NPCS = ART / "final/NPCs"
|
|
PLAYERS = ART / "final/Players"
|
|
GEMALT = ROOT / "game/assets/gemalt"
|
|
PANEL = ROOT / "game/assets/ui/ui_panel_9slice_12px_3x.png"
|
|
|
|
UI = Font(ART / "prep/font24/ttf/PressStart2P-Regular.ttf", 24)
|
|
UI.LINE = 36
|
|
|
|
# Weltpalette / UI-Anker
|
|
INK = ui.INK
|
|
CREAM = ui.CREAM
|
|
CREAM_D = ui.CREAM_D
|
|
GOLD = ui.GOLD
|
|
PANEL_C = ui.PANEL
|
|
LINE = ui.LINE
|
|
PANEL_HI = ui.PANEL_HI
|
|
PANEL_LO = ui.PANEL_LO
|
|
OCHRE_D = ui.OCHRE_D
|
|
BLOOD = ui.BLOOD
|
|
|
|
ERDE = (140, 115, 85, 255)
|
|
ERDE_D = (124, 103, 78, 255)
|
|
ERDE_H = (178, 146, 95, 255)
|
|
GRAS = (108, 114, 66, 255)
|
|
GRAS_H = (124, 138, 69, 255)
|
|
GRAS_D = (74, 107, 58, 255)
|
|
STEIN = (122, 127, 108, 255)
|
|
STEIN_D = (93, 95, 84, 255)
|
|
WAND = (61, 61, 53, 255)
|
|
WAND_H = (76, 64, 51, 255)
|
|
DACH = [(140, 115, 85, 255), (107, 87, 68, 255), (76, 64, 51, 255),
|
|
(58, 47, 39, 255)]
|
|
PUTZ = (216, 200, 168, 255)
|
|
PUTZ_D = (176, 160, 130, 255)
|
|
GLAS = (33, 41, 46, 255)
|
|
HOLZ = (122, 90, 46, 255)
|
|
HOLZ_H = (163, 118, 60, 255)
|
|
|
|
|
|
# ---------------------------------------------------------------- Laden -----
|
|
def load_map() -> dict:
|
|
return json.loads(MAP.read_text())["entries"]["garana"]
|
|
|
|
|
|
def tile_name(karte: dict, x: int, y: int) -> str:
|
|
zeilen = karte["tiles"]
|
|
if y < 0 or y >= len(zeilen) or x < 0 or x >= len(zeilen[y]):
|
|
return ""
|
|
return karte["legend"].get(zeilen[y][x], "")
|
|
|
|
|
|
def ist(id: str, praefix: str) -> bool:
|
|
return id.startswith(praefix)
|
|
|
|
|
|
def kachel(karte: dict, x: int, y: int) -> Image.Image:
|
|
"""Echte Kachel, inklusive First/Traufe und Variantenwahl."""
|
|
id = tile_name(karte, x, y)
|
|
if ist(id, "tile_dach_mitte"):
|
|
oben = tile_name(karte, x, y - 1)
|
|
unten = tile_name(karte, x, y + 1)
|
|
if not ist(oben, "tile_dach"):
|
|
id = "tile_dach_first_96px"
|
|
elif not ist(unten, "tile_dach"):
|
|
id = "tile_dach_traufe_96px"
|
|
if id.endswith(("_1", "_2", "_3", "_4")) and id[:-2].endswith("_96px"):
|
|
basis = id[:-2]
|
|
varianten = [TERRAIN / f"{basis}_{i}.png" for i in range(1, 5)]
|
|
varianten = [p for p in varianten if p.exists()]
|
|
if varianten:
|
|
return Image.open(varianten[(x * 7 + y * 3) % len(varianten)]).convert("RGBA")
|
|
return Image.open(TERRAIN / f"{id}.png").convert("RGBA")
|
|
|
|
|
|
# ---------------------------------------------------------- grafische Kacheln
|
|
def flaeche_erde(x: int, y: int) -> Image.Image:
|
|
im = Image.new("RGBA", (T, T), ERDE)
|
|
d = ImageDraw.Draw(im)
|
|
rnd = random.Random(x * 131 + y * 17)
|
|
for _ in range(9):
|
|
px, py = rnd.randrange(6, T - 8), rnd.randrange(6, T - 8)
|
|
d.rectangle((px, py, px + 2, py + 2), fill=ERDE_D)
|
|
for _ in range(3):
|
|
px, py = rnd.randrange(8, T - 4), rnd.randrange(8, T - 4)
|
|
d.point((px, py), fill=ERDE_H)
|
|
return im
|
|
|
|
|
|
def flaeche_gras(x: int, y: int) -> Image.Image:
|
|
im = Image.new("RGBA", (T, T), GRAS)
|
|
d = ImageDraw.Draw(im)
|
|
rnd = random.Random(x * 53 + y * 29)
|
|
for _ in range(12):
|
|
px, py = rnd.randrange(4, T - 6), rnd.randrange(8, T - 10)
|
|
d.rectangle((px, py, px + 2, py + 5),
|
|
fill=GRAS_H if rnd.random() < 0.55 else GRAS_D)
|
|
return im
|
|
|
|
|
|
def flaeche_stein(x: int, y: int) -> Image.Image:
|
|
im = Image.new("RGBA", (T, T), STEIN)
|
|
d = ImageDraw.Draw(im)
|
|
for px in range(0, T, 48):
|
|
d.line((px, 0, px, T), fill=STEIN_D, width=2)
|
|
for py in range(0, T, 48):
|
|
d.line((0, py, T, py), fill=STEIN_D, width=2)
|
|
d.rectangle((0, 0, T - 1, T - 1), outline=STEIN_D, width=2)
|
|
return im
|
|
|
|
|
|
def flaeche_wand(x: int, y: int) -> Image.Image:
|
|
im = Image.new("RGBA", (T, T), WAND)
|
|
d = ImageDraw.Draw(im)
|
|
d.rectangle((0, 0, T - 1, T - 1), outline=(36, 28, 21, 255), width=3)
|
|
d.line((0, 48, T - 1, 48), fill=(36, 28, 21, 255), width=3)
|
|
for px in (32, 64):
|
|
d.line((px, 3, px, 45), fill=WAND_H, width=2)
|
|
for px in (16, 48, 80):
|
|
d.line((px, 51, px, 93), fill=WAND_H, width=2)
|
|
return im
|
|
|
|
|
|
def flaeche_dach(teil: str) -> Image.Image:
|
|
if teil == "first":
|
|
im = Image.new("RGBA", (T, T), DACH[0])
|
|
elif teil == "traufe":
|
|
im = Image.new("RGBA", (T, T), DACH[2])
|
|
else:
|
|
im = Image.new("RGBA", (T, T), DACH[1])
|
|
d = ImageDraw.Draw(im)
|
|
for py in range(0, T, 24):
|
|
d.line((0, py, T, py), fill=DACH[3], width=3)
|
|
for px in range(0, T, 48):
|
|
d.line((px, 0, px, T), fill=DACH[3], width=2)
|
|
if teil == "first":
|
|
d.line((0, 0, T, 0), fill=ERDE_H, width=6)
|
|
if teil == "traufe":
|
|
d.rectangle((0, T - 9, T - 1, T - 1), fill=INK)
|
|
d.line((0, T - 9, T, T - 9), fill=DACH[3], width=3)
|
|
return im
|
|
|
|
|
|
def flaeche_fassade(tuer: bool) -> Image.Image:
|
|
im = Image.new("RGBA", (T, T), PUTZ)
|
|
d = ImageDraw.Draw(im)
|
|
# Steinsockel
|
|
d.rectangle((0, T - 18, T - 1, T - 1), fill=STEIN_D)
|
|
d.line((0, T - 18, T, T - 18), fill=(36, 28, 21, 255), width=3)
|
|
for px in range(0, T, 48):
|
|
d.line((px, T - 18, px, T), fill=STEIN, width=2)
|
|
# Rähm und Pfosten
|
|
d.rectangle((0, 0, T - 1, 9), fill=(58, 47, 39, 255))
|
|
d.line((0, 9, T, 9), fill=WAND_H, width=2)
|
|
d.rectangle((0, 0, 9, T - 18), fill=(58, 47, 39, 255))
|
|
d.rectangle((T - 9, 0, T - 1, T - 18), fill=(58, 47, 39, 255))
|
|
if tuer:
|
|
x0, y0 = 30, 16
|
|
d.rectangle((x0, y0, x0 + 36, T - 18), fill=HOLZ)
|
|
for px in range(x0 + 6, x0 + 36, 9):
|
|
d.line((px, y0 + 3, px, T - 18), fill=(58, 47, 39, 255), width=2)
|
|
d.line((px + 3, y0 + 3, px + 3, T - 18), fill=HOLZ_H, width=1)
|
|
d.rectangle((x0, y0, x0 + 36, T - 18), outline=(36, 28, 21, 255),
|
|
width=3)
|
|
d.ellipse((x0 + 26, 44, x0 + 32, 50), outline=GOLD, width=2)
|
|
else:
|
|
x0, y0 = 30, 26
|
|
d.rectangle((x0, y0, x0 + 36, y0 + 36), fill=GLAS)
|
|
d.rectangle((x0, y0, x0 + 36, y0 + 36), outline=(58, 47, 39, 255),
|
|
width=3)
|
|
d.line((x0 + 18, y0 + 3, x0 + 18, y0 + 33), fill=PUTZ_D, width=3)
|
|
d.line((x0 + 3, y0 + 18, x0 + 33, y0 + 18), fill=PUTZ_D, width=3)
|
|
d.rectangle((x0, y0 + 33, x0 + 36, y0 + 36), fill=STEIN)
|
|
return im
|
|
|
|
|
|
def kachel_grafik(karte: dict, x: int, y: int) -> Image.Image:
|
|
id = tile_name(karte, x, y)
|
|
if ist(id, "tile_dach_mitte"):
|
|
oben = tile_name(karte, x, y - 1)
|
|
unten = tile_name(karte, x, y + 1)
|
|
if not ist(oben, "tile_dach"):
|
|
return flaeche_dach("first")
|
|
if not ist(unten, "tile_dach"):
|
|
return flaeche_dach("traufe")
|
|
return flaeche_dach("mitte")
|
|
if ist(id, "tile_dach_first"):
|
|
return flaeche_dach("first")
|
|
if ist(id, "tile_dach_traufe"):
|
|
return flaeche_dach("traufe")
|
|
if ist(id, "tile_haus_wand"):
|
|
return flaeche_fassade(False)
|
|
if ist(id, "tile_haus_tuer"):
|
|
return flaeche_fassade(True)
|
|
if ist(id, "tile_wand"):
|
|
return flaeche_wand(x, y)
|
|
if ist(id, "battle_stein"):
|
|
return flaeche_stein(x, y)
|
|
if ist(id, "tile_grasland"):
|
|
return flaeche_gras(x, y)
|
|
return flaeche_erde(x, y)
|
|
|
|
|
|
# --------------------------------------------------------------- Schatten ----
|
|
def schatten_bbox(im: Image.Image) -> tuple[int, int, int, int] | None:
|
|
return im.getchannel("A").getbbox()
|
|
|
|
|
|
def schatten(im: Image.Image, fuss: tuple[int, int], hart: bool,
|
|
deckkraft: int = 90) -> tuple[Image.Image, tuple[int, int]]:
|
|
bb = schatten_bbox(im)
|
|
if not bb:
|
|
return Image.new("RGBA", (1, 1)), (0, 0)
|
|
w = max(8, int((bb[2] - bb[0]) * 1.05))
|
|
h = max(4, min(14, int(w * 0.22)))
|
|
ebene = Image.new("RGBA", (w + 16, h + 16), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(ebene)
|
|
d.ellipse((8, 8, 8 + w - 1, 8 + h - 1), fill=(20, 16, 13, deckkraft))
|
|
if not hart:
|
|
ebene = ebene.filter(ImageFilter.GaussianBlur(4))
|
|
# ein Drittel der Höhe vor der Standlinie
|
|
mx = fuss[0] - ebene.width // 2
|
|
my = fuss[1] - ebene.height // 2 + h // 3
|
|
return ebene, (mx, my)
|
|
|
|
|
|
# ---------------------------------------------------------- Figuren/Requisiten
|
|
def gemalt(id: str) -> Image.Image | None:
|
|
p = GEMALT / f"{id}.png"
|
|
return Image.open(p).convert("RGBA") if p.exists() else None
|
|
|
|
|
|
def posterize(im: Image.Image, farben: int = 5) -> Image.Image:
|
|
a = im.getchannel("A")
|
|
rgb = im.convert("RGB").quantize(colors=farben, method=Image.MEDIANCUT)
|
|
out = rgb.convert("RGBA")
|
|
out.putalpha(a)
|
|
return out
|
|
|
|
|
|
def mit_kontur(im: Image.Image, farbe=(20, 16, 13, 255)) -> Image.Image:
|
|
a = im.getchannel("A")
|
|
krone = a.filter(ImageFilter.MaxFilter(7))
|
|
out = Image.new("RGBA", im.size, (0, 0, 0, 0))
|
|
out.paste(Image.new("RGBA", im.size, farbe), (0, 0), krone)
|
|
out.alpha_composite(im)
|
|
return out
|
|
|
|
|
|
def stelle(im: Image.Image, fuss: tuple[int, int]) -> tuple[int, int]:
|
|
return (fuss[0] - im.width // 2, fuss[1] - im.height)
|
|
|
|
|
|
# --------------------------------------------------------------------- Welt ---
|
|
def welt(karte: dict, grafik: bool) -> Image.Image:
|
|
zeilen = karte["tiles"]
|
|
h = len(zeilen) * T
|
|
im = Image.new("RGBA", (W, h), (0, 0, 0, 0))
|
|
for y, zeile in enumerate(zeilen):
|
|
for x in range(len(zeile)):
|
|
k = kachel_grafik(karte, x, y) if grafik else kachel(karte, x, y)
|
|
im.alpha_composite(k, (x * T, y * T))
|
|
|
|
# Raster nur im grafischen Register
|
|
if grafik:
|
|
d = ImageDraw.Draw(im)
|
|
for y, zeile in enumerate(zeilen):
|
|
for x in range(len(zeile)):
|
|
id = tile_name(karte, x, y)
|
|
if ist(id, "tile_wand") or ist(id, "tile_dach") or \
|
|
ist(id, "tile_haus"):
|
|
continue
|
|
d.line((x * T, y * T, x * T + T - 1, y * T),
|
|
fill=(58, 47, 39, 70), width=1)
|
|
d.line((x * T, y * T, x * T, y * T + T - 1),
|
|
fill=(58, 47, 39, 70), width=1)
|
|
|
|
# Übergänge nur im gedämpften Register
|
|
if not grafik:
|
|
for y, zeile in enumerate(zeilen):
|
|
for x in range(len(zeile)):
|
|
id = tile_name(karte, x, y)
|
|
if not ist(id, "battle_erde"):
|
|
continue
|
|
for seite, (dx, dy) in {"n": (0, -1), "o": (1, 0),
|
|
"s": (0, 1), "w": (-1, 0)}.items():
|
|
nb = tile_name(karte, x + dx, y + dy)
|
|
if not ist(nb, "tile_grasland"):
|
|
continue
|
|
v = ["a", "b", "c"][(x * 3 + y * 5) % 3]
|
|
p = TERRAIN / "uebergaenge" / \
|
|
f"uebergang_erde_nach_gras_{v}_{seite}.png"
|
|
if p.exists():
|
|
im.alpha_composite(Image.open(p).convert("RGBA"),
|
|
(x * T, y * T))
|
|
|
|
# Kanten/Schatten unter Wand und Dach
|
|
sch_layer = Image.new("RGBA", im.size, (0, 0, 0, 0))
|
|
sd = ImageDraw.Draw(sch_layer)
|
|
for y, zeile in enumerate(zeilen):
|
|
for x in range(len(zeile)):
|
|
id = tile_name(karte, x, y)
|
|
if not (ist(id, "tile_wand") or ist(id, "tile_dach")):
|
|
continue
|
|
unten = tile_name(karte, x, y + 1)
|
|
rechts = tile_name(karte, x + 1, y)
|
|
if not (ist(unten, "tile_wand") or ist(unten, "tile_dach")):
|
|
sd.rectangle((x * T, (y + 1) * T, x * T + T - 1,
|
|
(y + 1) * T + 5), fill=(0, 0, 0, 80))
|
|
if not (ist(rechts, "tile_wand") or ist(rechts, "tile_dach")):
|
|
sd.rectangle(((x + 1) * T, y * T, (x + 1) * T + 5,
|
|
y * T + T - 1), fill=(0, 0, 0, 55))
|
|
if not grafik:
|
|
sch_layer = sch_layer.filter(ImageFilter.GaussianBlur(3))
|
|
im.alpha_composite(sch_layer)
|
|
|
|
# Requisiten und Figuren, nach Fußlinie sortiert
|
|
eintraege: list[tuple[int, Image.Image, Image.Image, tuple[int, int]]] = []
|
|
for e in karte.get("objects", []):
|
|
if grafik:
|
|
p = OBJECTS / f"{e['id']}.png"
|
|
spr = Image.open(p).convert("RGBA") if p.exists() else None
|
|
else:
|
|
spr = gemalt(e["id"].replace("_96px", "_gemalt"))
|
|
if spr is None:
|
|
continue
|
|
fuss = (int(e["x"]) * T + T // 2, (int(e["y"]) + 1) * T)
|
|
eintraege.append((fuss[1], spr, _schatten_fuer(spr, fuss, grafik), fuss))
|
|
for e in karte.get("npcs", []):
|
|
if grafik:
|
|
p = NPCS / f"nsc_{e['id']}_96px.png"
|
|
spr = Image.open(p).convert("RGBA") if p.exists() else None
|
|
else:
|
|
spr = gemalt(f"nsc_{e['id']}_gemalt")
|
|
if spr is None:
|
|
continue
|
|
fuss = (int(e["x"]) * T + T // 2, (int(e["y"]) + 1) * T)
|
|
eintraege.append((fuss[1], spr, _schatten_fuer(spr, fuss, grafik), fuss))
|
|
if grafik:
|
|
spieler = Image.open(PLAYERS / "player_abenteurer_96px.png").convert("RGBA")
|
|
else:
|
|
spieler = gemalt("player_abenteurer_gemalt")
|
|
if spieler is not None:
|
|
fuss = (10 * T + T // 2, 9 * T)
|
|
eintraege.append((fuss[1], spieler,
|
|
_schatten_fuer(spieler, fuss, grafik), fuss))
|
|
|
|
for _, spr, sch, fuss in sorted(eintraege, key=lambda e: e[0]):
|
|
im.alpha_composite(sch[0], sch[1])
|
|
if grafik:
|
|
spr = mit_kontur(posterize(spr, 5))
|
|
im.alpha_composite(spr, stelle(spr, fuss))
|
|
|
|
return im.crop((0, 0, W, H))
|
|
|
|
|
|
def _schatten_fuer(spr: Image.Image, fuss: tuple[int, int],
|
|
grafik: bool) -> tuple[Image.Image, tuple[int, int]]:
|
|
# Position des Sprites: Fußlinie unten, horizontal zentriert
|
|
ebene, pos = schatten(spr, fuss, hart=grafik,
|
|
deckkraft=90 if grafik else 60)
|
|
return ebene, pos
|
|
|
|
|
|
# ---------------------------------------------------------------------- UI ---
|
|
def slice9(w: int, h: int, b: int = 6) -> Image.Image:
|
|
tex = Image.open(PANEL).convert("RGBA")
|
|
s = tex.width
|
|
out = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
|
out.paste(tex.crop((0, 0, b, b)), (0, 0))
|
|
out.paste(tex.crop((s - b, 0, s, b)), (w - b, 0))
|
|
out.paste(tex.crop((0, s - b, b, s)), (0, h - b))
|
|
out.paste(tex.crop((s - b, s - b, s, s)), (w - b, h - b))
|
|
out.paste(tex.crop((b, 0, s - b, b)).resize((w - 2 * b, b), Image.NEAREST),
|
|
(b, 0))
|
|
out.paste(tex.crop((b, s - b, s - b, s)).resize((w - 2 * b, b),
|
|
Image.NEAREST),
|
|
(b, h - b))
|
|
out.paste(tex.crop((0, b, b, s - b)).resize((b, h - 2 * b), Image.NEAREST),
|
|
(0, b))
|
|
out.paste(tex.crop((s - b, b, s, s - b)).resize((b, h - 2 * b),
|
|
Image.NEAREST),
|
|
(w - b, b))
|
|
out.paste(tex.crop((b, b, s - b, s - b)).resize((w - 2 * b, h - 2 * b),
|
|
Image.NEAREST), (b, b))
|
|
return out
|
|
|
|
|
|
def ui_ebene() -> Image.Image:
|
|
ebene = Image.new("RGBA", (W, H), (0, 0, 0, 0))
|
|
# Menü
|
|
ebene.alpha_composite(slice9(144, 54), (24, 24))
|
|
UI.draw_text(ebene, 48, 40, "MENÜ", CREAM)
|
|
# Party
|
|
namen = ("krieger", "gelehrter", "magierin", "halbling")
|
|
for i, n in enumerate(namen):
|
|
y = 24 + i * 138
|
|
ebene.alpha_composite(slice9(120, 126), (1788, y))
|
|
por = Image.open(PLAYERS / f"portrait_{n}_96px.png").convert("RGBA")
|
|
ebene.alpha_composite(por, (1800, y + 12))
|
|
if i == 0:
|
|
d = ImageDraw.Draw(ebene)
|
|
d.rectangle((1788, y, 1907, y + 125), outline=GOLD, width=3)
|
|
return ebene
|
|
|
|
|
|
# --------------------------------------------------------------- Ausgabe -----
|
|
def gedaempft(world: Image.Image) -> Image.Image:
|
|
"""Farbgrade, warmes Licht oben links, Vignette — nur auf der Welt."""
|
|
im = world.convert("RGBA")
|
|
im = ImageEnhance.Color(im).enhance(0.72)
|
|
im = ImageEnhance.Contrast(im).enhance(0.95)
|
|
im = ImageEnhance.Brightness(im).enhance(1.02)
|
|
|
|
# Lichtverlauf oben links warm, unten rechts kühl (klein rechnen, weich)
|
|
klein = Image.new("RGBA", (W // 8, H // 8), (0, 0, 0, 0))
|
|
px = klein.load()
|
|
for y in range(klein.height):
|
|
for x in range(klein.width):
|
|
t = (x / klein.width + y / klein.height) / 2
|
|
px[x, y] = (int(255 - 195 * t), int(225 - 155 * t),
|
|
int(180 - 90 * t), int(45 - 20 * t))
|
|
im = Image.alpha_composite(im, klein.resize((W, H), Image.BILINEAR))
|
|
|
|
# Vignette
|
|
klein = Image.new("L", (W // 8, H // 8), 0)
|
|
d = ImageDraw.Draw(klein)
|
|
d.ellipse((-W // 24, -H // 24, W // 8 + W // 24, H // 8 + H // 24),
|
|
fill=255)
|
|
maske = klein.resize((W, H), Image.BILINEAR).filter(
|
|
ImageFilter.GaussianBlur(40))
|
|
dunkel = Image.new("RGBA", (W, H), (12, 10, 8, 0))
|
|
dunkel.putalpha(maske.point(lambda v: int((255 - v) * 0.30)))
|
|
return Image.alpha_composite(im, dunkel)
|
|
|
|
|
|
def main() -> int:
|
|
karte = load_map()
|
|
print("Welt grafisch …")
|
|
grafik = welt(karte, grafik=True)
|
|
print("Welt gedämpft …")
|
|
sanft = gedaempft(welt(karte, grafik=False))
|
|
|
|
ui_layer = ui_ebene()
|
|
|
|
for name, world in (("_grafik_1920x1080", grafik),
|
|
("_gedaempft_1920x1080", sanft)):
|
|
out = Image.alpha_composite(world.convert("RGBA"), ui_layer)
|
|
out.convert("RGB").save(HERE / f"{name}.png")
|
|
print(HERE / f"{name}.png")
|
|
|
|
# Vergleichsblatt
|
|
sheet = Image.new("RGBA", (1920, 700), (20, 16, 13, 255))
|
|
a = Image.open(HERE / "_grafik_1920x1080.png").resize((920, 518),
|
|
Image.LANCZOS)
|
|
b = Image.open(HERE / "_gedaempft_1920x1080.png").resize((920, 518),
|
|
Image.LANCZOS)
|
|
sheet.paste(a, (40, 110))
|
|
sheet.paste(b, (960, 110))
|
|
UI.draw_text(sheet, 40, 46, "BEWUSST GRAFISCH", CREAM)
|
|
UI.draw_text(sheet, 960, 46, "GEDÄMPFT REALISTISCH", CREAM)
|
|
UI.draw_text(sheet, 40, 650,
|
|
"Gleiche Karte, gleiche Positionen, gleiche UI — nur die "
|
|
"Weltdarstellung.", CREAM_D)
|
|
sheet.save(HERE / "_vergleich_grafik_vs_gedaempft.png")
|
|
print(HERE / "_vergleich_grafik_vs_gedaempft.png")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|