feat: 1st version of icons: champion, trash, yellow faction (so far)
release-tag / release-image (push) Has been cancelled
release-tag / release-image (push) Has been cancelled
This commit is contained in:
+75
-1
@@ -1,4 +1,6 @@
|
|||||||
from math import sin, cos, pi
|
from math import sin, cos, pi
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import drawsvg as dw
|
import drawsvg as dw
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -26,6 +28,7 @@ def is_base_effect(effect: Effect):
|
|||||||
def create_icon(
|
def create_icon(
|
||||||
amount: int,
|
amount: int,
|
||||||
fill_circle: str,
|
fill_circle: str,
|
||||||
|
outline_circle: Optional[str] = None,
|
||||||
effect_id: str | None = None,
|
effect_id: str | None = None,
|
||||||
fill_text: str = "black",
|
fill_text: str = "black",
|
||||||
radius: float = stats_radius,
|
radius: float = stats_radius,
|
||||||
@@ -35,7 +38,9 @@ def create_icon(
|
|||||||
else:
|
else:
|
||||||
click_function = js_event_function(effect_id)
|
click_function = js_event_function(effect_id)
|
||||||
group = dw.Group(**{"class": "svg_resource_icon", "v-on:click": click_function})
|
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(
|
group.append(
|
||||||
dw.Text(
|
dw.Text(
|
||||||
str(amount),
|
str(amount),
|
||||||
@@ -58,6 +63,7 @@ def create_damage_icon(
|
|||||||
amount,
|
amount,
|
||||||
radius=radius,
|
radius=radius,
|
||||||
fill_circle="red",
|
fill_circle="red",
|
||||||
|
outline_circle="black",
|
||||||
fill_text="white",
|
fill_text="white",
|
||||||
effect_id=effect_id,
|
effect_id=effect_id,
|
||||||
)
|
)
|
||||||
@@ -70,6 +76,7 @@ def create_heal_icon(
|
|||||||
amount,
|
amount,
|
||||||
radius=radius,
|
radius=radius,
|
||||||
fill_circle="green",
|
fill_circle="green",
|
||||||
|
outline_circle="black",
|
||||||
fill_text="white",
|
fill_text="white",
|
||||||
effect_id=effect_id,
|
effect_id=effect_id,
|
||||||
)
|
)
|
||||||
@@ -82,6 +89,7 @@ def create_gold_icon(
|
|||||||
amount,
|
amount,
|
||||||
radius=radius,
|
radius=radius,
|
||||||
fill_circle="yellow",
|
fill_circle="yellow",
|
||||||
|
outline_circle="goldenrod",
|
||||||
effect_id=effect_id,
|
effect_id=effect_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -313,6 +321,31 @@ def create_effect_text(
|
|||||||
|
|
||||||
return group
|
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(
|
def create_effect_row(
|
||||||
card: Card, effects: list[Effect], type: str, height: int, width: int
|
card: Card, effects: list[Effect], type: str, height: int, width: int
|
||||||
@@ -330,6 +363,9 @@ def create_effect_row(
|
|||||||
filter="url(#drop-shadow)",
|
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":
|
elif type == "suicide":
|
||||||
has_icon = True
|
has_icon = True
|
||||||
group.append(
|
group.append(
|
||||||
@@ -341,6 +377,30 @@ def create_effect_row(
|
|||||||
filter="url(#drop-shadow)",
|
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":
|
elif type == "champion_action":
|
||||||
has_icon = True
|
has_icon = True
|
||||||
@@ -349,10 +409,24 @@ def create_effect_row(
|
|||||||
cx=30,
|
cx=30,
|
||||||
cy=height / 2,
|
cy=height / 2,
|
||||||
r=15,
|
r=15,
|
||||||
|
fill="#444444",
|
||||||
|
filter="url(#drop-shadow)",
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
group.append(
|
||||||
|
dw.Circle(
|
||||||
|
cx=30,
|
||||||
|
cy=height / 2,
|
||||||
|
r=13,
|
||||||
fill="gray",
|
fill="gray",
|
||||||
filter="url(#drop-shadow)",
|
filter="url(#drop-shadow)",
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
subg = dw.Group(transform=f"translate({30},{height / 2})")
|
||||||
|
subg.append(create_arrow())
|
||||||
|
group.append(subg)
|
||||||
effect_with_icons = list(
|
effect_with_icons = list(
|
||||||
filter(lambda x: x.get("effect") in resourceIcons and not x.get("per"), effects)
|
filter(lambda x: x.get("effect") in resourceIcons and not x.get("per"), effects)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from card_types import Card, SkinData, SkinFile, Translation
|
|||||||
from drawsvg.drawing import Drawing
|
from drawsvg.drawing import Drawing
|
||||||
|
|
||||||
from edit_card import finish_card
|
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:
|
with open("src/data/translation_fr.json", encoding="utf-8") as f:
|
||||||
translation_fr: Translation = json.load(f)
|
translation_fr: Translation = json.load(f)
|
||||||
@@ -113,6 +114,9 @@ for card_data in cards:
|
|||||||
fill=f'url(#grad2-{card_data["id"]})',
|
fill=f'url(#grad2-{card_data["id"]})',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
faction_icon.append(
|
||||||
|
create_faction_icon("yellow", transform="scale(1.5)"),
|
||||||
|
)
|
||||||
|
|
||||||
# Define linear colored gradient
|
# Define linear colored gradient
|
||||||
gradient = dw.LinearGradient(
|
gradient = dw.LinearGradient(
|
||||||
|
|||||||
Reference in New Issue
Block a user