first commit

This commit is contained in:
2026-09-19 17:24:02 +08:00
commit afb343aa49
109 changed files with 13011 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(r"C:\milimoe\osm-game")
CHARACTER = ROOT / "assets/images/2d-game-characters/02-xinyin"
LEFT = CHARACTER / "assembled/front-right/xinyin-front-right-neutral-assembly-v4.png"
RIGHT = CHARACTER / "assembled/front-left/xinyin-front-left-neutral-assembly-v4.png"
OUTPUT = CHARACTER / "previews/xinyin-4way-direction-map-v1.png"
FONT = Path(r"C:\Windows\Fonts\msyh.ttc")
def font(size):
return ImageFont.truetype(str(FONT), size)
def fit(image, size):
result = image.copy()
result.thumbnail(size, Image.Resampling.LANCZOS)
return result
def checker(size, cell=20):
image = Image.new("RGB", size, (239, 243, 248))
draw = ImageDraw.Draw(image)
for y in range(0, size[1], cell):
for x in range(0, size[0], cell):
if (x // cell + y // cell) % 2:
draw.rectangle((x, y, x + cell - 1, y + cell - 1), fill=(219, 226, 234))
return image
def paste_character(canvas, path, rect):
x0, y0, x1, y1 = rect
panel = checker((x1 - x0, y1 - y0))
character = fit(Image.open(path).convert("RGBA"), (x1 - x0 - 30, y1 - y0 - 30))
panel.paste(character, ((panel.width - character.width) // 2, (panel.height - character.height) // 2), character)
canvas.paste(panel, (x0, y0))
def placeholder(draw, rect, arrow, title, subtitle):
x0, y0, x1, y1 = rect
draw.rounded_rectangle(rect, radius=18, fill=(32, 40, 55), outline=(71, 88, 113), width=2)
draw.text(((x0 + x1) // 2, y0 + 36), arrow, font=font(70), fill=(103, 203, 255), anchor="ma")
draw.text(((x0 + x1) // 2, y0 + 122), title, font=font(28), fill=(242, 246, 252), anchor="ma")
draw.text(((x0 + x1) // 2, y0 + 166), subtitle, font=font(18), fill=(163, 178, 199), anchor="ma")
def main():
canvas = Image.new("RGB", (1800, 1160), (18, 23, 32))
draw = ImageDraw.Draw(canvas)
white = (242, 246, 252)
muted = (163, 178, 199)
blue = (103, 203, 255)
green = (121, 224, 167)
draw.text((60, 38), "心音|四方向移动映射 v1", font=font(44), fill=white)
draw.text((62, 99), "运行时只使用 up / down / left / right;旧制作目录保留为兼容别名", font=font(22), fill=muted)
placeholder(draw, (660, 150, 1140, 370), "↑", "UP|向上", "待制作:全新背面母版与分解包")
placeholder(draw, (660, 895, 1140, 1115), "↓", "DOWN|向下", "待制作:全新正面母版与分解包")
left_panel = (65, 270, 565, 970)
right_panel = (1235, 270, 1735, 970)
for rect in (left_panel, right_panel):
draw.rounded_rectangle(rect, radius=18, fill=(32, 40, 55), outline=(71, 88, 113), width=2)
draw.text((90, 292), "← LEFT|向左", font=font(29), fill=blue)
draw.text((90, 337), "旧目录:front-right", font=font(18), fill=muted)
draw.text((90, 368), "状态:动作美术已验证", font=font(18), fill=green)
paste_character(canvas, LEFT, (90, 410, 540, 940))
draw.text((1260, 292), "RIGHT|向右 →", font=font(29), fill=blue)
draw.text((1260, 337), "旧目录:front-left", font=font(18), fill=muted)
draw.text((1260, 368), "状态:静态美术已验证", font=font(18), fill=green)
paste_character(canvas, RIGHT, (1260, 410, 1710, 940))
draw.rounded_rectangle((615, 410, 1185, 835), radius=18, fill=(27, 34, 47), outline=(71, 88, 113), width=2)
draw.text((650, 442), "运行时规则", font=font(28), fill=white)
rules = [
"1. 取移动输入的主轴决定身体朝向",
"2. 斜向临界区保持上一朝向,避免闪烁",
"3. 左右独立绘制,禁止水平镜像",
"4. 身体四向;投射物与 VFX 可自由角度瞄准",
"5. 脚底中心是所有方向的统一原点",
]
for index, rule in enumerate(rules):
draw.text((650, 505 + index * 58), rule, font=font(20), fill=muted)
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
canvas.save(OUTPUT, quality=95)
print(OUTPUT)
if __name__ == "__main__":
main()