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 data = Squib.csv file: 'cards.csv' #layouts = ['economy.yml', 'space-layout-1.yml'] layouts = ['space-layout-2.yml'] c1 = '#9f68ed' c2 = '#ed9f68' c3 = '#b5ed68' c4 = '#eeeeee' # conditional coloring # https://squib.readthedocs.io/en/v0.15.0/colors.html?highlight=color#samples color = c1 Squib::Deck.new cards: data['name'].size, width: '38mm', height: '60mm', layout: layouts do # 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 # 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 # testing "Hanafuda" style/size cards # https://squib.readthedocs.io/en/v0.15.0/text_feature.html#width-and-height background color: bg rect fill_color: fg , x: '3mm', y: '3mm', width: '32mm', height: '54mm', radius: 32 #rect layout: 'cut' # cut line as defined by TheGameCrafter in economy.yml #rect layout: 'safe' # safe zone as defined by TheGameCrafter in economy.yml text str: data['type'], layout: 'type' text str: data['name'], layout: 'title' text str: data['text'], layout: 'description' svg file: data['illustration'], layout: 'illustration' # output a png of each card and pdf of the deck save_png save_pdf end