From 8a024929bcafb736754a2c91b6c4500ca0fa6a3a Mon Sep 17 00:00:00 2001 From: Erzangel Date: Sun, 15 Mar 2026 16:23:18 +0100 Subject: [PATCH] feat: 1st version of icons: champion, trash, yellow faction (so far) --- src/draw_functions.py | 76 ++++++++++++++++++++++++++++++++++++++- src/generate_cards_mvp.py | 4 +++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/draw_functions.py b/src/draw_functions.py index 61c1309..596a8c3 100644 --- a/src/draw_functions.py +++ b/src/draw_functions.py @@ -1,4 +1,6 @@ from math import sin, cos, pi +from typing import Optional + import drawsvg as dw import json @@ -26,6 +28,7 @@ def is_base_effect(effect: Effect): def create_icon( amount: int, fill_circle: str, + outline_circle: Optional[str] = None, effect_id: str | None = None, fill_text: str = "black", radius: float = stats_radius, @@ -35,7 +38,9 @@ def create_icon( else: click_function = js_event_function(effect_id) group = dw.Group(**{"class": "svg_resource_icon", "v-on:click": click_function}) - group.append(dw.Circle(cx=0, cy=0, r=radius, fill=fill_circle, x=0, y=0)) + if outline_circle: + group.append(dw.Circle(cx=0, cy=0, r=radius, fill=outline_circle, x=0, y=0)) + group.append(dw.Circle(cx=0, cy=0, r=radius-2, fill=fill_circle, x=0, y=0)) group.append( dw.Text( str(amount), @@ -58,6 +63,7 @@ def create_damage_icon( amount, radius=radius, fill_circle="red", + outline_circle="black", fill_text="white", effect_id=effect_id, ) @@ -70,6 +76,7 @@ def create_heal_icon( amount, radius=radius, fill_circle="green", + outline_circle="black", fill_text="white", effect_id=effect_id, ) @@ -82,6 +89,7 @@ def create_gold_icon( amount, radius=radius, fill_circle="yellow", + outline_circle="goldenrod", effect_id=effect_id, ) @@ -313,6 +321,31 @@ def create_effect_text( return group +def create_arrow(): + return dw.Lines(7, 10, + 7, -5, + -5, -5, + -5, -9, + -10, -2, + -5, 4, + -5, 0, + 2, 0, + 2, 10, + stroke='black', fill='white', close='true') + + +def create_faction_icon(faction: str, transform: str = None): + if faction == "yellow": + return dw.Lines(9, 0, + 2, -2, + 0, -5, + -2, -2, + -9, 0, + -2, 2, + 0, 5, + 2, 2, + stroke='grey', fill='white', close='true', transform=transform) + def create_effect_row( card: Card, effects: list[Effect], type: str, height: int, width: int @@ -330,6 +363,9 @@ def create_effect_row( filter="url(#drop-shadow)", ) ) + subg = dw.Group(transform=f"translate({30},{height / 2})") + subg.append(create_faction_icon(faction="yellow")) + group.append(subg) elif type == "suicide": has_icon = True group.append( @@ -341,6 +377,30 @@ def create_effect_row( filter="url(#drop-shadow)", ) ) + group.append( + dw.Line( + sx=19, + sy=(height / 2) - 11, + ex=41, + ey=(height / 2) + 11, + stroke="black", + stroke_width=2, + stroke_dasharray='3,1', + stroke_opacity=0.3, + ) + ) + group.append( + dw.Line( + sx=41, + sy=(height / 2) - 11, + ex=19, + ey=(height / 2) + 11, + stroke="black", + stroke_width=2, + stroke_dasharray='3,1', + stroke_opacity=0.3, + ) + ) elif type == "champion_action": has_icon = True @@ -349,10 +409,24 @@ def create_effect_row( cx=30, cy=height / 2, r=15, + fill="#444444", + filter="url(#drop-shadow)", + ) + + ) + group.append( + dw.Circle( + cx=30, + cy=height / 2, + r=13, fill="gray", filter="url(#drop-shadow)", ) + ) + subg = dw.Group(transform=f"translate({30},{height / 2})") + subg.append(create_arrow()) + group.append(subg) effect_with_icons = list( filter(lambda x: x.get("effect") in resourceIcons and not x.get("per"), effects) ) diff --git a/src/generate_cards_mvp.py b/src/generate_cards_mvp.py index 5c22019..9d36655 100644 --- a/src/generate_cards_mvp.py +++ b/src/generate_cards_mvp.py @@ -10,6 +10,7 @@ from card_types import Card, SkinData, SkinFile, Translation from drawsvg.drawing import Drawing from edit_card import finish_card +from src.draw_functions import create_faction_icon with open("src/data/translation_fr.json", encoding="utf-8") as f: translation_fr: Translation = json.load(f) @@ -113,6 +114,9 @@ for card_data in cards: fill=f'url(#grad2-{card_data["id"]})', ) ) + faction_icon.append( + create_faction_icon("yellow", transform="scale(1.5)"), + ) # Define linear colored gradient gradient = dw.LinearGradient(