From f112f57e373c95e8d9f2c36db34cd00075b491aa Mon Sep 17 00:00:00 2001 From: Ninjananas Date: Mon, 28 Oct 2024 13:13:31 +0100 Subject: [PATCH] Configurable font and embedable sizes --- scripts/generate_layouts.py | 2 -- src/deck.rb | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/generate_layouts.py b/scripts/generate_layouts.py index 5497e8a..8fba07f 100644 --- a/scripts/generate_layouts.py +++ b/scripts/generate_layouts.py @@ -170,8 +170,6 @@ effect_text: y: {EFFECT_TEXT_Y}c width: {EFFECT_TEXT_WIDTH}c height: {EFFECT_TEXT_HEIGHT}c - font_size: 9 - spacing: 5 align: center valign: middle markup: true diff --git a/src/deck.rb b/src/deck.rb index 2e6ca6f..fbe75c7 100644 --- a/src/deck.rb +++ b/src/deck.rb @@ -1,5 +1,17 @@ require 'squib' + +DPI = 300 +CELL_PX = DPI / 8.0 +BLEED = 0.125 # In inches +WIDTH = (2.5 + 2*BLEED) * DPI +HEIGHT = (3.5 + 2*BLEED) * DPI +EFFECT_FONT_SIZE = 8 +EFFECT_FONT_SPACING = 5 +EMBED_SIZE = EFFECT_FONT_SIZE / 9.0 # In cells +EMBED_DY = - (0.7 * EMBED_SIZE + 0.2) * DPI / 300 # In cells + + data = Squib.xlsx file: 'data/cards.xlsx', explode: 'quantite' def icon_to_svg(icon) @@ -42,20 +54,13 @@ def get_art(data, idx) icon = data['icone'][idx] icon_alt = data['icone_alt'][idx] icon_alt = icon_alt.nil? ? '' : "_#{icon_alt}" - puts "default_art_#{icon}#{icon_alt}.svg" return "default_art_#{icon}#{icon_alt}.svg" end def embed_custom(embed, id) - embed.svg width: '0.8c', height: '0.8c', dx: '0c', dy: '-0.7c', key: ":#{id}:", file: "._graphics/#{id}.svg" + embed.svg width: "#{EMBED_SIZE}c", height: "#{EMBED_SIZE}c", dx: '0c', dy: "#{EMBED_DY}c", key: ":#{id}:", file: "._graphics/#{id}.svg" end -DPI = 300 -CELL_PX = DPI / 8.0 -BLEED = 0.125 # In inches -WIDTH = (2.5 + 2*BLEED) * DPI -HEIGHT = (3.5 + 2*BLEED) * DPI - Squib.configure cell_px: CELL_PX Squib::Deck.new( @@ -106,7 +111,7 @@ Squib::Deck.new( fill_color = data['effet'].map { |effet| effet.nil? ? '#0000': '#f7f7f7ff' } stroke_color = data['effet'].map { |effet| effet.nil? ? '#0000': '#cca9' } rect layout: 'effect_frame', fill_color: fill_color, stroke_color: stroke_color - text(str: data['effet'], layout: 'effect_text') do |embed| + text(str: data['effet'], layout: 'effect_text', font_size: EFFECT_FONT_SIZE, spacing: EFFECT_FONT_SPACING) do |embed| embed_custom(embed, 'effet') embed_custom(embed, 'magouille') embed_custom(embed, 'pv')