From 2024b2529c14a9566df75f8bd9b88fbf7644345c Mon Sep 17 00:00:00 2001 From: Erzangel <57399897+Erzangel@users.noreply.github.com> Date: Tue, 21 May 2024 21:57:40 +0200 Subject: [PATCH] feat: bourred chatgpt first draft --- requirements.txt | 1 + src/generate_cards_mvp.py | 63 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 requirements.txt create mode 100644 src/generate_cards_mvp.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6224855 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +svgwrite \ No newline at end of file diff --git a/src/generate_cards_mvp.py b/src/generate_cards_mvp.py new file mode 100644 index 0000000..945a1d3 --- /dev/null +++ b/src/generate_cards_mvp.py @@ -0,0 +1,63 @@ +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!')