feat: first ver with 1 card and a bit of variabilisation
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<svg baseProfile="tiny" height="417px" version="1.2" width="298px" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><rect fill="rgb(206, 182, 167)" height="417px" rx="10" ry="10" width="298px" x="0" y="0" /><rect fill="white" height="50px" width="298px" x="0" y="0" /><text fill="black" font-size="24px" font-weight="bold" text-anchor="middle" x="130" y="30">Rallier les Troupes</text><text fill="black" font-size="16px" x="10" y="70">Action, Charme</text><circle cx="268" cy="25" fill="yellow" r="20" /><text fill="black" font-size="24px" font-weight="bold" x="263" y="32">4</text><image height="180" width="298" x="0" xlink:href="lancersiz3.png" y="80" /><circle cx="100" cy="305" fill="red" r="25" /><text fill="white" font-size="24px" font-weight="bold" text-anchor="middle" x="100" y="314">5</text><circle cx="210" cy="305" fill="green" r="25" /><text fill="white" font-size="24px" font-weight="bold" text-anchor="middle" x="210" y="314">5</text><line stroke="black" stroke-width="1" x1="20" x2="278" y1="360" y2="360" /><text fill="black" font-size="16px" text-anchor="middle" x="149.0" y="390">Mobilisez un Champion.</text></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"title": "Rallier les Troupes",
|
||||
"type": "Action, Charme",
|
||||
"faction": "yellow",
|
||||
"cost": 4,
|
||||
"image_path": "lancersiz3.png",
|
||||
"row_1": {
|
||||
"damage": 5,
|
||||
"heal": 5
|
||||
},
|
||||
"row_2": {
|
||||
"effect": "Mobilisez un Champion."
|
||||
}
|
||||
}
|
||||
|
||||
+111
-49
@@ -1,63 +1,125 @@
|
||||
# import svgwrite
|
||||
# from svgwrite import cm, mm, px
|
||||
|
||||
# # Configuration des chemins vers les icônes
|
||||
# icons = {
|
||||
# 'degats': 'path/to/damage_icon.svg',
|
||||
# 'or': 'path/to/gold_icon.svg',
|
||||
# 'soin': 'path/to/heal_icon.svg'
|
||||
# }
|
||||
|
||||
# # Configuration des couleurs de fond
|
||||
# background_colors = {
|
||||
# 'bleue': 'lightblue',
|
||||
# 'rouge': 'lightcoral',
|
||||
# 'jaune': 'lightyellow',
|
||||
# 'verte': 'lightgreen',
|
||||
# 'sans': 'white'
|
||||
# }
|
||||
|
||||
# def generate_card_svg(name, description, color, effects, output_path):
|
||||
# # Créer un dessin SVG
|
||||
# dwg = svgwrite.Drawing(output_path, profile='tiny', size=(8*cm, 12*cm))
|
||||
|
||||
# # Ajouter un rectangle de fond
|
||||
# dwg.add(dwg.rect(insert=(0, 0), size=('100%', '100%'), fill=background_colors[color]))
|
||||
|
||||
# # Ajouter le titre de la carte
|
||||
# dwg.add(dwg.text(name, insert=(0.5*cm, 1*cm), font_size="20px", fill='black'))
|
||||
|
||||
# # Ajouter la description
|
||||
# dwg.add(dwg.text(description, insert=(0.5*cm, 2*cm), font_size="12px", fill='black'))
|
||||
|
||||
# # Ajouter les effets
|
||||
# y_offset = 3*cm
|
||||
# for effect in effects:
|
||||
# if effect['type'] in icons:
|
||||
# # Ajouter l'icône
|
||||
# dwg.add(dwg.image(href=icons[effect['type']], insert=(0.5*cm, y_offset), size=(1*cm, 1*cm)))
|
||||
# # Ajouter le texte de l'effet
|
||||
# dwg.add(dwg.text(effect['text'], insert=(2*cm, y_offset + 0.75*cm), font_size="15px", fill='black'))
|
||||
# else:
|
||||
# # Ajouter le texte de l'effet sans icône
|
||||
# dwg.add(dwg.text(effect['text'], insert=(0.5*cm, y_offset + 0.75*cm), font_size="15px", fill='black'))
|
||||
# y_offset += 2*cm
|
||||
|
||||
# # Sauvegarder le fichier SVG
|
||||
# dwg.save()
|
||||
|
||||
# # Exemple d'utilisation
|
||||
# card_info = {
|
||||
# 'name': 'Niko Incendiaire',
|
||||
# 'description': 'Action, ghdj;spftgljh.-',
|
||||
# 'color': 'bleue',
|
||||
# 'effects': [
|
||||
# {'type': 'degats', 'text': '8 Dégâts'},
|
||||
# {'type': 'or', 'text': '5 Or'}
|
||||
# ]
|
||||
# }
|
||||
|
||||
# output_path = 'niko_incendiaire.svg'
|
||||
# generate_card_svg(**card_info, output_path=output_path)
|
||||
|
||||
# print('Carte SVG générée avec succès!')
|
||||
|
||||
import svgwrite
|
||||
from svgwrite import cm, mm, px
|
||||
import json
|
||||
|
||||
# Configuration des chemins vers les icônes
|
||||
icons = {
|
||||
'degats': 'path/to/damage_icon.svg',
|
||||
'or': 'path/to/gold_icon.svg',
|
||||
'soin': 'path/to/heal_icon.svg'
|
||||
}
|
||||
# Load card data from JSON file
|
||||
with open('src/card_data.json') as f:
|
||||
card_data = json.load(f)
|
||||
|
||||
# Params
|
||||
x_width = 298
|
||||
y_height = 417
|
||||
stats_radius = 25
|
||||
row_1_base_y = 280
|
||||
row_2_base_y = 390
|
||||
row_1_to_2_separator_y = 360
|
||||
row_1_to_2_separator_shorten_by = 20
|
||||
|
||||
# Configuration des couleurs de fond
|
||||
background_colors = {
|
||||
'bleue': 'lightblue',
|
||||
'rouge': 'lightcoral',
|
||||
'jaune': 'lightyellow',
|
||||
'verte': 'lightgreen',
|
||||
'sans': 'white'
|
||||
'blue': 'lightblue',
|
||||
'red': 'lightcoral',
|
||||
'yellow': 'rgb(206, 182, 167)',
|
||||
'green': 'lightgreen',
|
||||
'base': 'lightgrey'
|
||||
}
|
||||
|
||||
def generate_card_svg(name, description, color, effects, output_path):
|
||||
# Créer un dessin SVG
|
||||
dwg = svgwrite.Drawing(output_path, profile='tiny', size=(8*cm, 12*cm))
|
||||
|
||||
# Ajouter un rectangle de fond
|
||||
dwg.add(dwg.rect(insert=(0, 0), size=('100%', '100%'), fill=background_colors[color]))
|
||||
# Create a new SVG drawing
|
||||
dwg = svgwrite.Drawing('card.svg', profile='tiny', size=(str(x_width) + 'px', str(y_height) + 'px'))
|
||||
|
||||
# Ajouter le titre de la carte
|
||||
dwg.add(dwg.text(name, insert=(0.5*cm, 1*cm), font_size="20px", fill='black'))
|
||||
# Draw card background
|
||||
dwg.add(dwg.rect(insert=(0, 0), size=(str(x_width) + 'px', str(y_height) + 'px'), rx=10, ry=10, fill=background_colors[card_data['faction']]))
|
||||
|
||||
# Ajouter la description
|
||||
dwg.add(dwg.text(description, insert=(0.5*cm, 2*cm), font_size="12px", fill='black'))
|
||||
# Draw title area
|
||||
dwg.add(dwg.rect(insert=(0, 0), size=(str(x_width) + 'px', '50px'), fill='white'))
|
||||
dwg.add(dwg.text(card_data['title'], insert=(130, 30), text_anchor='middle', fill='black', font_size='24px', font_weight="bold"))
|
||||
|
||||
# Ajouter les effets
|
||||
y_offset = 3*cm
|
||||
for effect in effects:
|
||||
if effect['type'] in icons:
|
||||
# Ajouter l'icône
|
||||
dwg.add(dwg.image(href=icons[effect['type']], insert=(0.5*cm, y_offset), size=(1*cm, 1*cm)))
|
||||
# Ajouter le texte de l'effet
|
||||
dwg.add(dwg.text(effect['text'], insert=(2*cm, y_offset + 0.75*cm), font_size="15px", fill='black'))
|
||||
else:
|
||||
# Ajouter le texte de l'effet sans icône
|
||||
dwg.add(dwg.text(effect['text'], insert=(0.5*cm, y_offset + 0.75*cm), font_size="15px", fill='black'))
|
||||
y_offset += 2*cm
|
||||
# Draw type area
|
||||
dwg.add(dwg.text(card_data['type'], insert=(10, 70), fill='black', font_size='16px'))
|
||||
|
||||
# Sauvegarder le fichier SVG
|
||||
dwg.save()
|
||||
# Draw cost circle
|
||||
dwg.add(dwg.circle(center=(x_width - 30, 25), r=20, fill='yellow'))
|
||||
dwg.add(dwg.text(str(card_data['cost']), insert=(x_width - 35, 32), fill='black', font_size='24px', font_weight="bold"))
|
||||
|
||||
# Exemple d'utilisation
|
||||
card_info = {
|
||||
'name': 'Niko Incendiaire',
|
||||
'description': 'Action, ghdj;spftgljh.-',
|
||||
'color': 'bleue',
|
||||
'effects': [
|
||||
{'type': 'degats', 'text': '8 Dégâts'},
|
||||
{'type': 'or', 'text': '5 Or'}
|
||||
]
|
||||
}
|
||||
# Draw image area
|
||||
dwg.add(dwg.image(card_data['image_path'], insert=(0, 80), size=(x_width, 180)))
|
||||
|
||||
output_path = 'niko_incendiaire.svg'
|
||||
generate_card_svg(**card_info, output_path=output_path)
|
||||
# TODO: figure out nb of effects and adjust row_1_x_offset accordingly
|
||||
# Draw row 1 stats
|
||||
dwg.add(dwg.circle(center=(100, row_1_base_y + stats_radius), r=25, fill='red'))
|
||||
dwg.add(dwg.text(str(card_data['row_1']['damage']), insert=(100, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='white', font_size='24px', font_weight="bold"))
|
||||
|
||||
print('Carte SVG générée avec succès!')
|
||||
dwg.add(dwg.circle(center=(210, row_1_base_y + stats_radius), r=25, fill='green'))
|
||||
dwg.add(dwg.text(str(card_data['row_1']['heal']), insert=(210, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='white', font_size='24px', font_weight="bold"))
|
||||
|
||||
if card_data['row_2']:
|
||||
# Draw row 1 to row 2 separator
|
||||
dwg.add(dwg.line(start=(0 + row_1_to_2_separator_shorten_by, row_1_to_2_separator_y), end=(x_width - row_1_to_2_separator_shorten_by, row_1_to_2_separator_y), stroke='black', stroke_width=1))
|
||||
# Draw row 2 effect text
|
||||
dwg.add(dwg.text(card_data['row_2']['effect'], insert=(x_width/2, row_2_base_y), text_anchor='middle', fill='black', font_size='16px'))
|
||||
|
||||
# Save the SVG file
|
||||
dwg.save()
|
||||
|
||||
Reference in New Issue
Block a user