Enlarge battle UI icons
This commit is contained in:
@@ -9,7 +9,8 @@ from PIL import Image, ImageDraw, ImageFilter
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / "src" / "assets" / "images" / "ui" / "battle-ui-icons.png"
|
||||
FRAME = 48
|
||||
BASE_FRAME = 48
|
||||
FRAME = 64
|
||||
SCALE = 4
|
||||
|
||||
|
||||
@@ -38,6 +39,10 @@ def main() -> None:
|
||||
("counter", draw_counter),
|
||||
("advantage", draw_advantage),
|
||||
("success", draw_success),
|
||||
("heal", draw_heal),
|
||||
("focus", draw_focus),
|
||||
("fire", draw_fire),
|
||||
("shout", draw_shout),
|
||||
]
|
||||
cols = 5
|
||||
rows = math.ceil(len(icons) / cols)
|
||||
@@ -63,24 +68,32 @@ def c(value: tuple[int, int, int, int] | tuple[int, int, int]) -> tuple[int, int
|
||||
return value
|
||||
|
||||
|
||||
def s(value: float) -> int:
|
||||
return round(value * FRAME / BASE_FRAME * SCALE)
|
||||
|
||||
|
||||
def sw(width: float) -> int:
|
||||
return max(1, round(width * FRAME / BASE_FRAME * SCALE))
|
||||
|
||||
|
||||
def line(draw: ImageDraw.ImageDraw, points: list[tuple[int, int]], fill: tuple[int, int, int, int], width: int) -> None:
|
||||
scaled = [(x * SCALE, y * SCALE) for x, y in points]
|
||||
draw.line(scaled, fill=fill, width=width * SCALE, joint="curve")
|
||||
scaled = [(s(x), s(y)) for x, y in points]
|
||||
draw.line(scaled, fill=fill, width=sw(width), joint="curve")
|
||||
|
||||
|
||||
def poly(draw: ImageDraw.ImageDraw, points: list[tuple[int, int]], fill, outline=None) -> None:
|
||||
scaled = [(x * SCALE, y * SCALE) for x, y in points]
|
||||
scaled = [(s(x), s(y)) for x, y in points]
|
||||
draw.polygon(scaled, fill=c(fill), outline=c(outline) if outline else None)
|
||||
|
||||
|
||||
def ellipse(draw: ImageDraw.ImageDraw, box: tuple[int, int, int, int], fill, outline=None, width=1) -> None:
|
||||
scaled = tuple(v * SCALE for v in box)
|
||||
draw.ellipse(scaled, fill=c(fill), outline=c(outline) if outline else None, width=width * SCALE)
|
||||
scaled = tuple(s(v) for v in box)
|
||||
draw.ellipse(scaled, fill=c(fill), outline=c(outline) if outline else None, width=sw(width))
|
||||
|
||||
|
||||
def rect(draw: ImageDraw.ImageDraw, box: tuple[int, int, int, int], fill, outline=None, width=1) -> None:
|
||||
scaled = tuple(v * SCALE for v in box)
|
||||
draw.rounded_rectangle(scaled, radius=4 * SCALE, fill=c(fill), outline=c(outline) if outline else None, width=width * SCALE)
|
||||
scaled = tuple(s(v) for v in box)
|
||||
draw.rounded_rectangle(scaled, radius=sw(4), fill=c(fill), outline=c(outline) if outline else None, width=sw(width))
|
||||
|
||||
|
||||
def icon_shadow(draw: ImageDraw.ImageDraw) -> None:
|
||||
@@ -279,5 +292,48 @@ def draw_success(draw: ImageDraw.ImageDraw) -> None:
|
||||
ellipse(draw, (18, 36, 30, 43), (180, 63, 58), (73, 27, 27))
|
||||
|
||||
|
||||
def draw_heal(draw: ImageDraw.ImageDraw) -> None:
|
||||
icon_shadow(draw)
|
||||
ellipse(draw, (8, 8, 40, 40), (34, 85, 69), (22, 39, 35), 2)
|
||||
poly(draw, [(24, 39), (10, 25), (10, 15), (16, 10), (24, 15), (32, 10), (38, 15), (38, 25)], (211, 68, 70), (65, 18, 24))
|
||||
poly(draw, [(24, 35), (14, 24), (14, 17), (18, 14), (24, 19), (30, 14), (34, 17), (34, 24)], (255, 139, 117))
|
||||
rect(draw, (20, 13, 28, 35), (235, 248, 210), (61, 93, 72), 1)
|
||||
rect(draw, (13, 20, 35, 28), (235, 248, 210), (61, 93, 72), 1)
|
||||
line(draw, [(14, 35), (34, 35)], (133, 222, 150, 210), 2)
|
||||
|
||||
|
||||
def draw_focus(draw: ImageDraw.ImageDraw) -> None:
|
||||
icon_shadow(draw)
|
||||
line(draw, [(14, 40), (14, 8)], (113, 83, 45), 4)
|
||||
poly(draw, [(17, 10), (39, 14), (31, 23), (39, 31), (17, 28)], (50, 111, 178), (23, 44, 76))
|
||||
poly(draw, [(17, 13), (35, 16), (29, 22), (35, 28), (17, 25)], (109, 169, 232))
|
||||
points = []
|
||||
for i in range(10):
|
||||
radius = 9 if i % 2 == 0 else 4
|
||||
angle = -math.pi / 2 + i * math.pi / 5
|
||||
points.append((24 + math.cos(angle) * radius, 23 + math.sin(angle) * radius))
|
||||
poly(draw, [(round(x), round(y)) for x, y in points], (244, 205, 91), (87, 55, 23))
|
||||
ellipse(draw, (9, 36, 19, 44), (216, 179, 88), (74, 55, 31))
|
||||
|
||||
|
||||
def draw_fire(draw: ImageDraw.ImageDraw) -> None:
|
||||
icon_shadow(draw)
|
||||
poly(draw, [(24, 7), (34, 18), (31, 16), (38, 29), (31, 41), (18, 42), (10, 31), (14, 21), (18, 24)], (154, 42, 35), (58, 20, 19))
|
||||
poly(draw, [(25, 11), (32, 22), (29, 21), (34, 31), (29, 38), (20, 39), (14, 31), (18, 24), (20, 28)], (229, 82, 49))
|
||||
poly(draw, [(25, 20), (30, 29), (27, 36), (21, 36), (18, 30), (21, 25)], (255, 190, 78), (116, 51, 26))
|
||||
line(draw, [(13, 39), (37, 39)], (86, 35, 26, 180), 2)
|
||||
|
||||
|
||||
def draw_shout(draw: ImageDraw.ImageDraw) -> None:
|
||||
icon_shadow(draw)
|
||||
ellipse(draw, (10, 15, 31, 36), (125, 72, 46), (49, 28, 24), 2)
|
||||
poly(draw, [(27, 19), (42, 13), (39, 35), (27, 30)], (218, 176, 96), (72, 50, 27))
|
||||
poly(draw, [(31, 20), (38, 18), (36, 30), (31, 28)], (255, 223, 134))
|
||||
line(draw, [(35, 10), (43, 6)], (232, 84, 61), 3)
|
||||
line(draw, [(38, 24), (46, 24)], (232, 84, 61), 3)
|
||||
line(draw, [(35, 38), (43, 43)], (232, 84, 61), 3)
|
||||
ellipse(draw, (16, 22, 23, 29), (35, 20, 18), None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user