91 lines
3.4 KiB
Python
91 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""화면 UI 배치 미리보기: 기기 화면 크기별로 UI 상자와 로블록스 조이스틱·점프 버튼 자리를 그립니다.
|
|
실제 글자·색은 아니고 위치·크기만 맞습니다.
|
|
|
|
python3 tools/hud_preview.py out.png
|
|
"""
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
DEVICES = [
|
|
("iPhone SE", 667, 375 - 58, True),
|
|
("iPhone 15", 844 - 94, 390 - 58, True),
|
|
("Android 800x360", 800, 360 - 58, True),
|
|
("iPad 1024x768", 1024, 768 - 58, True),
|
|
("PC 1366x768", 1366, 768 - 58, False),
|
|
]
|
|
BOXES = [
|
|
("money", "돈", (255, 130, 50)),
|
|
("carry", "들고 있는 접시", (200, 160, 120)),
|
|
("hint", "튜토리얼 안내", (255, 235, 120)),
|
|
("toasts", "알림 자리", (120, 120, 150)),
|
|
("card", "다음 업그레이드", (255, 248, 235)),
|
|
("buy", "사기", (70, 190, 90)),
|
|
("settings", "설정", (80, 140, 230)),
|
|
("list", "업그레이드 목록", (255, 130, 50)),
|
|
("double", "2배 수익", (150, 80, 220)),
|
|
("boost", "돈 부스트", (240, 170, 30)),
|
|
("promote", "홍보", (74, 172, 255)),
|
|
("rush", "손님 러시", (255, 196, 48)),
|
|
]
|
|
|
|
|
|
def font(size):
|
|
for path in ("/usr/share/fonts/truetype/nanum/NanumGothicBold.ttf",
|
|
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
|
|
"/usr/share/fonts/truetype/noto/NotoSansCJK-Bold.ttc"):
|
|
if os.path.exists(path):
|
|
return ImageFont.truetype(path, size)
|
|
return ImageFont.load_default()
|
|
|
|
|
|
def layout(w, h, touch):
|
|
out = subprocess.run(["lune", "run", "tools/hud_layout.luau", str(w), str(h), "touch" if touch else "pc"],
|
|
cwd=ROOT, capture_output=True, text=True, check=True).stdout
|
|
return json.loads(out)
|
|
|
|
|
|
def draw_device(name, w, h, touch):
|
|
L = layout(w, h, touch)
|
|
s = L["scale"]
|
|
img = Image.new("RGB", (w, h + 30), (40, 40, 40))
|
|
d = ImageDraw.Draw(img, "RGBA")
|
|
d.rectangle([0, 30, w - 1, h + 29], fill=(110, 160, 110))
|
|
d.text((6, 4), f"{name} UI 영역 {w}x{h} 배율 {s:.2f}", fill=(255, 255, 255), font=font(18))
|
|
if touch:
|
|
for key, label in (("stick", "조이스틱 자리"), ("jump", "점프 버튼 자리")):
|
|
z = L["zones"][key]
|
|
d.rectangle([z["x"], z["y"] + 30, z["x"] + z["w"], z["y"] + z["h"] + 30], fill=(255, 0, 0, 60),
|
|
outline=(255, 60, 60), width=2)
|
|
d.text((z["x"] + 6, z["y"] + z["h"] + 30 - 22), label, fill=(255, 220, 220), font=font(14))
|
|
for key, label, color in BOXES:
|
|
r = L[key]
|
|
x0, y0 = r["x"] * s, r["y"] * s + 30
|
|
x1, y1 = x0 + r["w"] * s, y0 + r["h"] * s
|
|
alpha = 90 if key == "toasts" else 230
|
|
d.rounded_rectangle([x0, y0, x1, y1], radius=6, fill=color + (alpha,), outline=(255, 255, 255), width=2)
|
|
d.text((x0 + 4, y0 + 2), label, fill=(20, 20, 20), font=font(max(10, int(15 * s))))
|
|
return img
|
|
|
|
|
|
def main(argv):
|
|
out = argv[1] if len(argv) > 1 else "hud_preview.png"
|
|
imgs = [draw_device(*dev) for dev in DEVICES]
|
|
width = max(i.width for i in imgs)
|
|
sheet = Image.new("RGB", (width, sum(i.height + 10 for i in imgs)), (25, 25, 25))
|
|
y = 0
|
|
for i in imgs:
|
|
sheet.paste(i, (0, y))
|
|
y += i.height + 10
|
|
sheet.save(out)
|
|
print(out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv)
|