ThreeKingdomsSlingshot/Tools/make_tornado_texture.py

107 lines
5.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# 제갈근 선풍계 회오리 그림(2026-11-19 PD 「제갈근의 회오리가 여전히 부자연스러워 · 첨부 파일과 같은 느낌이 되면 좋겠어」 =
# 평평한 만화 회오리: 아래로 갈수록 작아지는 기운 타원 층을 겹쳐 쌓고(아래 층이 앞) · 층마다 밝은 면 · 몸 · 그늘 3단 · 층 둘레를 감는 가는 띠 · 끝에 작은 먼지).
# 출력 = Assets/VFX/TKS2D/sk_tornado_sheet.png (4 × 4 칸 = 16 장 · 한 바퀴 회전 · 칸 256) — Tools/build_tornado.cs 가 입자 1개 · 칸 넘김 애니로 프리팹을 만든다.
# 색 = 첨부 그림의 회청색 3단 + 이 게임 그림처럼 옅은 남색 외곽선(먹색 대신 · 그림 색과 어울리게).
# 실행: python -I -X utf8 Tools/make_tornado_texture.py <게임 레포>
import math
import os
import sys
from PIL import Image, ImageDraw, ImageFilter, ImageChops
game = sys.argv[1]
OUT = os.path.join(game, 'Assets', 'VFX', 'TKS2D', 'sk_tornado_sheet.png')
CELL = 256
GRID = 4
SS = 4 # 그릴 때 배율(가장자리 매끈하게)
N = GRID * GRID
LAYERS = 10
TILT = math.radians(-8) # 층 타원 기울기
LIGHT = (214, 222, 242)
MID = (172, 184, 222)
DARK = (136, 150, 196)
DEEP = (112, 126, 176)
LINE = (88, 100, 150) # 외곽선
OUTLINE_PX = 2 # 칸 256 기준 외곽선 굵기
def rot(x, y, cx, cy):
c, s = math.cos(TILT), math.sin(TILT)
dx, dy = x - cx, y - cy
return cx + dx * c - dy * s, cy + dx * s + dy * c
def ellipse_poly(cx, cy, a, b, n=72):
return [rot(cx + a * math.cos(2 * math.pi * k / n), cy + b * math.sin(2 * math.pi * k / n), cx, cy) for k in range(n)]
def band(cx, cy, a, b, phi0, span, r_in, r_out, n=40):
"""타원 둘레를 따라가는 끝이 가는 띠(바깥 반지름 r_out · 안 r_in · 가운데가 가장 굵음)."""
outer, inner = [], []
for k in range(n + 1):
u = k / n
phi = phi0 + span * u
w = math.sin(math.pi * u) ** 0.8
ro = r_in + (r_out - r_in) * (0.5 + 0.5 * w)
ri = r_in + (r_out - r_in) * (0.5 - 0.5 * w)
outer.append(rot(cx + a * ro * math.cos(phi), cy + b * ro * math.sin(phi), cx, cy))
inner.append(rot(cx + a * ri * math.cos(phi), cy + b * ri * math.sin(phi), cx, cy))
return outer + inner[::-1]
def frame(p):
S = CELL * SS
img = Image.new('RGBA', (S, S), (0, 0, 0, 0))
for i in range(LAYERS): # 0 = 맨 위(뒤 · 가장 큼) → 아래(앞 · 작음)
t = 1.0 - i / (LAYERS - 1)
w = (0.10 + 0.66 * t ** 1.05) * S
a, b = w * 0.5, w * 0.5 * 0.40
cy = (0.90 - 0.66 * t ** 1.15) * S
sway = math.sin(2 * math.pi * (p + i * 0.16)) * 0.025 * S * (0.4 + 0.6 * (1 - t))
cx = 0.5 * S + 0.06 * S * (t - 0.5) + sway
spin = 2 * math.pi * p + i * 0.75 # 층마다 띠의 시작 각(한 바퀴 = 16 장)
layer = Image.new('RGBA', (S, S), (0, 0, 0, 0))
d = ImageDraw.Draw(layer)
d.polygon(ellipse_poly(cx, cy, a, b), fill=DARK + (255,))
d.polygon(ellipse_poly(cx - 0.05 * a, cy - 0.16 * b, a * 0.93, b * 0.86), fill=MID + (255,))
# 도는 띠: 밝은 넓은 띠 · 짙은 띠 · 밝은 가는 띠 (타원 안쪽으로 잘림)
mask = Image.new('L', (S, S), 0)
ImageDraw.Draw(mask).polygon(ellipse_poly(cx, cy, a, b), fill=255)
inner = Image.new('RGBA', (S, S), (0, 0, 0, 0))
di = ImageDraw.Draw(inner)
di.polygon(band(cx, cy, a, b, spin, 2.2, 0.45, 1.02), fill=LIGHT + (255,))
di.polygon(band(cx, cy, a, b, spin + 2.4, 1.6, 0.55, 1.0), fill=DEEP + (255,))
di.polygon(band(cx, cy, a, b, spin + 4.3, 1.3, 0.25, 0.62), fill=LIGHT + (255,))
inner.putalpha(ImageChops.multiply(inner.getchannel('A'), mask))
layer = Image.alpha_composite(layer, inner)
# 바깥을 감는 가는 띠(위쪽 큰 층만 · 타원 밖으로 뻗음)
if t > 0.35:
d = ImageDraw.Draw(layer)
d.polygon(band(cx, cy, a, b, spin + 0.6, 1.9, 1.04, 1.22), fill=MID + (255,))
d.polygon(band(cx, cy, a, b, spin + 3.6, 1.4, 1.03, 1.15), fill=LIGHT + (255,))
img = Image.alpha_composite(img, layer)
# 끝 = 작은 소용돌이 먼지
d = ImageDraw.Draw(img)
for k in range(6):
ang = 2 * math.pi * (p * 1.5 + k / 6)
r = (0.012 + 0.008 * ((k * 7) % 3)) * S
x = 0.5 * S + math.cos(ang) * 0.045 * S
y = 0.925 * S + math.sin(ang) * 0.012 * S
d.ellipse([x - r, y - r, x + r, y + r], fill=LIGHT + (255,))
small = img.resize((CELL, CELL), Image.LANCZOS)
# 외곽선 = 그림 알파를 굵힌 자리에 옅은 남색을 깔고 그 위에 그림
al = small.getchannel('A').point(lambda v: 255 if v > 40 else 0)
grow = al.filter(ImageFilter.MaxFilter(OUTLINE_PX * 2 + 1)).filter(ImageFilter.GaussianBlur(0.6))
base = Image.new('RGBA', (CELL, CELL), LINE + (0,))
base.putalpha(grow)
return Image.alpha_composite(base, small)
sheet = Image.new('RGBA', (CELL * GRID, CELL * GRID), (0, 0, 0, 0))
for f in range(N):
sheet.paste(frame(f / N), ((f % GRID) * CELL, (f // GRID) * CELL))
os.makedirs(os.path.dirname(OUT), exist_ok=True)
sheet.save(OUT)
print('ok', OUT, sheet.size)