art/UI: UI-Elemente prozedural gezeichnet (tools/ui.py, final/UI/)
Sechste Kategorie, als einzige ohne Modell: 1-px-Bevel, 2-px-Rahmen und harte Kanten sind Rechnung, keine Malerei. Gezeichnet bei 1x (320x180-Raster), ausgeliefert mit nearest 4x. - tools/ui.py: Dialoge (3/6 Zeilen), Buttons (4 Zustaende), Slots, Inventar, Zauberbuch, Party-Rahmen, Kampf-Leiste, Balken, Tooltip, Ladebalken - 5x7-Pixelfont im Skript (3x5 war bei M/N/H nicht unterscheidbar) - 16-Farben-Palette mit _palette_ui.png als Anker - zwei Mocks ueber echten Szenen als Lesbarkeitsprobe - WORKFLOW 4.7 + Kategorien-Tabellen ergaenzt
|
|
@ -13,7 +13,7 @@ Neuer Rechner: [`SETUP.md`](SETUP.md) — `python3 art/tools/setup.py check`.
|
|||
|
||||
## Kategorien
|
||||
|
||||
Fünf Kategorien, nach **Funktion im Spiel** sortiert — nicht nach Motiv.
|
||||
Sechs Kategorien, nach **Funktion im Spiel** sortiert — nicht nach Motiv.
|
||||
Ein Wolf ist `Creatures`, auch wenn er in einem Wald steht; der Wald ist
|
||||
`Terrain`, auch wenn ein Wolf drin sitzt.
|
||||
|
||||
|
|
@ -24,11 +24,17 @@ Ein Wolf ist `Creatures`, auch wenn er in einem Wald steht; der Wald ist
|
|||
| `Creatures/` | Monster und Tiere als Sprite | 96×96 | 384×384 | A (flach) | ja |
|
||||
| `Players/` | Spielerfiguren und Porträts | 64×80 / 64×64 | 256×320 / 256×256 | A (flach) | ja |
|
||||
| `Objects/` | einzelne Dinge: Waffen, Türen, Kisten, Icons | 32×32 | 128×128 | A (flach) | ja |
|
||||
| `UI/` | Dialoge, Fenster, Buttons, Slots, Balken, Party-Rahmen — **prozedural** | variabel, 1× im 320×180-Raster | 4× nearest | A (flach) | teils |
|
||||
|
||||
Alle drei Sprite-Kategorien laufen mit `--cutout 12 --outline auto --recenter`.
|
||||
`--levels 0.5 --gamma 1.15` zusätzlich bei dunklen Figuren (`Players`) und
|
||||
`Objects` — sonst verschwinden sie auf dunklem Grund.
|
||||
|
||||
`UI/` ist die Ausnahme in der Pipeline: gezeichnet von
|
||||
[`tools/ui.py`](tools/ui.py), nicht generiert und nicht durch `pixelize.py`
|
||||
geschickt. Begründung und Regeln in
|
||||
[`final/UI/README.md`](final/UI/README.md).
|
||||
|
||||
`Terrain` ist etwas anderes als „Landschaft im Bild": es sind die **Kacheln für
|
||||
die Overland-Karte**, aus denen sich die Welt zusammensetzt. Alles, was ein
|
||||
ganzes Bild füllt — auch eine leere Taverne oder ein Waldpanorama — ist
|
||||
|
|
@ -41,6 +47,10 @@ Kleine ist **A** (flach, 32 Farben, harte Kanten). Begründung: bei 32×32 und
|
|||
96×96 ist Detail ein Nachteil, bei 320×180 ist es die halbe Atmosphäre.
|
||||
Details in [`WORKFLOW.md`](WORKFLOW.md) §3.
|
||||
|
||||
`UI/` ist immer **A** — und die einzige Kategorie ohne Modell: 1-px-Bevels,
|
||||
2-px-Rahmen und harte Kanten sind Rechnung, keine Malerei. Siehe
|
||||
[`WORKFLOW.md`](WORKFLOW.md) §4.7.
|
||||
|
||||
## Aufbau
|
||||
|
||||
```
|
||||
|
|
@ -51,6 +61,7 @@ art/
|
|||
requirements.txt Pillow (einzige Abhängigkeit von pixelize.py)
|
||||
prompts/ Style- und Motiv-Blöcke
|
||||
tools/pixelize.py Downscale, Palette, Dither, Freisteller
|
||||
tools/ui.py UI-Elemente zeichnen (1x, kein Modell, kein pixelize)
|
||||
tools/setup.py check / deps / comfy / models / workbench
|
||||
workflows/ ComfyUI-Jobdateien, eine pro Motiv (flux2_klein9b_api.json = Standard)
|
||||
license-log.csv jede Generierung, mit Prompt und Seed
|
||||
|
|
@ -77,7 +88,9 @@ assets/final/…`) unverändert von der Workbench aus, und es gibt nur einen Sta
|
|||
`<thema>_<motiv>_<groesse>.png` — z. B. `monster_wolf_96px.png`,
|
||||
`szene_waffenhaendler_1280x720.png`, `objekt_schwert_32px.png`.
|
||||
Rohbilder behalten den Seed: `monster_wolf_s271828.png` — damit ist jede
|
||||
Engine-Datei auf eine Zeile im Lizenzlog zurückführbar.
|
||||
Engine-Datei auf eine Zeile im Lizenzlog zurückführbar. `UI/` folgt derselben
|
||||
Regel mit der Basisgröße des Elements: `ui_dialog_292x59.png` ist bei 1×
|
||||
292×59 groß und in der Datei 1168×236.
|
||||
|
||||
## Jedes Asset: drei Zeilen im Kopf der Kategorie-README
|
||||
|
||||
|
|
|
|||
|
|
@ -382,6 +382,38 @@ Drei Dinge, die noch offen sind:
|
|||
die Symbole zu Brei — mehr Kacheln pro Bildschirm heißt weniger Platz pro
|
||||
Symbol, nicht mehr Detail.
|
||||
|
||||
### 4.7 UI-Elemente — gezeichnet, nicht generiert (12.11.2026)
|
||||
|
||||
`final/UI/` ist die erste Kategorie, die **kein Modell** durchläuft. Sie wird
|
||||
von `tools/ui.py` bei 1× gezeichnet und mit nearest 4× ausgeliefert.
|
||||
|
||||
Der Grund steht schon in `prompts/retro_crpg_style.md`: „UI-Rahmen (*nur wenn
|
||||
überhaupt generiert* — meist besser als Prozedur)". Ein 1-px-Bevel ist eine
|
||||
exakte Pixelzeile; ein Diffusionsmodell liefert dort Farbverläufe und
|
||||
ausgefranste Kanten, und beim Herunterrechnen bricht die Linie weg. Ein Rahmen
|
||||
aus `INK`, `PANEL`, `PANEL_HI`, `PANEL_LO` ist dagegen eine Rechnung. Kein
|
||||
Prompt, kein Seed, kein Lizenzlog-Eintrag — und 0 € Kosten.
|
||||
|
||||
Gebaut: Dialogbox (3 und 6 Zeilen), Buttons in vier Zuständen, Slots,
|
||||
Inventar- und Zauberbuch-Fenster, Party-Rahmen, Kampf-Aktionsleiste, Balken,
|
||||
Checkbox, Slider, Tooltip, Cursor, Ladebalken. Dazu zwei Mocks über echten
|
||||
Szenen (`_mock_hud_A/B_1280x720.png`) — das ist der eigentliche Test.
|
||||
|
||||
Was die Umsetzung gelehrt hat:
|
||||
|
||||
| Befund | Konsequenz |
|
||||
|---|---|
|
||||
| 3×5-Font ist bei `M`/`N`/`H` nicht unterscheidbar („WHAT" = „HHAT") | 5×7 mit 1 px Laufweite; 3 Zeilen passen weiter in 54 px |
|
||||
| Bevel invertiert (hell oben/links in einer Vertiefung) | die Slots wirkten wie erhabene Kacheln → Regel: vertieft = dunkel oben/links |
|
||||
| eine Linie reicht über hellen Flächen nicht | `INK` außen + `LINE` innen; nur `LINE` franst über Himmel und Fenstern aus |
|
||||
| deckendes Panel wirkt aufgeklebt | Alpha 232–238 über der Szene |
|
||||
| Vollkörper-Sprite auf 26×26 gecroppt ist ein Fleck | Party-Porträts sind gezeichnete Kopf-Schulter-Silhouetten |
|
||||
| 1-px-Rahmen und 5×7-Text brauchen Platz | Dialog 292×59 + Party-Spalte 34 px = ~48 % der Bildhöhe; über Szene A (Tageslicht) wird es eng |
|
||||
|
||||
Nichts davon gehört ins Lizenzlog, weil nichts generiert wird. Kommt ein
|
||||
Element doch mal aus einem Modell (ornamentaler Rahmen), gilt §5 normal — dann
|
||||
steht es in `license-log.csv` und läuft durch `pixelize.py`.
|
||||
|
||||
## 5. Werkzeuge auf dieser Maschine
|
||||
|
||||
- **Hardware:** RTX 5060 Ti, 16 GB VRAM, 32 GB RAM. Bilder lokal: problemlos.
|
||||
|
|
@ -404,6 +436,9 @@ Drei Dinge, die noch offen sind:
|
|||
(0,03 $/MP), `fal-ai/flux-2/klein/9b` für Varianten, `blackforestlabs/flux-3/text-to-image`
|
||||
nur wenn Typografie/Komposition sitzen muss. **Vor jedem Lauf `estimate_cost`
|
||||
mit dem echten Input**, Modell + Preis in einem Satz nennen.
|
||||
- **UI (`tools/ui.py`):** zeichnet `final/UI/` bei 1× und skaliert 4× nearest.
|
||||
`python3 tools/ui.py` (Auslieferung) / `--scale 1` (Basisgrößen) /
|
||||
`--out DIR`. Kein Modell, kein `pixelize.py`, kein Lizenzlog.
|
||||
- **Protokoll:** jeder Lauf → `assets/license-log.csv`
|
||||
(`datum,endpoint_id,request_id,prompt,seed,lizenz`).
|
||||
- **Seitenverhältnis:** Szene = Zielformat des Spiels (16:9, §0); Porträt/Icon = 1:1.
|
||||
|
|
@ -467,6 +502,7 @@ Standardaufrufe stehen in `assets/README.md` und in der README jeder Kategorie:
|
|||
| `Creatures/` | Monster, Tiere | 96×96 | 384×384 | A |
|
||||
| `Players/` | Spielerfiguren, Porträts | 64×80 / 64×64 | 256×320 / 256×256 | A |
|
||||
| `Objects/` | Waffen, Türen, Icons | 32×32 | 128×128 | A |
|
||||
| `UI/` | Dialoge, Fenster, Buttons, Slots, Balken (**gezeichnet**) | variabel (1×) | 4× nearest | A |
|
||||
|
||||
`Terrain` sind die **Kacheln der Overland-Karte**, nicht „Landschaft im Bild".
|
||||
Alles, was ein ganzes Bild füllt — auch eine leere Taverne — ist `Pictures`.
|
||||
|
|
@ -487,7 +523,11 @@ Alles, was ein ganzes Bild füllt — auch eine leere Taverne — ist `Pictures`
|
|||
Dithering: Schwelle `--smart-low/--smart-high` muss noch kalibriert werden.
|
||||
6. Paletten-Konsistenz über eine Asset-Serie ist Handarbeit (`--palette` pro
|
||||
Serie), kein Automatismus.
|
||||
7. **Richtung A oder B (§3) ist nicht entschieden.** Beide sind jetzt gebaut
|
||||
7. **UI ist erst ein Satz, kein System.** `final/UI/` deckt HUD, Inventar und
|
||||
Zauberbuch ab. Offen: 9-Slice-Ränder für variable Panels, der 5×7-Font als
|
||||
Engine-Font (BMFont/`FontFile`), Kartenrand, Kampf-Log, Handelsfenster.
|
||||
Siehe `final/UI/README.md`.
|
||||
8. **Richtung A oder B (§3) ist nicht entschieden.** Beide sind jetzt gebaut
|
||||
und vergleichbar: `assets/final/_vergleich_A_vs_B.png`. A = flach, 32 Farben,
|
||||
Tageslicht, Text als Beiwerk. B = gemalt, 64 Farben, Nachtlicht, Text als
|
||||
Hauptträger. Das ist die nächste echte Weichenstellung, nicht ein Detail.
|
||||
|
|
|
|||
110
art/final/UI/README.md
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
# UI — Panels, Dialoge, Buttons, Slots
|
||||
|
||||
Alles, was über dem Bild liegt: Dialogboxen, Fenster, Buttons, Inventar- und
|
||||
Zauberbuch-Raster, Party-Rahmen, Balken, Tooltips, Ladebalken.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Basisgröße | **variabel**, gezeichnet im 320×180-Raster (1 px = 1 Bildschirmpixel) |
|
||||
| Ausgabe | 4× nearest, also im 1280×720-Maßstab |
|
||||
| Stil | Richtung **A** (flach) |
|
||||
| Palette | **16 Farben fest**, Anker `_palette_ui.png` |
|
||||
| Alpha | teils — Panels liegen mit Alpha über der Szene, Einzelteile sind freigestellt |
|
||||
|
||||
**Diese Kategorie läuft nicht über `pixelize.py` und nicht über ein Modell.**
|
||||
UI ist Linienarbeit: ein 1-px-Bevel ist eine exakte Pixelzeile, und ein
|
||||
Diffusionsmodell liefert dort Farbverläufe und ausgefranste Kanten, die beim
|
||||
Herunterrechnen wegbrechen. Der Prompt-Baustein in
|
||||
[`../../prompts/retro_crpg_style.md`](../../prompts/retro_crpg_style.md) sagt
|
||||
das selbst: „UI-Rahmen (*nur wenn überhaupt generiert* — meist besser als
|
||||
Prozedur)".
|
||||
|
||||
## Pipeline
|
||||
|
||||
```bash
|
||||
# Auslieferung: 4x nearest (1280x720-Maßstab) -> ../../final/UI/
|
||||
python3 ../../tools/ui.py
|
||||
|
||||
# Basisgrößen zum Prüfen (1x, 320x180-Raster)
|
||||
python3 ../../tools/ui.py --scale 1 --out /tmp/ui_1x
|
||||
```
|
||||
|
||||
`tools/ui.py` zeichnet alle Elemente bei 1× und skaliert sie mit nearest.
|
||||
**Gezeichnet wird immer bei 1×** — ein 4×-Entwurf mit halben Pixeln ist nicht
|
||||
mehr auf das Raster zu bringen.
|
||||
|
||||
## Inhalt
|
||||
|
||||
| Datei | Basisgröße | Inhalt |
|
||||
|---|---|---|
|
||||
| `ui_dialog_292x59.png` | 292×59 | Dialogbox, 3 Zeilen, Namensschild, Weiter-Pfeil |
|
||||
| `ui_dialog_gross_292x89.png` | 292×89 | dasselbe mit 6 Zeilen (Erzähltext) |
|
||||
| `ui_buttons_52x14.png` | 52×14 (4 Stück) | Zustände: idle, hover, pressed, disabled |
|
||||
| `ui_slots_22px.png` | 22×22 (6 Stück) | leer, Waffe, Pflanze, leer, ausgewählt + Stapelzahl, gesperrt |
|
||||
| `ui_window_pack_148x112.png` | 148×112 | Inventar: Titelleiste, 5×3-Raster, Schließen, Fußzeile |
|
||||
| `ui_window_zauber_148x116.png` | 148×116 | Zauberbuch: Schulen-Tabs, 5×3-Raster, Kosten, Mem-Slots |
|
||||
| `ui_party_34px.png` | 34×34 (3 Stück) | Party-Rahmen mit Porträt und HP-Rinne, erster aktiv |
|
||||
| `ui_kampf_leiste_300x40.png` | 300×40 | Initiative-Reihe + Aktionen (ATTACK … END TURN) |
|
||||
| `ui_misc_170x104.png` | 170×104 | Balken HP/SP/MP, Checkbox, Slider, Tooltip, Cursor |
|
||||
| `ui_ladebalken_180x20.png` | 180×20 | Ladebalken mit Segmentmarken und Prozentwert |
|
||||
| `_mock_hud_B_1280x720.png` | 320×180 | UI über Szene B — Lesbarkeitsprobe |
|
||||
| `_mock_hud_A_1280x720.png` | 320×180 | dasselbe über Szene A (Tageslicht) |
|
||||
| `_palette_ui.png` | 32×32 | 16 Farben als 4×4-Raster, `--palette`-Anker |
|
||||
|
||||
Die Mocks entstehen im Skript mit: echte Szene aus `../Pictures/`, auf
|
||||
320×180 heruntergerechnet, UI darüber, dann 4×. Was bei 1× untergeht, geht
|
||||
auch im Spiel unter — das ist der eigentliche Test.
|
||||
|
||||
## Palette
|
||||
|
||||
| Farbe | Wert | Rolle |
|
||||
|---|---|---|
|
||||
| `INK` | `#1a1512` | harte Außenkante, Schrift auf hell |
|
||||
| `PANEL` | `#3a2f27` | Fläche (mit Alpha 232–238 über der Szene) |
|
||||
| `PANEL_HI` | `#544536` | Bevel oben/links |
|
||||
| `PANEL_LO` | `#27201b` | Bevel unten/rechts, vertiefte Flächen |
|
||||
| `LINE` | `#7c674e` | 1-px-Rahmenlinie |
|
||||
| `CREAM` / `CREAM_D` | `#e2d1b0` / `#b0a082` | Text primär / sekundär |
|
||||
| `OCHRE` / `OCHRE_D` | `#b28a4a` / `#7a5a2e` | Akzent, Titelleiste |
|
||||
| `GOLD` | `#d8b468` | Fokus, Auswahl, Hover |
|
||||
| `SLATE` / `SLATE_D` | `#4c5e6a` / `#2e3c46` | kühle Flächen, Porträt 1 |
|
||||
| `OLIVE` / `OLIVE_D` | `#6c7242` / `#484e2c` | Balken, Porträt 2 |
|
||||
| `BLOOD` | `#963a2e` | HP, Gegner |
|
||||
|
||||
Die Familie ist dieselbe wie im A-Style-Block (Ocker, Slate, Olive, Creme,
|
||||
Umbra) — UI und Bild sollen nicht zwei Welten sein.
|
||||
|
||||
## Regeln
|
||||
|
||||
- **Zwei Linien.** `INK` außen plus `LINE` innen. Nur `LINE` franst über hellen
|
||||
Flächen optisch aus (Fenster, Himmel), nur `INK` wirkt wie ein Loch.
|
||||
- **Bevel: Licht von oben links.** `PANEL_HI` oben/links, `PANEL_LO` unten/
|
||||
rechts. Vertiefte Flächen (Slots, Balken-Track) genau umgekehrt, sonst lesen
|
||||
sie sich als erhabene Kacheln — der Fehler war im ersten Lauf drin.
|
||||
- **Alpha 232–238 über der Szene.** Deckend wirkt die Box aufgeklebt,
|
||||
besonders über Tageslicht-Szenen.
|
||||
- **Text ist Platzhalter.** Was in den Elementen steht, zeigt nur Zeilenlänge
|
||||
und Dichte; im Spiel kommt der Text aus der Engine.
|
||||
- **Schrift: 5×7, 1 px Laufweite (6 px Vorschub).** 3×5 ist bei `M`/`N`/`H`
|
||||
nicht unterscheidbar („WHAT" liest sich als „HHAT") und deshalb verworfen.
|
||||
Zeilenraster 10 px, drei Zeilen passen in 54 px Panelhöhe.
|
||||
- **Dateiname trägt die Basisgröße**, die Datei das 4×-Ergebnis —
|
||||
`ui_dialog_292x59.png` ist 1168×236 groß. Dieselbe Regel wie
|
||||
`monster_wolf_96px.png`.
|
||||
- **Neues Element:** in `tools/ui.py` als Funktion ergänzen, in `main()` in die
|
||||
`elements`-Tabelle eintragen, Zeile hier ergänzen. Kein Einzel-PNG von Hand.
|
||||
|
||||
## Offen
|
||||
|
||||
- **Font für die Engine.** Die 5×7-Matrix steht im Skript. Für Godot braucht
|
||||
es sie als `FontFile`/BMFont oder als Textur-Atlas — sonst zeichnet die
|
||||
Engine eine andere Schrift als die Entwürfe.
|
||||
- **Neun-Slice.** Panels sind derzeit feste Größen (292, 148, 300 px). Für
|
||||
variable Textboxen braucht es 9-Slice-Ränder (Ecken 4×4, Kanten 1 px) plus
|
||||
Regel, wie der Inhalt einrückt.
|
||||
- **Höhe gegen Bildfläche.** Dialog 292×59 + Party-Spalte 34 px sind ~48 % der
|
||||
Bildhöhe. Über Szene B trägt das, über Szene A (heller Himmel) wird es eng.
|
||||
Die 6-Zeilen-Box (89 px) frisst noch mehr — Entscheidung steht aus.
|
||||
- **Noch nicht gebaut:** Kartenrand, Kapitel-/Titelbild-Rahmen, Kampf-Log,
|
||||
Handelsfenster, Tooltip mit variabler Breite, Mauszeiger-Varianten,
|
||||
16-px-Variante der Slots (für dichtere Raster).
|
||||
BIN
art/final/UI/_mock_hud_A_1280x720.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
art/final/UI/_mock_hud_B_1280x720.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
art/final/UI/_palette_ui.png
Normal file
|
After Width: | Height: | Size: 192 B |
BIN
art/final/UI/ui_buttons_52x14.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
art/final/UI/ui_dialog_292x59.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
art/final/UI/ui_dialog_gross_292x89.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
art/final/UI/ui_kampf_leiste_300x40.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
art/final/UI/ui_ladebalken_180x20.png
Normal file
|
After Width: | Height: | Size: 898 B |
BIN
art/final/UI/ui_misc_170x104.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
art/final/UI/ui_party_34px.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
art/final/UI/ui_slots_22px.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
art/final/UI/ui_window_pack_148x112.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
art/final/UI/ui_window_zauber_148x116.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
571
art/tools/ui.py
Normal file
|
|
@ -0,0 +1,571 @@
|
|||
#!/usr/bin/env python3
|
||||
"""UI-Generator für Taloria — prozedural gezeichnet, 1x = 320x180-Maßstab.
|
||||
|
||||
UI ist Linienarbeit: 1-px-Bevel, 2-px-Rahmen, harte Kanten. Ein
|
||||
Diffusionsmodell liefert dort Farbverläufe und ausgefranste Kanten, die beim
|
||||
Herunterrechnen wegbrechen. Deshalb wird hier gezeichnet, nicht generiert,
|
||||
und zwar direkt bei 1x; ausgeliefert wird mit nearest 4x.
|
||||
|
||||
python3 tools/ui.py # -> final/UI/, 4x (1280x720)
|
||||
python3 tools/ui.py --scale 1 # -> Basisgrößen, 1x
|
||||
python3 tools/ui.py --out /tmp/ui # woanders hin
|
||||
|
||||
Die Dateinamen tragen die **Basisgröße** (z. B. ui_dialog_292x59.png =
|
||||
292x59 bei 1x, 1168x236 in der Datei) — dieselbe Regel wie
|
||||
monster_wolf_96px.png in final/Creatures/.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
ART = Path(__file__).resolve().parent.parent
|
||||
FINAL = ART / "final"
|
||||
SCENE_B = FINAL / "Pictures" / "taverne_B_1280x720.png"
|
||||
SCENE_A = FINAL / "Pictures" / "taverne_A_1280x720.png"
|
||||
SWORD = FINAL / "Objects" / "objekt_schwert_32px.png"
|
||||
|
||||
# ---------------------------------------------------------------- Palette (16)
|
||||
INK = (26, 21, 18, 255) # fast schwarz, warm
|
||||
PANEL = (58, 47, 39, 255) # umber, Fläche
|
||||
PANEL_HI = (84, 69, 54, 255) # Bevel oben/links
|
||||
PANEL_LO = (39, 32, 27, 255) # Bevel unten/rechts, vertiefte Fläche
|
||||
LINE = (124, 103, 78, 255) # 1-px-Rahmenlinie
|
||||
CREAM = (226, 209, 176, 255) # Text, hellste Fläche
|
||||
CREAM_D = (176, 160, 130, 255) # sekundärer Text
|
||||
OCHRE = (178, 138, 74, 255) # Akzent
|
||||
OCHRE_D = (122, 90, 46, 255) # Akzent dunkel, Titelleiste
|
||||
GOLD = (216, 180, 104, 255) # Fokus, Auswahl, Hover
|
||||
SLATE = (76, 94, 106, 255)
|
||||
SLATE_D = (46, 60, 70, 255)
|
||||
OLIVE = (108, 114, 66, 255)
|
||||
OLIVE_D = (72, 78, 44, 255)
|
||||
BLOOD = (150, 58, 46, 255)
|
||||
|
||||
PALETTE = [INK, PANEL, PANEL_HI, PANEL_LO, LINE, CREAM, CREAM_D, OCHRE,
|
||||
OCHRE_D, GOLD, SLATE, SLATE_D, OLIVE, OLIVE_D, BLOOD]
|
||||
|
||||
# -------------------------------------------------------------- Font 5x7
|
||||
FONT = {
|
||||
"A": ".###.|#...#|#...#|#####|#...#|#...#|#...#",
|
||||
"B": "####.|#...#|#...#|####.|#...#|#...#|####.",
|
||||
"C": ".####|#....|#....|#....|#....|#....|.####",
|
||||
"D": "####.|#...#|#...#|#...#|#...#|#...#|####.",
|
||||
"E": "#####|#....|#....|####.|#....|#....|#####",
|
||||
"F": "#####|#....|#....|####.|#....|#....|#....",
|
||||
"G": ".####|#....|#....|#..##|#...#|#...#|.###.",
|
||||
"H": "#...#|#...#|#...#|#####|#...#|#...#|#...#",
|
||||
"I": "#####|..#..|..#..|..#..|..#..|..#..|#####",
|
||||
"J": "..###|...#.|...#.|...#.|...#.|#..#.|.##..",
|
||||
"K": "#...#|#..#.|#.#..|##...|#.#..|#..#.|#...#",
|
||||
"L": "#....|#....|#....|#....|#....|#....|#####",
|
||||
"M": "#...#|##.##|#.#.#|#.#.#|#...#|#...#|#...#",
|
||||
"N": "#...#|##..#|#.#.#|#.#.#|#..##|#...#|#...#",
|
||||
"O": ".###.|#...#|#...#|#...#|#...#|#...#|.###.",
|
||||
"P": "####.|#...#|#...#|####.|#....|#....|#....",
|
||||
"Q": ".###.|#...#|#...#|#...#|#.#.#|#..#.|.##.#",
|
||||
"R": "####.|#...#|#...#|####.|#.#..|#..#.|#...#",
|
||||
"S": ".####|#....|#....|.###.|....#|....#|####.",
|
||||
"T": "#####|..#..|..#..|..#..|..#..|..#..|..#..",
|
||||
"U": "#...#|#...#|#...#|#...#|#...#|#...#|.###.",
|
||||
"V": "#...#|#...#|#...#|#...#|#...#|.#.#.|..#..",
|
||||
"W": "#...#|#...#|#...#|#.#.#|#.#.#|##.##|#...#",
|
||||
"X": "#...#|#...#|.#.#.|..#..|.#.#.|#...#|#...#",
|
||||
"Y": "#...#|#...#|.#.#.|..#..|..#..|..#..|..#..",
|
||||
"Z": "#####|....#|...#.|..#..|.#...|#....|#####",
|
||||
"0": ".###.|#...#|#..##|#.#.#|##..#|#...#|.###.",
|
||||
"1": "..#..|.##..|..#..|..#..|..#..|..#..|.###.",
|
||||
"2": ".###.|#...#|....#|...#.|..#..|.#...|#####",
|
||||
"3": "####.|....#|....#|.###.|....#|....#|####.",
|
||||
"4": "...#.|..##.|.#.#.|#..#.|#####|...#.|...#.",
|
||||
"5": "#####|#....|####.|....#|....#|#...#|.###.",
|
||||
"6": "..##.|.#...|#....|####.|#...#|#...#|.###.",
|
||||
"7": "#####|....#|...#.|..#..|.#...|.#...|.#...",
|
||||
"8": ".###.|#...#|#...#|.###.|#...#|#...#|.###.",
|
||||
"9": ".###.|#...#|#...#|.####|....#|...#.|.##..",
|
||||
".": ".....|.....|.....|.....|.....|.##..|.##..",
|
||||
",": ".....|.....|.....|.....|.##..|.##..|.#...",
|
||||
"/": "....#|....#|...#.|..#..|.#...|#....|#....",
|
||||
":": ".....|.##..|.##..|.....|.##..|.##..|.....",
|
||||
"-": ".....|.....|.....|#####|.....|.....|.....",
|
||||
"!": "..#..|..#..|..#..|..#..|..#..|.....|..#..",
|
||||
"?": ".###.|#...#|....#|...#.|..#..|.....|..#..",
|
||||
"+": ".....|..#..|..#..|#####|..#..|..#..|.....",
|
||||
"'": "..#..|..#..|.....|.....|.....|.....|.....",
|
||||
}
|
||||
|
||||
|
||||
def alpha(c, a: int = 255):
|
||||
return (c[0], c[1], c[2], a)
|
||||
|
||||
|
||||
def darker(c, f: float = 0.72):
|
||||
return alpha(tuple(int(v * f) for v in c[:3]))
|
||||
|
||||
|
||||
def lighter(c, f: float = 1.12):
|
||||
return alpha(tuple(min(255, int(v * f)) for v in c[:3]))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- Schrift ----
|
||||
def draw_text(d: ImageDraw.ImageDraw, x: int, y: int, text: str,
|
||||
color=CREAM) -> int:
|
||||
"""5x7-Pixelfont, 1 px Laufweite → 6 px Vorschub."""
|
||||
for ch in text.upper():
|
||||
glyph = FONT.get(ch)
|
||||
if glyph:
|
||||
for row, bits in enumerate(glyph.split("|")):
|
||||
for col, bit in enumerate(bits):
|
||||
if bit == "#":
|
||||
d.point((x + col, y + row), fill=color)
|
||||
x += 6
|
||||
return x
|
||||
|
||||
|
||||
def text_width(text: str) -> int:
|
||||
return max(0, len(text) * 6 - 1)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- Bausteine --
|
||||
def panel(d, box, fill=PANEL, line=LINE, bevel=True):
|
||||
"""Fläche mit Bevel (Licht oben links) und 1-px-Rahmenlinie."""
|
||||
x0, y0, x1, y1 = box
|
||||
d.rectangle((x0, y0, x1, y1), fill=fill)
|
||||
if bevel:
|
||||
d.line((x0 + 1, y0 + 1, x1 - 1, y0 + 1), fill=PANEL_HI)
|
||||
d.line((x0 + 1, y0 + 1, x0 + 1, y1 - 1), fill=PANEL_HI)
|
||||
d.line((x0 + 1, y1 - 1, x1 - 1, y1 - 1), fill=PANEL_LO)
|
||||
d.line((x1 - 1, y0 + 1, x1 - 1, y1 - 1), fill=PANEL_LO)
|
||||
if line is not None:
|
||||
d.rectangle((x0, y0, x1, y1), outline=line)
|
||||
return d
|
||||
|
||||
|
||||
def well(d, box, fill=PANEL_LO):
|
||||
"""Vertiefte Fläche: dunkel oben/links, Licht unten/rechts."""
|
||||
x0, y0, x1, y1 = box
|
||||
d.rectangle((x0, y0, x1, y1), fill=fill)
|
||||
d.line((x0, y0, x1, y0), fill=INK)
|
||||
d.line((x0, y0, x0, y1), fill=INK)
|
||||
d.line((x1, y0, x1, y1), fill=PANEL_HI)
|
||||
d.line((x0, y1, x1, y1), fill=PANEL_HI)
|
||||
|
||||
|
||||
def bar(d, x, y, w, h, label, value, vmax, color):
|
||||
draw_text(d, x, y + 1, label, CREAM_D)
|
||||
bx = x + text_width(label) + 4
|
||||
well(d, (bx, y, bx + w - 1, y + h - 1))
|
||||
fillw = round((w - 4) * value / vmax)
|
||||
if fillw > 0:
|
||||
d.rectangle((bx + 2, y + 2, bx + 1 + fillw, y + h - 3), fill=color)
|
||||
d.line((bx + 2, y + 2, bx + 1 + fillw, y + 2), fill=lighter(color, 1.15))
|
||||
draw_text(d, bx + w + 4, y + 1, f"{value}/{vmax}", CREAM_D)
|
||||
|
||||
|
||||
def title_bar(d, box, label):
|
||||
x0, y0, x1, y1 = box
|
||||
d.rectangle((x0, y0, x1, y1), fill=OCHRE_D)
|
||||
d.line((x0, y1, x1, y1), fill=INK)
|
||||
draw_text(d, x0 + 5, y0 + 3, label, CREAM)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ Elemente
|
||||
def elem_dialog(lines, name, height) -> Image.Image:
|
||||
"""Textbox mit Namensschild; height = Panelhöhe bei 1x."""
|
||||
w = 292
|
||||
im = Image.new("RGBA", (w, height + 5), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
d.rectangle((0, 5, w - 1, height + 4), fill=alpha(PANEL, 238))
|
||||
d.rectangle((0, 5, w - 1, height + 4), outline=INK)
|
||||
d.rectangle((1, 6, w - 2, height + 3), outline=LINE)
|
||||
d.line((2, 6, w - 3, 6), fill=PANEL_LO)
|
||||
|
||||
tw = text_width(name) + 10
|
||||
d.rectangle((6, 0, 6 + tw, 13), fill=OCHRE_D)
|
||||
d.rectangle((6, 0, 6 + tw, 13), outline=INK)
|
||||
d.line((7, 1, 5 + tw, 1), fill=OCHRE)
|
||||
draw_text(d, 11, 3, name, CREAM)
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
draw_text(d, 11, 21 + i * 10, line,
|
||||
CREAM if i < len(lines) - 1 else CREAM_D)
|
||||
|
||||
ax, ay = w - 13, height + 1
|
||||
for i in range(4):
|
||||
d.line((ax - i, ay - i, ax + i, ay - i), fill=OCHRE)
|
||||
return im
|
||||
|
||||
|
||||
def elem_buttons() -> Image.Image:
|
||||
labels = ["ATTACK", "TALK", "USE", "FLEE"]
|
||||
bw, bh, gap = 52, 14, 4
|
||||
im = Image.new("RGBA", (bw, (bh + gap) * 4 + 4), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
for i, (label, state) in enumerate(zip(labels, ["idle", "hover",
|
||||
"pressed", "disabled"])):
|
||||
y = i * (bh + gap)
|
||||
tw = text_width(label)
|
||||
if state == "hover":
|
||||
panel(d, (0, y, bw - 1, y + bh - 1), fill=OCHRE_D, line=GOLD)
|
||||
draw_text(d, (bw - tw) // 2, y + 4, label, CREAM)
|
||||
elif state == "pressed":
|
||||
well(d, (0, y, bw - 1, y + bh - 1), fill=(30, 25, 21, 255))
|
||||
draw_text(d, (bw - tw) // 2 + 1, y + 5, label, CREAM_D)
|
||||
elif state == "disabled":
|
||||
panel(d, (0, y, bw - 1, y + bh - 1), fill=(44, 37, 32, 255),
|
||||
line=(74, 62, 50, 255), bevel=False)
|
||||
draw_text(d, (bw - tw) // 2, y + 4, label, (98, 86, 70, 255))
|
||||
else:
|
||||
panel(d, (0, y, bw - 1, y + bh - 1))
|
||||
draw_text(d, (bw - tw) // 2, y + 4, label, CREAM)
|
||||
return im
|
||||
|
||||
|
||||
def icon_sword() -> Image.Image:
|
||||
return Image.open(SWORD).convert("RGBA").resize((18, 18), Image.NEAREST)
|
||||
|
||||
|
||||
def icon_herb() -> Image.Image:
|
||||
im = Image.new("RGBA", (18, 18), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
d.polygon([(9, 1), (12, 7), (9, 16), (6, 7)], fill=OLIVE)
|
||||
d.line((9, 3, 9, 14), fill=OLIVE_D)
|
||||
d.line((7, 8, 4, 12), fill=OLIVE_D)
|
||||
d.line((11, 8, 14, 12), fill=OLIVE_D)
|
||||
return im
|
||||
|
||||
|
||||
def icon_coin() -> Image.Image:
|
||||
im = Image.new("RGBA", (18, 18), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
d.ellipse((3, 5, 14, 16), fill=OCHRE)
|
||||
d.ellipse((4, 6, 13, 15), outline=GOLD)
|
||||
return im
|
||||
|
||||
|
||||
def elem_slots() -> Image.Image:
|
||||
s, gap = 22, 3
|
||||
im = Image.new("RGBA", (s * 6 + gap * 5, s + 6), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
for i, sprite in enumerate([None, icon_sword(), icon_herb(), None,
|
||||
icon_coin(), None]):
|
||||
x = i * (s + gap)
|
||||
well(d, (x, 3, x + s - 1, 3 + s - 1))
|
||||
if sprite is not None:
|
||||
im.alpha_composite(sprite, (x + 2, 5))
|
||||
if i == 4: # Auswahl: 2-px-Rahmen + Stapelzahl
|
||||
d.rectangle((x, 3, x + s - 1, 3 + s - 1), outline=GOLD)
|
||||
d.rectangle((x + 1, 4, x + s - 2, 2 + s), outline=GOLD)
|
||||
d.rectangle((x + 7, 13, x + s - 2, 3 + s - 2), fill=INK)
|
||||
draw_text(d, x + 8, 15, "12", GOLD)
|
||||
if i == 5: # gesperrt: Schraffur, auf die Slot-Fläche beschnitten
|
||||
hatch = Image.new("RGBA", (s, s), (0, 0, 0, 0))
|
||||
hd2 = ImageDraw.Draw(hatch)
|
||||
for k in range(-s, s, 5):
|
||||
hd2.line((k, s - 1, k + s - 1, 0), fill=(54, 46, 38, 255))
|
||||
im.alpha_composite(hatch, (x, 3))
|
||||
d.line((x, 3, x + s - 1, 3), fill=INK)
|
||||
d.line((x, 3, x, 3 + s - 1), fill=INK)
|
||||
d.line((x + s - 1, 3, x + s - 1, 3 + s - 1), fill=PANEL_HI)
|
||||
d.line((x, 3 + s - 1, x + s - 1, 3 + s - 1), fill=PANEL_HI)
|
||||
return im
|
||||
|
||||
|
||||
def elem_pack() -> Image.Image:
|
||||
w, h = 148, 112
|
||||
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
panel(d, (0, 0, w - 1, h - 1), line=INK)
|
||||
d.rectangle((1, 1, w - 2, h - 2), outline=LINE)
|
||||
title_bar(d, (2, 2, w - 3, 14), "PACK")
|
||||
|
||||
d.rectangle((w - 15, 4, w - 5, 12), fill=PANEL_LO)
|
||||
d.rectangle((w - 15, 4, w - 5, 12), outline=LINE)
|
||||
d.line((w - 12, 6, w - 8, 10), fill=CREAM_D)
|
||||
d.line((w - 8, 6, w - 12, 10), fill=CREAM_D)
|
||||
|
||||
s, gap, ox, oy = 22, 4, 6, 19
|
||||
for row in range(3):
|
||||
for col in range(5):
|
||||
x = ox + col * (s + gap)
|
||||
y = oy + row * (s + gap)
|
||||
well(d, (x, y, x + s - 1, y + s - 1))
|
||||
|
||||
draw_text(d, 7, h - 11, "LOAD 42/60", CREAM_D)
|
||||
draw_text(d, w - 7 - text_width("128 GOLD"), h - 11, "128 GOLD", GOLD)
|
||||
return im
|
||||
|
||||
|
||||
def rune(kind: str) -> Image.Image:
|
||||
"""14x14-Magiesymbole für das Zauberbuch."""
|
||||
im = Image.new("RGBA", (14, 14), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
if kind == "fire":
|
||||
d.polygon([(7, 0), (13, 7), (11, 13), (3, 13), (1, 7)], fill=BLOOD)
|
||||
d.polygon([(7, 5), (10, 8), (9, 12), (5, 12), (4, 8)], fill=GOLD)
|
||||
elif kind == "ice":
|
||||
d.polygon([(7, 0), (13, 7), (7, 13), (1, 7)], fill=SLATE)
|
||||
d.polygon([(7, 3), (10, 7), (7, 11), (4, 7)], fill=CREAM)
|
||||
elif kind == "bolt":
|
||||
d.polygon([(9, 0), (3, 7), (6, 7), (4, 13), (11, 5), (8, 5)], fill=GOLD)
|
||||
elif kind == "ward":
|
||||
d.ellipse((1, 1, 12, 12), outline=CREAM)
|
||||
d.line((7, 3, 7, 10), fill=CREAM)
|
||||
d.line((4, 6, 10, 6), fill=CREAM)
|
||||
elif kind == "eye":
|
||||
d.ellipse((1, 4, 12, 10), fill=CREAM)
|
||||
d.ellipse((5, 5, 8, 9), fill=INK)
|
||||
elif kind == "leaf":
|
||||
d.polygon([(7, 0), (12, 7), (7, 13), (2, 7)], fill=OLIVE)
|
||||
d.line((7, 2, 7, 11), fill=OLIVE_D)
|
||||
elif kind == "star":
|
||||
d.polygon([(7, 0), (8, 5), (13, 7), (8, 8), (7, 13), (6, 8),
|
||||
(1, 7), (6, 5)], fill=GOLD)
|
||||
elif kind == "skull":
|
||||
d.rectangle((3, 1, 10, 8), fill=CREAM)
|
||||
d.rectangle((4, 9, 9, 11), fill=CREAM)
|
||||
d.point((5, 4), fill=INK)
|
||||
d.point((8, 4), fill=INK)
|
||||
d.point((6, 6), fill=INK)
|
||||
return im
|
||||
|
||||
|
||||
def elem_spells() -> Image.Image:
|
||||
w, h = 148, 116
|
||||
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
panel(d, (0, 0, w - 1, h - 1), line=INK)
|
||||
d.rectangle((1, 1, w - 2, h - 2), outline=LINE)
|
||||
title_bar(d, (2, 2, w - 3, 14), "SPELLBOOK")
|
||||
|
||||
# Schulen-Tabs, der erste aktiv
|
||||
for i, (label, active) in enumerate([("ARCANE", True), ("DIVINE", False)]):
|
||||
x = 6 + i * 46
|
||||
panel(d, (x, 17, x + 43, 29), fill=OCHRE_D if active else PANEL_LO,
|
||||
line=GOLD if active else LINE, bevel=not active)
|
||||
draw_text(d, x + 5, 21, label, CREAM if active else CREAM_D)
|
||||
|
||||
spells = [("fire", 3), ("ice", 2), ("bolt", 2), ("ward", 1), ("eye", 4),
|
||||
("leaf", 1), ("star", 3), (None, 0), (None, 0), (None, 0),
|
||||
(None, 0), (None, 0), (None, 0), (None, 0), (None, 0)]
|
||||
s, gap, ox, oy = 20, 4, 16, 33
|
||||
for idx, (kind, cost) in enumerate(spells):
|
||||
col, row = idx % 5, idx // 5
|
||||
x = ox + col * (s + gap)
|
||||
y = oy + row * (s + gap)
|
||||
well(d, (x, y, x + s - 1, y + s - 1))
|
||||
if kind:
|
||||
im.alpha_composite(rune(kind), (x + 3, y + 2))
|
||||
d.rectangle((x + s - 8, y + s - 8, x + s - 2, y + s - 2), fill=INK)
|
||||
draw_text(d, x + s - 7, y + s - 7, str(cost), GOLD)
|
||||
if idx == 0: # gewählter Zauber
|
||||
d.rectangle((x, y, x + s - 1, y + s - 1), outline=GOLD)
|
||||
d.rectangle((x + 1, y + 1, x + s - 2, y + s - 2), outline=GOLD)
|
||||
|
||||
draw_text(d, 7, h - 11, "MEM 3/6 SLOTS", CREAM_D)
|
||||
draw_text(d, w - 7 - text_width("LVL 4"), h - 11, "LVL 4", GOLD)
|
||||
return im
|
||||
|
||||
|
||||
def elem_party() -> Image.Image:
|
||||
fw, fh, gap = 34, 34, 4
|
||||
im = Image.new("RGBA", (fw, fh * 3 + gap * 2), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
figures = [(SLATE_D, OCHRE_D, (176, 140, 108, 255), (26, 30)),
|
||||
(OLIVE_D, PANEL_HI, (156, 122, 94, 255), (12, 30)),
|
||||
(PANEL_HI, SLATE_D, (150, 118, 92, 255), (30, 30))]
|
||||
for i, (hood, trim, skin, hp) in enumerate(figures):
|
||||
y = i * (fh + gap)
|
||||
panel(d, (0, y, fw - 1, y + fh - 1))
|
||||
well(d, (3, y + 3, fw - 4, y + 26))
|
||||
bust(d, 3, y + 3, hood, trim, skin)
|
||||
fillw = round(24 * hp[0] / hp[1])
|
||||
d.rectangle((4, y + 29, 4 + fillw, y + 31), fill=BLOOD)
|
||||
d.rectangle((4, y + 29, fw - 5, y + 31), outline=INK)
|
||||
if i == 0:
|
||||
d.rectangle((0, y, fw - 1, y + fh - 1), outline=GOLD)
|
||||
return im
|
||||
|
||||
|
||||
def bust(d, x, y, hood, trim, skin):
|
||||
"""Flache Kopf-Schulter-Silhouette, 26x26 — für Party-Rahmen.
|
||||
|
||||
Ein Crop aus dem Vollkörper-Sprite (64x80) auf 26x26 ist ein Fleck;
|
||||
gezeichnete Formen bleiben auch bei 1x lesbar.
|
||||
"""
|
||||
d.polygon([(x + 1, y + 25), (x + 4, y + 17), (x + 9, y + 15),
|
||||
(x + 17, y + 15), (x + 22, y + 17), (x + 25, y + 25)], fill=trim)
|
||||
d.ellipse((x + 6, y + 1, x + 20, y + 20), fill=hood)
|
||||
d.ellipse((x + 9, y + 6, x + 17, y + 17), fill=darker(hood, 0.55))
|
||||
d.ellipse((x + 10, y + 7, x + 16, y + 16), fill=skin)
|
||||
d.point((x + 11, y + 11), fill=INK)
|
||||
d.point((x + 15, y + 11), fill=INK)
|
||||
d.line((x + 12, y + 14, x + 14, y + 14), fill=darker(skin, 0.6))
|
||||
d.line((x + 7, y + 4, x + 11, y + 2), fill=darker(hood, 1.25))
|
||||
|
||||
|
||||
def elem_misc() -> Image.Image:
|
||||
im = Image.new("RGBA", (170, 104), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
bar(d, 0, 0, 52, 10, "HP", 24, 30, BLOOD)
|
||||
bar(d, 0, 12, 52, 10, "SP", 11, 20, OLIVE)
|
||||
bar(d, 0, 24, 52, 10, "MP", 3, 15, SLATE)
|
||||
|
||||
for i, on in enumerate([False, True]):
|
||||
x = 112 + i * 16
|
||||
well(d, (x, 2, x + 11, 13))
|
||||
if on:
|
||||
d.line((x + 2, 7, x + 4, 10), fill=GOLD)
|
||||
d.line((x + 4, 10, x + 9, 4), fill=GOLD)
|
||||
|
||||
sx, sy = 0, 57
|
||||
draw_text(d, sx, 46, "VOLUME", CREAM_D)
|
||||
well(d, (sx, sy, sx + 64, sy + 5))
|
||||
d.rectangle((sx + 1, sy + 1, sx + 34, sy + 4), fill=OCHRE_D)
|
||||
panel(d, (sx + 31, sy - 4, sx + 39, sy + 8), bevel=False)
|
||||
|
||||
panel(d, (88, 40, 168, 65), fill=alpha((30, 25, 21, 255), 246), line=INK)
|
||||
draw_text(d, 93, 44, "RUSTY SWORD", CREAM)
|
||||
draw_text(d, 93, 54, "1D6+1 SLASH", CREAM_D)
|
||||
|
||||
cx, cy = 112, 76
|
||||
d.polygon([(cx, cy), (cx + 11, cy + 4), (cx + 5, cy + 6),
|
||||
(cx + 8, cy + 12), (cx + 5, cy + 13), (cx + 3, cy + 7),
|
||||
(cx, cy + 7)], fill=CREAM, outline=INK)
|
||||
return im
|
||||
|
||||
|
||||
def elem_combat() -> Image.Image:
|
||||
"""Kampf-Aktionsleiste: Initiative-Reihe oben, Aktionen unten."""
|
||||
w, h = 300, 40
|
||||
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
# Initiative: Chips, der aktive in GOLD, Gegner in BLOOD
|
||||
for i in range(8):
|
||||
x = 6 + i * 12
|
||||
chip = [(SLATE, None), (SLATE, None), (BLOOD, None), (GOLD, INK),
|
||||
(SLATE, None), (BLOOD, None), (SLATE, None), (BLOOD, None)][i]
|
||||
d.rectangle((x, 1, x + 8, 9), fill=chip[0])
|
||||
d.rectangle((x, 1, x + 8, 9), outline=INK if chip[1] is None else GOLD)
|
||||
draw_text(d, 110, 2, "RND 3", CREAM_D)
|
||||
|
||||
panel(d, (0, 13, w - 1, h - 1), fill=alpha(PANEL, 236), line=INK)
|
||||
labels = ["ATTACK", "MOVE", "SPELL", "ITEM", "DEFEND"]
|
||||
for i, label in enumerate(labels):
|
||||
x = 6 + i * 47
|
||||
panel(d, (x, 19, x + 42, 34), fill=OCHRE_D if label == "SPELL" else PANEL,
|
||||
line=GOLD if label == "SPELL" else LINE)
|
||||
tw = text_width(label)
|
||||
draw_text(d, x + (43 - tw) // 2, 23, label,
|
||||
CREAM if label == "SPELL" else CREAM_D)
|
||||
panel(d, (241, 19, 293, 34), fill=PANEL, line=LINE)
|
||||
draw_text(d, 241 + (53 - text_width("END TURN")) // 2, 23, "END TURN", CREAM)
|
||||
return im
|
||||
|
||||
|
||||
def elem_loadbar() -> Image.Image:
|
||||
w, h = 180, 20
|
||||
im = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
draw_text(d, 0, 0, "LOADING THE HARBOUR", CREAM_D)
|
||||
draw_text(d, w - text_width("62%"), 0, "62%", CREAM_D)
|
||||
well(d, (0, 9, w - 1, h - 1))
|
||||
fillw = round((w - 4) * 0.62)
|
||||
d.rectangle((2, 11, 1 + fillw, h - 2), fill=OCHRE_D)
|
||||
d.line((2, 11, 1 + fillw, 11), fill=OCHRE)
|
||||
# Segmentmarken alle 10 %
|
||||
for k in range(1, 10):
|
||||
x = 2 + round((w - 4) * k / 10)
|
||||
d.line((x, 11, x, h - 2), fill=alpha(INK, 150))
|
||||
return im
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ Mocks ---
|
||||
def mock_hud(scene: Path) -> Image.Image:
|
||||
"""Szene als Hintergrund, UI darüber — die Lesbarkeitsprobe bei 1x."""
|
||||
base = Image.open(scene).convert("RGBA").resize((320, 180), Image.LANCZOS)
|
||||
d = ImageDraw.Draw(base)
|
||||
|
||||
base.alpha_composite(elem_party(), (320 - 34 - 6, 6))
|
||||
|
||||
panel(d, (6, 6, 46, 20), fill=alpha(PANEL, 232))
|
||||
draw_text(d, 11, 10, "MENU", CREAM)
|
||||
|
||||
d.rectangle((153, 6, 166, 20), fill=alpha(PANEL, 232))
|
||||
d.rectangle((153, 6, 166, 20), outline=LINE)
|
||||
draw_text(d, 156, 10, "N", GOLD)
|
||||
|
||||
base.alpha_composite(
|
||||
elem_dialog(["THE HARBOUR IS QUIET TONIGHT. TOO QUIET",
|
||||
"FOR A TOWN THAT SMELLS OF SALT AND IRON.",
|
||||
"WHAT DO YOU WANT TO DO?"], "ALDRIC THE GREY", 54),
|
||||
(14, 116))
|
||||
d.rectangle((0, 0, 319, 179), outline=INK)
|
||||
return base
|
||||
|
||||
|
||||
def palette_anchor() -> Image.Image:
|
||||
"""Palette-Anker für `pixelize.py --palette` (16 Farben, 4x4-Raster)."""
|
||||
im = Image.new("RGB", (32, 32), INK[:3])
|
||||
for i, c in enumerate(PALETTE[:16]):
|
||||
x, y = (i % 4) * 8, (i // 4) * 8
|
||||
ImageDraw.Draw(im).rectangle((x, y, x + 7, y + 7), fill=c[:3])
|
||||
return im
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ Ausgabe --
|
||||
def save(im: Image.Image, out: Path, name: str, scale: int) -> None:
|
||||
if scale > 1:
|
||||
im = im.resize((im.width * scale, im.height * scale), Image.NEAREST)
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
path = out / f"{name}.png"
|
||||
im.save(path)
|
||||
px = list(im.getdata())
|
||||
colors = len({p[:3] for p in px if len(p) < 4 or p[3] > 0})
|
||||
print(f"{name:28s} {im.width:4d}x{im.height:<4d} {colors:5d} Farben")
|
||||
|
||||
|
||||
def main(argv=None) -> None:
|
||||
ap = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--out", type=Path, default=FINAL / "UI")
|
||||
ap.add_argument("--scale", type=int, default=4,
|
||||
help="1 = Basisgröße, 4 = Auslieferung (Default)")
|
||||
a = ap.parse_args(argv)
|
||||
|
||||
elements = {
|
||||
"ui_dialog_292x59": elem_dialog(
|
||||
["THE HARBOUR IS QUIET TONIGHT. TOO QUIET",
|
||||
"FOR A TOWN THAT SMELLS OF SALT AND IRON.",
|
||||
"WHAT DO YOU WANT TO DO?"], "ALDRIC THE GREY", 54),
|
||||
"ui_dialog_gross_292x89": elem_dialog(
|
||||
["THE HARBOUR IS QUIET TONIGHT. TOO QUIET FOR",
|
||||
"A TOWN THAT SMELLS OF SALT AND IRON. THE",
|
||||
"LANTERNS SWING, THE GULLS HAVE GONE TO",
|
||||
"ROOST, AND THE TIDE IS COMING IN UNDER",
|
||||
"THE PIER. SOMETHING IS WRONG WITH THE",
|
||||
"WATER, AND NOBODY WILL SAY WHAT."],
|
||||
"ALDRIC THE GREY", 84),
|
||||
"ui_buttons_52x14": elem_buttons(),
|
||||
"ui_slots_22px": elem_slots(),
|
||||
"ui_window_pack_148x112": elem_pack(),
|
||||
"ui_window_zauber_148x116": elem_spells(),
|
||||
"ui_party_34px": elem_party(),
|
||||
"ui_misc_170x104": elem_misc(),
|
||||
"ui_kampf_leiste_300x40": elem_combat(),
|
||||
"ui_ladebalken_180x20": elem_loadbar(),
|
||||
}
|
||||
for name, im in elements.items():
|
||||
save(im, a.out, name, a.scale)
|
||||
|
||||
save(mock_hud(SCENE_B), a.out, "_mock_hud_B_1280x720", a.scale)
|
||||
save(mock_hud(SCENE_A), a.out, "_mock_hud_A_1280x720", a.scale)
|
||||
save(palette_anchor(), a.out, "_palette_ui", 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||