#!/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") RAINBOW = [(255, 80, 80), (255, 160, 40), (255, 220, 50), (80, 200, 100), (60, 160, 255), (150, 90, 230)] def rainbow_fill(size): w, h = size arr = np.zeros((h, w, 4), dtype=np.uint8) n = len(RAINBOW) - 1 for x in range(w): t = x / max(1, w - 1) * n i = min(int(t), n - 1) f = t - i c = [int(RAINBOW[i][k] * (1 - f) + RAINBOW[i + 1][k] * f) for k in range(3)] arr[:, x, :3] = c arr[:, x, 3] = 255 return Image.fromarray(arr, "RGBA") def rainbow_name(): img = background((120, 200, 255), (60, 120, 230)) d = ImageDraw.Draw(img) # 이름판 d.rounded_rectangle([40, 150, 472, 360], radius=50, fill=(255, 250, 240), outline=(120, 70, 40), width=14) f = font(150) mask = Image.new("L", (S, S), 0) ImageDraw.Draw(mask).text((256, 250), "가게", font=f, fill=255, anchor="mm") outline = Image.new("L", (S, S), 0) ImageDraw.Draw(outline).text((256, 250), "가게", font=f, fill=255, anchor="mm", stroke_width=10, stroke_fill=255) img.paste((90, 40, 120, 255), (0, 0), outline) img.paste(rainbow_fill((S, S)), (0, 0), mask) for (x, y, r) in [(80, 110, 22), (430, 100, 28), (450, 400, 20), (70, 410, 26)]: star(d, x, y, r, (255, 255, 200)) return img def star(d, cx, cy, r, color): pts = [] for i in range(8): a = i * math.pi / 4 - math.pi / 2 rr = r if i % 2 == 0 else r * 0.35 pts.append((cx + rr * math.cos(a), cy + rr * math.sin(a))) d.polygon(pts, fill=color) def house(d, x0, y0, x1, y1, wall, trim, door): d.rectangle([x0, y0, x1, y1], fill=wall, outline=trim, width=10) cx = (x0 + x1) / 2 d.rounded_rectangle([cx - 40, y1 - 110, cx + 40, y1], radius=18, fill=door, outline=trim, width=8) for wx in (x0 + 30, x1 - 110): d.rounded_rectangle([wx, y0 + 40, wx + 80, y0 + 110], radius=12, fill=(200, 235, 255), outline=trim, width=8) def candy_design(): img = background((255, 200, 230), (255, 130, 180)) d = ImageDraw.Draw(img) house(d, 96, 230, 416, 450, (255, 210, 232), (255, 100, 160), (255, 140, 190)) # 줄무늬 차양 for i in range(8): col = (255, 110, 165) if i % 2 == 0 else (255, 255, 255) d.polygon([(80 + i * 44, 180), (124 + i * 44, 180), (124 + i * 44, 240), (80 + i * 44, 240)], fill=col) d.rounded_rectangle([80, 170, 432, 250], radius=20, outline=(220, 70, 130), width=10) # 하트 간판 d.ellipse([200, 70, 262, 132], fill=(255, 70, 130)) d.ellipse([250, 70, 312, 132], fill=(255, 70, 130)) d.polygon([(204, 112), (308, 112), (256, 170)], fill=(255, 70, 130)) # 막대사탕 for x in (50, 462): d.line([(x, 470), (x, 330)], fill=(255, 255, 255), width=12) d.ellipse([x - 40, 270, x + 40, 350], fill=(150, 110, 255), outline=(255, 255, 255), width=8) for (x, y, r) in [(120, 90, 18), (400, 80, 24), (440, 200, 14)]: star(d, x, y, r, (255, 255, 255)) return img def hanok_design(): img = background((255, 225, 170), (230, 150, 90)) d = ImageDraw.Draw(img) house(d, 110, 250, 402, 450, (248, 238, 216), (95, 60, 40), (150, 100, 60)) # 나무 기둥 for x in (110, 256, 402): d.rectangle([x - 10, 250, x + 10, 450], fill=(95, 60, 40)) # 기와지붕(처마가 위로 휜 모양) roof = [(40, 250), (70, 215), (140, 150), (372, 150), (442, 215), (472, 250), (420, 235), (256, 230), (92, 235)] d.polygon(roof, fill=(60, 66, 80), outline=(30, 34, 42)) d.line([(140, 150), (372, 150)], fill=(30, 34, 42), width=14) for i in range(9): x = 110 + i * 37 d.line([(x, 160), (x - 8, 225)], fill=(85, 92, 108), width=6) # 등롱 for x in (60, 452): d.line([(x, 250), (x, 290)], fill=(40, 30, 20), width=5) d.ellipse([x - 32, 285, x + 32, 365], fill=(225, 50, 40), outline=(120, 20, 20), width=6) d.line([(x - 30, 325), (x + 30, 325)], fill=(255, 200, 80), width=4) return img def face(d, cx, cy, r, skin=(255, 220, 190)): d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=skin, outline=(90, 50, 30), width=max(4, r // 8)) d.ellipse([cx - r * 0.4 - 6, cy - r * 0.15 - 6, cx - r * 0.4 + 6, cy - r * 0.15 + 6], fill=(40, 25, 20)) d.ellipse([cx + r * 0.4 - 6, cy - r * 0.15 - 6, cx + r * 0.4 + 6, cy - r * 0.15 + 6], fill=(40, 25, 20)) d.arc([cx - r * 0.45, cy - r * 0.2, cx + r * 0.45, cy + r * 0.5], 20, 160, fill=(150, 50, 40), width=6) def rush(): img = background((120, 230, 180), (40, 170, 130)) d = ImageDraw.Draw(img) for i, (x, y, r, skin) in enumerate([(330, 200, 70, (255, 220, 190)), (210, 290, 64, (230, 180, 140)), (350, 380, 58, (200, 150, 110))]): for k in range(3): d.line([(x - r - 30 - k * 10, y - 25 + k * 25), (x - r - 110 - k * 10, y - 25 + k * 25)], fill=(255, 255, 255), width=12) face(d, x, y, r, skin) outlined(d, (120, 120), "x2", font(140), (255, 240, 80), (20, 100, 70), 12) return img def kick(): img = background((255, 170, 120), (235, 90, 70)) d = ImageDraw.Draw(img) # 오른쪽 우리 가게, 왼쪽에서 손님이 화살표를 따라 옴 d.rectangle([300, 230, 470, 430], fill=(255, 245, 225), outline=(120, 60, 40), width=10) d.polygon([(280, 240), (385, 150), (490, 240)], fill=(255, 90, 120), outline=(120, 60, 40)) d.rounded_rectangle([355, 330, 415, 430], radius=12, fill=(255, 190, 90), outline=(120, 60, 40), width=8) arrow = [(70, 320), (210, 320), (210, 280), (280, 345), (210, 410), (210, 370), (70, 370)] d.polygon(arrow, fill=(255, 255, 255), outline=(150, 50, 30)) face(d, 110, 200, 62) face(d, 215, 160, 50, (230, 180, 140)) return img def promote_ad(): img = background((255, 230, 110), (255, 160, 60)) d = ImageDraw.Draw(img) horn = [(120, 220), (330, 110), (330, 400), (120, 290)] d.polygon(horn, fill=(255, 90, 120), outline=(120, 30, 50)) d.rounded_rectangle([70, 205, 140, 305], radius=16, fill=(255, 255, 255), outline=(120, 30, 50), width=8) d.line([(150, 300), (190, 400)], fill=(120, 30, 50), width=22) for k, r in enumerate((60, 110, 160)): d.arc([330 - r, 255 - r, 330 + r, 255 + r], -40, 40, fill=(255, 255, 255), width=14) for (x, y, r) in [(420, 90, 22), (450, 420, 18), (80, 100, 16)]: star(d, x, y, r, (255, 255, 255)) return img 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), ("rainbow_name", rainbow_name), ("candy_design", candy_design), ("hanok_design", hanok_design), ("rush", rush), ("kick", kick), ("promote_ad", promote_ad)]: path = os.path.join(OUT, name + ".png") fn().save(path) print(path) if __name__ == "__main__": main()