#!/usr/bin/env python3 """게임패스·개발자 상품 아이콘(512x512), 게임 아이콘(512x512), 썸네일(1920x1080)을 그립니다. 외부 그림을 쓰지 않아 저작권 걱정이 없습니다. python3 tools/art.py # art/*.png 생성 """ import math import os import numpy as np from PIL import Image, ImageDraw, ImageFilter, ImageFont OUT = os.path.join(os.path.dirname(__file__), "..", "art") BOLD = "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc" S = 512 def font(size): return ImageFont.truetype(BOLD, size, index=1) # KR def background(c1, c2): img = Image.new("RGBA", (S, S)) d = ImageDraw.Draw(img) for y in range(S): t = y / S col = tuple(int(c1[i] * (1 - t) + c2[i] * t) for i in range(3)) + (255,) d.line([(0, y), (S, y)], fill=col) # 햇살 무늬 rays = Image.new("RGBA", (S, S), (0, 0, 0, 0)) rd = ImageDraw.Draw(rays) for i in range(16): a0 = i * math.pi / 8 a1 = a0 + math.pi / 16 rd.polygon([(S / 2, S / 2), (S / 2 + 800 * math.cos(a0), S / 2 + 800 * math.sin(a0)), (S / 2 + 800 * math.cos(a1), S / 2 + 800 * math.sin(a1))], fill=(255, 255, 255, 40)) img.alpha_composite(rays) mask = Image.new("L", (S, S), 0) ImageDraw.Draw(mask).rounded_rectangle([0, 0, S - 1, S - 1], radius=90, fill=255) out = Image.new("RGBA", (S, S), (0, 0, 0, 0)) out.paste(img, (0, 0), mask) return out def coin(d, cx, cy, r): d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=(255, 200, 40), outline=(190, 120, 10), width=max(4, r // 8)) d.ellipse([cx - r * 0.65, cy - r * 0.65, cx + r * 0.65, cy + r * 0.65], outline=(230, 160, 20), width=max(3, r // 12)) f = font(int(r * 1.0)) d.text((cx, cy - r * 0.05), "₩", font=f, fill=(190, 120, 10), anchor="mm") def outlined(d, xy, text, f, fill, stroke, width): d.text(xy, text, font=f, fill=fill, anchor="mm", stroke_width=width, stroke_fill=stroke) def shadow(img): sh = img.copy().filter(ImageFilter.GaussianBlur(6)) return sh def double_money(): img = background((170, 90, 230), (90, 40, 170)) d = ImageDraw.Draw(img) for (x, y, r) in [(140, 330, 80), (370, 350, 70), (255, 395, 90)]: coin(d, x, y, r) outlined(d, (256, 190), "x2", font(250), (255, 230, 60), (90, 30, 120), 14) return img def money_boost(): img = background((255, 190, 60), (240, 110, 30)) d = ImageDraw.Draw(img) for (x, y, r) in [(130, 380, 70), (385, 380, 70), (256, 410, 80)]: coin(d, x, y, r) bolt = [(290, 40), (150, 270), (245, 270), (205, 430), (360, 200), (265, 200), (320, 40)] d.polygon(bolt, fill=(255, 250, 120), outline=(160, 70, 0)) d.line(bolt + [bolt[0]], fill=(160, 70, 0), width=12, joint="curve") return img def stall_scene(W, H, scale): """포장마차와 떡볶이 판 그림(W x H, 크게 그린 뒤 줄여서 부드럽게).""" k = scale img = Image.new("RGBA", (W, H)) d = ImageDraw.Draw(img) # 저녁 하늘 for y in range(H): tt = y / H c = (int(255 * (1 - tt) + 255 * tt), int(170 * (1 - tt) + 120 * tt), int(90 * (1 - tt) + 140 * tt), 255) d.line([(0, y), (W, y)], fill=c) rays = Image.new("RGBA", (W, H), (0, 0, 0, 0)) rd = ImageDraw.Draw(rays) cx, cy = W / 2, H * 0.55 for i in range(24): a0 = i * math.pi / 12 a1 = a0 + math.pi / 24 rd.polygon([(cx, cy), (cx + 4000 * math.cos(a0), cy + 4000 * math.sin(a0)), (cx + 4000 * math.cos(a1), cy + 4000 * math.sin(a1))], fill=(255, 255, 255, 28)) img.alpha_composite(rays) d = ImageDraw.Draw(img) # 바닥 d.rectangle([0, H * 0.82, W, H], fill=(120, 95, 80)) # 천막 기둥 left, right = W / 2 - 330 * k, W / 2 + 330 * k top = H * 0.30 for x in (left + 30 * k, right - 30 * k): d.rectangle([x - 9 * k, top, x + 9 * k, H * 0.84], fill=(180, 180, 190)) # 수레(나무) d.rounded_rectangle([left + 10 * k, H * 0.58, right - 10 * k, H * 0.84], radius=18 * k, fill=(165, 105, 60), outline=(110, 65, 35), width=int(8 * k)) for i in range(1, 6): x = left + 10 * k + i * (right - left - 20 * k) / 6 d.line([(x, H * 0.60), (x, H * 0.82)], fill=(140, 85, 45), width=int(5 * k)) d.rounded_rectangle([left - 10 * k, H * 0.55, right + 10 * k, H * 0.60], radius=10 * k, fill=(215, 220, 225), outline=(150, 150, 160), width=int(5 * k)) # 줄무늬 천막과 물결 테두리 roof = [(left - 60 * k, top + 110 * k), (W / 2, top - 40 * k), (right + 60 * k, top + 110 * k)] d.polygon(roof, fill=(245, 110, 40), outline=(170, 60, 20)) n = 8 for i in range(n): if i % 2 == 0: x0 = left - 60 * k + i * (right - left + 120 * k) / n x1 = x0 + (right - left + 120 * k) / n d.polygon([(W / 2, top - 40 * k), (x0, top + 110 * k), (x1, top + 110 * k)], fill=(255, 235, 205)) d.line(roof + [roof[0]], fill=(170, 60, 20), width=int(8 * k), joint="curve") sw = (right - left + 120 * k) / n for i in range(n): x0 = left - 60 * k + i * sw col = (245, 110, 40) if i % 2 == 0 else (255, 235, 205) d.pieslice([x0, top + 70 * k, x0 + sw, top + 150 * k], 0, 180, fill=col, outline=(170, 60, 20), width=int(5 * k)) # 전구 for i in range(9): x = left - 20 * k + i * (right - left + 40 * k) / 8 d.ellipse([x - 14 * k, top + 150 * k, x + 14 * k, top + 178 * k], fill=(255, 230, 140), outline=(230, 170, 60), width=int(3 * k)) # 큰 떡볶이 판 px, py, pr = W / 2, H * 0.60, 250 * k d.ellipse([px - pr, py - pr * 0.42, px + pr, py + pr * 0.42], fill=(45, 45, 50)) d.ellipse([px - pr * 0.9, py - pr * 0.36, px + pr * 0.9, py + pr * 0.36], fill=(215, 45, 25)) r2 = random_state = np.random.default_rng(3) # noqa: F841 for _ in range(26): a = r2.uniform(0, 2 * math.pi) rr = r2.uniform(0, 0.78) x = px + math.cos(a) * pr * 0.85 * rr y = py + math.sin(a) * pr * 0.32 * rr ang = r2.uniform(-0.6, 0.6) tl, tw = 70 * k, 22 * k pts = [(-tl / 2, -tw / 2), (tl / 2, -tw / 2), (tl / 2, tw / 2), (-tl / 2, tw / 2)] pts = [(x + px_ * math.cos(ang) - py_ * math.sin(ang), y + px_ * math.sin(ang) + py_ * math.cos(ang)) for px_, py_ in pts] d.polygon(pts, fill=(250, 120, 80), outline=(170, 40, 20)) d.line([pts[0], pts[1]], fill=(255, 190, 160), width=int(4 * k)) for _ in range(4): x = px + r2.uniform(-0.6, 0.6) * pr y = py + r2.uniform(-0.2, 0.15) * pr d.polygon([(x - 40 * k, y + 15 * k), (x + 40 * k, y + 15 * k), (x, y - 40 * k)], fill=(240, 200, 130), outline=(170, 120, 60)) # 김 steam = Image.new("RGBA", (W, H), (0, 0, 0, 0)) sd = ImageDraw.Draw(steam) for j, off in enumerate((-110, 0, 110)): pts = [] for i in range(30): yy = py - pr * 0.4 - i * 9 * k xx = px + off * k + math.sin(i / 4 + j) * 26 * k pts.append((xx, yy)) sd.line(pts, fill=(255, 255, 255, 170), width=int(22 * k), joint="curve") steam = steam.filter(ImageFilter.GaussianBlur(8 * k)) img.alpha_composite(steam) return img def title(img, cx, cy, size, sub=True): d = ImageDraw.Draw(img) outlined(d, (cx, cy), "분식 타이쿤", font(size), (255, 245, 120), (150, 40, 20), max(6, size // 10)) if sub: outlined(d, (cx, cy + size * 0.95), "BUNSIK TYCOON", font(int(size * 0.45)), (255, 255, 255), (150, 40, 20), max(4, size // 18)) def game_icon(): big = stall_scene(1024, 1024, 1.25) title(big, 512, 150, 150) img = big.resize((S, S), Image.LANCZOS) mask = Image.new("L", (S, S), 0) ImageDraw.Draw(mask).rounded_rectangle([0, 0, S - 1, S - 1], radius=90, fill=255) out = Image.new("RGBA", (S, S), (0, 0, 0, 0)) out.paste(img, (0, 0), mask) return out def thumbnail(): big = stall_scene(1920, 1080, 1.35) d = ImageDraw.Draw(big) title(big, 960, 120, 130) # 메뉴 말풍선 for (x, y, label) in [(250, 560, "떡볶이"), (1670, 560, "김밥"), (300, 860, "순대"), (1620, 860, "어묵")]: d.rounded_rectangle([x - 150, y - 60, x + 150, y + 60], radius=40, fill=(255, 255, 255), outline=(255, 140, 60), width=8) d.text((x, y), label, font=font(64), fill=(200, 60, 30), anchor="mm") outlined(d, (960, 1010), "손님을 받고 가게를 키우세요! Serve customers & grow your shop!", font(48), (255, 255, 255), (90, 40, 20), 6) return big.convert("RGB") def main(): os.makedirs(OUT, exist_ok=True) game_icon().save(os.path.join(OUT, "game_icon.png")) thumbnail().save(os.path.join(OUT, "thumbnail_1.png")) print(os.path.join(OUT, "game_icon.png"), os.path.join(OUT, "thumbnail_1.png")) for name, fn in [("double_money", double_money), ("money_boost", money_boost)]: path = os.path.join(OUT, name + ".png") fn().save(path) print(path) if __name__ == "__main__": main()