2020-10-20 09:59:13 +00:00
|
|
|
|
|
|
|
require 'squib'
|
|
|
|
|
|
|
|
# Squib::Deck.new cards: 3, layout: 'economy.yml' do
|
|
|
|
# background color: 'white'
|
|
|
|
# rect layout: 'cut' # cut line as defined by TheGameCrafter
|
|
|
|
# rect layout: 'safe' # safe zone as defined by TheGameCrafter
|
|
|
|
# text str: ['Occasion','Qualifier','Virus','Reflection'] , layout: 'title'
|
|
|
|
# text str: 'S.P.A.C.E.', layout: 'description'
|
|
|
|
# save format: :png
|
|
|
|
# end
|
|
|
|
|
2020-11-10 12:16:59 +00:00
|
|
|
# for csv data
|
2020-10-20 09:59:13 +00:00
|
|
|
data = Squib.csv file: 'cards.csv'
|
|
|
|
|
2020-10-22 12:33:59 +00:00
|
|
|
#layouts = ['economy.yml', 'space-layout-1.yml']
|
|
|
|
layouts = ['space-layout-2.yml']
|
2020-10-20 09:59:13 +00:00
|
|
|
|
|
|
|
c1 = '#9f68ed'
|
|
|
|
c2 = '#ed9f68'
|
|
|
|
c3 = '#b5ed68'
|
2020-10-20 11:12:52 +00:00
|
|
|
c4 = '#eeeeee'
|
2020-10-20 09:59:13 +00:00
|
|
|
|
|
|
|
# conditional coloring
|
|
|
|
# https://squib.readthedocs.io/en/v0.15.0/colors.html?highlight=color#samples
|
|
|
|
|
2020-10-20 11:12:52 +00:00
|
|
|
color = c1
|
2020-10-20 09:59:13 +00:00
|
|
|
|
2020-10-22 12:33:59 +00:00
|
|
|
Squib::Deck.new cards: data['name'].size, width: '38mm', height: '60mm', layout: layouts do
|
2020-10-20 09:59:13 +00:00
|
|
|
|
2020-10-20 11:12:52 +00:00
|
|
|
# set background colour per card type
|
|
|
|
bg = data['type'].map do |t|
|
|
|
|
if (t.eql? 'O')
|
|
|
|
c1
|
|
|
|
elsif (t.eql? 'Q')
|
|
|
|
c2
|
|
|
|
elsif (t.eql? 'Q')
|
|
|
|
c3
|
|
|
|
else
|
|
|
|
c4
|
|
|
|
end
|
|
|
|
end
|
2020-10-20 09:59:13 +00:00
|
|
|
|
2020-10-20 11:12:52 +00:00
|
|
|
# set fill colour per card type
|
|
|
|
fg = data['type'].map do |t|
|
|
|
|
if (t.eql? 'O')
|
|
|
|
c2
|
|
|
|
elsif (t.eql? 'Q')
|
|
|
|
c1
|
|
|
|
elsif (t.eql? 'Q')
|
|
|
|
c4
|
|
|
|
else
|
|
|
|
c4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-22 12:33:59 +00:00
|
|
|
# testing "Hanafuda" style/size cards
|
|
|
|
# https://squib.readthedocs.io/en/v0.15.0/text_feature.html#width-and-height
|
|
|
|
|
2020-10-20 11:12:52 +00:00
|
|
|
background color: bg
|
2020-10-22 12:33:59 +00:00
|
|
|
rect fill_color: fg , x: '3mm', y: '3mm', width: '32mm', height: '54mm', radius: 32
|
2020-10-20 11:12:52 +00:00
|
|
|
|
2020-10-22 12:33:59 +00:00
|
|
|
#rect layout: 'cut' # cut line as defined by TheGameCrafter in economy.yml
|
|
|
|
#rect layout: 'safe' # safe zone as defined by TheGameCrafter in economy.yml
|
|
|
|
|
2020-10-20 09:59:13 +00:00
|
|
|
text str: data['type'], layout: 'type'
|
2020-10-22 12:33:59 +00:00
|
|
|
text str: data['name'], layout: 'title'
|
2020-10-20 09:59:13 +00:00
|
|
|
text str: data['text'], layout: 'description'
|
|
|
|
svg file: data['illustration'], layout: 'illustration'
|
2020-10-22 12:33:59 +00:00
|
|
|
|
2020-10-20 11:12:52 +00:00
|
|
|
# output a png of each card and pdf of the deck
|
2020-10-20 09:59:13 +00:00
|
|
|
save_png
|
|
|
|
save_pdf
|
2020-10-20 11:12:52 +00:00
|
|
|
|
2020-10-20 09:59:13 +00:00
|
|
|
end
|