Fichiers

62 lignes
2.6 KiB
Python

"""Génère l'arrière-plan de l'accueil GastinelClient (1920x1080, PNG).
Papier réchauffé, courbes de niveau fines (relief imaginaire façon Vercors), une ligne de crête
à l'encre et un repère orange. La moitié gauche reste presque vide pour le menu.
Usage : python outils/fond.py (écrit src/main/resources/assets/gastinelclient/textures/gui/fond.png)
"""
import os
import numpy as np
from PIL import Image, ImageDraw
W, H, SS = 1920, 1080, 2 # sur-échantillonnage x2 pour adoucir les traits
PAPIER = np.array([242, 240, 230], float)
FILET = np.array([218, 213, 200], float)
FILET_FORT = np.array([196, 188, 170], float)
ys, xs = np.mgrid[0:H * SS, 0:W * SS].astype(float) / SS
u, v = xs / W, ys / H
# Relief : un plateau (falaises) à droite + ondulations douces
relief = (
1.6 * np.exp(-((u - 0.78) ** 2 / 0.05 + (v - 0.62) ** 2 / 0.09))
+ 0.9 * np.exp(-((u - 0.98) ** 2 / 0.02 + (v - 0.25) ** 2 / 0.05))
+ 0.25 * np.sin(5.1 * u + 2.3 * v) * np.cos(3.7 * v - 1.2 * u)
+ 0.12 * np.sin(13 * u + 7 * v + 1.0)
)
k = 18.0
f = relief * k
d = np.abs(f - np.round(f)) # distance à la courbe la plus proche
grad = np.hypot(*np.gradient(f, 1.0 / SS)) + 1e-6
dist_px = d / grad
ligne = np.clip(1.2 - dist_px * 1.4, 0, 1)
maitresse = (np.round(f).astype(int) % 5 == 0)
# Masque : rien sous le menu à gauche, apparition progressive vers la droite
masque = np.clip((u - 0.34) / 0.22, 0, 1) ** 1.5
img = np.ones((H * SS, W * SS, 3)) * PAPIER
coul = np.where(maitresse[..., None], FILET_FORT, FILET)
a = (ligne * masque)[..., None]
img = img * (1 - a) + coul * a
pil = Image.fromarray(img.astype(np.uint8)).resize((W, H), Image.LANCZOS)
dr = ImageDraw.Draw(pil)
# Ligne de crête (encre), polyline anguleuse : pas d'arrondi
crete = [(1010, 820), (1120, 760), (1185, 772), (1260, 690), (1330, 668), (1372, 600),
(1460, 596), (1520, 640), (1600, 560), (1700, 548), (1770, 610), (1920, 590)]
dr.line(crete, fill=(45, 42, 38), width=2)
# Repère du spawn : carré orange franc + filet vertical
sx, sy = 1460, 596
dr.line([(sx, sy - 120), (sx, sy - 8)], fill=(45, 42, 38), width=1)
dr.rectangle([sx - 6, sy - 6 - 120, sx + 6, sy + 6 - 120], fill=(232, 89, 12))
# Croix de repérage dans les coins (filets fins)
for cx, cy in [(1840, 80), (1840, 1000), (760, 80), (760, 1000)]:
dr.line([(cx - 10, cy), (cx + 10, cy)], fill=(160, 152, 136), width=1)
dr.line([(cx, cy - 10), (cx, cy + 10)], fill=(160, 152, 136), width=1)
out = os.path.join(os.path.dirname(__file__), "..", "src", "main", "resources", "assets",
"gastinelclient", "textures", "gui", "fond.png")
pil.save(out, optimize=True)
print("écrit", os.path.normpath(out), pil.size)