#!/usr/bin/env python3 """요리 화면의 큰 그림(조리 도구, 마스코트 떡이)을 256px 칸 4x4 한 장(art/kitchen.png)으로 직접 그립니다. 칸 이름과 위치는 src/shared/Icons.luau 의 KITCHEN 표와 같아야 합니다(--luau 로 확인). python3 tools/kitchen_art.py # art/kitchen.png python3 tools/kitchen_art.py --sheet x.png """ import math import os import sys import cairo sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from icons import INK, ellipse, fill_stroke, lin, rad, rgb, rrect, shine # noqa: E402 OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "art", "kitchen.png") CELL = 256 GRID = 4 LW = 9 def fs(c, paint, lw=LW): fill_stroke(c, paint, lw) def flame_row(c, y=236, n=4): # 그릇 바닥을 핥는 작은 불꽃(그릇을 그린 다음에 그림) for i in range(n): x = 128 + (i - (n - 1) / 2) * 40 c.move_to(x, y) c.curve_to(x - 16, y - 4, x - 12, y - 22, x - 3, y - 32) c.curve_to(x, y - 22, x + 8, y - 24, x + 6, y - 36) c.curve_to(x + 18, y - 20, x + 16, y - 4, x, y) c.close_path() fs(c, lin(0, y - 36, 0, y, "#fff36b", "#ffa51f", "#ff5a1f"), 5) def burner(c): # 가스 화구 받침(불꽃 아래) rrect(c, 44, 228, 168, 22, 10) fs(c, lin(0, 228, 0, 250, "#94a3b8", "#475569"), 7) def pan(c): pan_body(c) flame_row(c) burner(c) def pan_body(c): # 손잡이 rrect(c, 196, 132, 58, 22, 10) fs(c, lin(0, 132, 0, 154, "#7c4a24", "#4a2a12")) # 팬(위에서 비스듬히) ellipse(c, 118, 150, 108, 52) fs(c, lin(0, 98, 0, 202, "#4b5563", "#1f2937")) ellipse(c, 118, 144, 92, 40) c.set_source(lin(0, 104, 0, 184, "#6b7280", "#374151")) c.fill() shine(c, 70, 124, 22, 7, 0.35) def board(c): # 나무 도마 + 김 + 밥 rrect(c, 8, 70, 240, 150, 26) fs(c, lin(0, 70, 0, 220, "#f5c98a", "#d99a52")) for y in (100, 140, 180): c.move_to(24, y) c.curve_to(90, y - 8, 160, y + 8, 232, y) c.set_source_rgba(*INK, 0.12) c.set_line_width(3) c.stroke() rrect(c, 36, 84, 184, 122, 10) fs(c, lin(0, 84, 0, 206, "#2e3b2e", "#141c14"), 6) rrect(c, 46, 94, 164, 86, 18) c.set_source(lin(0, 94, 0, 180, "#ffffff", "#f1ede4")) c.fill() for x, y in ((70, 110), (100, 130), (140, 112), (170, 140), (120, 160), (80, 158), (190, 108)): ellipse(c, x, y, 6, 3.5) c.set_source_rgba(*INK, 0.08) c.fill() def steamer(c): steamer_body(c) flame_row(c) burner(c) def steamer_body(c): # 냄비 몸통 + 대나무 찜기 테두리 + 뚜껑 없음(속이 보임) rrect(c, 34, 112, 188, 92, 22) fs(c, lin(0, 112, 0, 204, "#e2e8f0", "#94a3b8")) rrect(c, 22, 96, 212, 40, 18) fs(c, lin(0, 96, 0, 136, "#f6d58e", "#d9a24a")) for x in range(40, 230, 24): c.move_to(x, 100) c.line_to(x, 132) c.set_source_rgba(*INK, 0.25) c.set_line_width(3) c.stroke() ellipse(c, 128, 100, 96, 22) fs(c, lin(0, 78, 0, 122, "#fff3d0", "#e9c983"), 6) for x in range(48, 212, 18): c.move_to(x, 88) c.line_to(x, 112) c.set_source_rgba(*INK, 0.15) c.set_line_width(2) c.stroke() def pot(c): pot_body(c) flame_row(c) burner(c) def pot_body(c): rrect(c, 12, 118, 24, 22, 8) fs(c, rgb("#7c4a24"), 6) rrect(c, 220, 118, 24, 22, 8) fs(c, rgb("#7c4a24"), 6) rrect(c, 30, 100, 196, 106, 30) fs(c, lin(0, 100, 0, 206, "#ff8a6a", "#d92f1c")) ellipse(c, 128, 102, 98, 26) fs(c, lin(0, 76, 0, 128, "#ffe08a", "#f2b046"), 7) for x, y in ((90, 98), (150, 108), (176, 94)): c.arc(x, y, 5, 0, 2 * math.pi) c.set_source_rgba(1, 1, 1, 0.7) c.fill() # 파 송송 for x, y in ((70, 104), (120, 92), (196, 104), (140, 114)): c.arc(x, y, 6, 0, 2 * math.pi) fs(c, rgb("#5cc95c"), 3) shine(c, 60, 150, 10, 22, 0.35) def fryer(c): fryer_body(c) flame_row(c) burner(c) def fryer_body(c): rrect(c, 26, 96, 204, 112, 26) fs(c, lin(0, 96, 0, 208, "#cbd5e1", "#64748b")) ellipse(c, 128, 100, 100, 26) fs(c, lin(0, 74, 0, 126, "#ffe58a", "#f5b52a"), 7) for x, y, r in ((80, 100, 6), (120, 92, 4), (164, 104, 5), (190, 96, 4), (100, 110, 3)): c.arc(x, y, r, 0, 2 * math.pi) c.set_source_rgba(1, 1, 1, 0.75) c.fill() shine(c, 56, 150, 10, 24, 0.4) def mascot_body(c, cheer): # 떡이: 하얀 가래떡 몸 + 요리사 모자 + 빨간 앞치마 arm_y = 70 if cheer else 150 c.set_line_cap(cairo.LINE_CAP_ROUND) for x0, x1 in ((62, 22), (194, 234)): for w, col in ((26 + LW, INK), (26, rgb("#fff7ef"))): c.move_to(x0, 150) c.line_to(x1, arm_y) c.set_line_width(w) c.set_source_rgb(*col) c.stroke() rrect(c, 52, 70, 152, 176, 64) fs(c, lin(0, 70, 0, 246, "#ffffff", "#ffe6da")) # 앞치마 c.move_to(76, 176) c.line_to(180, 176) c.line_to(176, 234) c.curve_to(150, 248, 106, 248, 80, 234) c.close_path() fs(c, lin(0, 176, 0, 244, "#ff7a8a", "#ff4d6a"), 6) c.arc(128, 206, 10, 0, 2 * math.pi) fs(c, rgb("#ffd23a"), 4) # 모자 for x, y, r in ((88, 54, 34), (128, 38, 40), (168, 54, 34)): c.arc(x, y, r, 0, 2 * math.pi) fs(c, rgb("#ffffff"), 7) rrect(c, 70, 58, 116, 32, 10) fs(c, rgb("#ffffff"), 7) rrect(c, 76, 52, 104, 30, 8) c.set_source_rgb(1, 1, 1) c.fill() # 얼굴 for x in (102, 154): if cheer: c.arc(x, 130, 11, math.pi, 2 * math.pi) c.set_source_rgb(*INK) c.set_line_width(7) c.stroke() else: ellipse(c, x, 128, 10, 13) c.set_source_rgb(*INK) c.fill() c.arc(x + 3, 122, 4, 0, 2 * math.pi) c.set_source_rgb(1, 1, 1) c.fill() c.move_to(112, 146) c.curve_to(116, 166 if cheer else 160, 140, 166 if cheer else 160, 144, 146) c.close_path() fs(c, rgb("#ff6b6b"), 5) for x in (82, 174): ellipse(c, x, 150, 14, 9) c.set_source_rgba(1, 0.45, 0.5, 0.55) c.fill() if cheer: for x, y in ((24, 40), (232, 36), (14, 120), (242, 118)): c.move_to(x, y - 16) c.line_to(x + 5, y - 5) c.line_to(x + 16, y) c.line_to(x + 5, y + 5) c.line_to(x, y + 16) c.line_to(x - 5, y + 5) c.line_to(x - 16, y) c.line_to(x - 5, y - 5) c.close_path() fs(c, rgb("#ffd23a"), 4) def mascot(c): mascot_body(c, False) def mascot_cheer(c): mascot_body(c, True) def gimbap_roll(c): # 돌돌 만 김밥 한 줄(옆), 오른쪽 끝 단면 rrect(c, 10, 92, 220, 72, 36) fs(c, lin(0, 92, 0, 164, "#3a4a3a", "#141c14")) shine(c, 90, 106, 60, 6, 0.25) c.arc(212, 128, 38, 0, 2 * math.pi) fs(c, rgb("#1f2a1f"), 7) c.arc(212, 128, 29, 0, 2 * math.pi) c.set_source_rgb(1, 1, 1) c.fill() for dx, dy, col in ((-9, -8, "#ff8c1a"), (9, -7, "#ffd23a"), (0, 9, "#3fae49"), (-11, 9, "#ff8fa3"), (11, 9, "#fff3a0")): c.arc(212 + dx, 128 + dy, 7, 0, 2 * math.pi) c.set_source_rgb(*rgb(col)) c.fill() def plate_big(c): # 완성 접시 받침(위에서 비스듬히) ellipse(c, 128, 150, 116, 58) fs(c, lin(0, 92, 0, 208, "#ffffff", "#d7dde6")) ellipse(c, 128, 146, 82, 38) c.set_source_rgba(*INK, 0.15) c.set_line_width(4) c.stroke() def burst(c): # 완성 축하 빛(테두리 없음) for i in range(12): a0 = i * math.pi / 6 a1 = a0 + math.pi / 12 c.move_to(128, 128) c.line_to(128 + 130 * math.cos(a0), 128 + 130 * math.sin(a0)) c.line_to(128 + 130 * math.cos(a1), 128 + 130 * math.sin(a1)) c.close_path() g = cairo.RadialGradient(128, 128, 10, 128, 128, 128) g.add_color_stop_rgba(0, 1, 0.95, 0.6, 1) g.add_color_stop_rgba(1, 1, 0.85, 0.3, 0) c.set_source(g) c.fill() BIG = [ ("pan", pan), ("board", board), ("steamer", steamer), ("pot", pot), ("fryer", fryer), ("mascot", mascot), ("mascotCheer", mascot_cheer), ("gimbapRoll", gimbap_roll), ("plateBig", plate_big), ("burst", burst), ] def draw(): surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID) for i, (name, fn) in enumerate(BIG): c = cairo.Context(surf) c.translate((i % GRID) * CELL, (i // GRID) * CELL) c.rectangle(0, 0, CELL, CELL) c.clip() c.translate(128, 128) c.scale(0.94, 0.94) c.translate(-128, -128) fn(c) return surf def main(argv): surf = draw() if "--luau" in argv: for i, (name, _) in enumerate(BIG): print(f"\t{name} = Vector2.new({(i % GRID) * CELL}, {(i // GRID) * CELL}),") return if "--sheet" in argv: out = argv[argv.index("--sheet") + 1] sheet = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID) c = cairo.Context(sheet) c.set_source_rgb(0.55, 0.75, 0.6) c.paint() c.set_source_surface(surf, 0, 0) c.paint() for i, (name, _) in enumerate(BIG): c.set_source_rgb(0, 0, 0) c.move_to((i % GRID) * CELL + 6, (i // GRID) * CELL + 18) c.set_font_size(16) c.show_text(name) sheet.write_to_png(out) print(out) return surf.write_to_png(OUT) print(os.path.normpath(OUT)) if __name__ == "__main__": main(sys.argv[1:])