From 569aa630a2c34ae799252d1f85b751845f737ef6 Mon Sep 17 00:00:00 2001 From: Erzangel Date: Fri, 20 Mar 2026 17:07:10 +0100 Subject: [PATCH] feat(wip): flavor text sample --- src/convert/README.md | 7 ++++- src/draw_functions.py | 65 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/convert/README.md b/src/convert/README.md index 7dabacb..40bc9b9 100644 --- a/src/convert/README.md +++ b/src/convert/README.md @@ -11,4 +11,9 @@ local file used to track next stuff to do - Fix larger names - Fix 20 - Fix 19 -- Texte du Con Artist avec la bonne couleur; Pareil pour Kikuri \ No newline at end of file +- Texte du Con Artist avec la bonne couleur; Pareil pour Kikuri + + +## Idées + +- 69: demonic cloud -> darkness CSM \ No newline at end of file diff --git a/src/draw_functions.py b/src/draw_functions.py index 596a8c3..23390bf 100644 --- a/src/draw_functions.py +++ b/src/draw_functions.py @@ -583,15 +583,62 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int): effect_types = list(grouped_effects.keys()) if len(grouped_effects) == 1: - group.append( - create_effect_row( - card=card, - effects=grouped_effects[effect_types[0]], - type=effect_types[0], - height=height, - width=width, - ), - ) + if False: + group.append( + create_effect_row( + card=card, + effects=grouped_effects[effect_types[0]], + type=effect_types[0], + height=height, + width=width, + ), + ) + else: + group.append( + dw.Line(sx=10, sy=80, ex=width - 10, ey=80, stroke="black", stroke_width=1) + ) + group.append( + create_effect_row( + card=card, + effects=grouped_effects[effect_types[0]], + type=effect_types[0], + height=80, + width=width, + ), + ) + flavor_text = "chouette!" + + font_width = 0.5 + line_width = ( + max(*[len(x) for x in flavor_text.split("\n")], len(flavor_text)) * font_width + ) + # Take width in account + font_size = effect_text_size + font_size = min( + font_size, (font_size * 3) - line_width, font_size * width / (line_width or 1) + ) + # Take height in account + font_size = min((height) / (flavor_text.count("\n") or 1), font_size) + + font_size = max(font_size, 11) + + group.append( + dw.Group( + [ + dw.Text( + text="Funky!", # TODO: mettre en italique & gris + x=0, + y=(-font_size / 2) * flavor_text.count("\n"), + text_anchor="middle", + fill="black", + font_size=font_size, + font_family="Helvetica", + transform=f"translate({width / 2},{height - 80})" + ) + ], + transform=f"translate({0},{55})" + ) + ) if len(grouped_effects) == 2: group.append( dw.Line(sx=10, sy=80, ex=width - 10, ey=80, stroke="black", stroke_width=1)