1
0

Configurable font and embedable sizes

This commit is contained in:
Ninjananas
2024-10-28 13:13:31 +01:00
parent e27b7941bb
commit f112f57e37
2 changed files with 14 additions and 11 deletions

View File

@@ -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

View File

@@ -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')