Support for built-in layouts, with examples
parent
cad197553b
commit
569464a575
|
|
@ -112,10 +112,17 @@ module Squib
|
|||
@layout = {}
|
||||
Squib::logger.info { " using layout(s): #{files}" }
|
||||
Array(files).each do |file|
|
||||
yml = @layout.merge(YAML.load_file(file))
|
||||
thefile = file
|
||||
thefile = "#{File.dirname(__FILE__)}/layouts/#{file}" unless File.exists?(file)
|
||||
if File.exists? thefile
|
||||
yml = @layout.merge(YAML.load_file(thefile))
|
||||
yml.each do |key, value|
|
||||
@layout[key] = recurse_extends(yml, key, {})
|
||||
end
|
||||
else
|
||||
puts "the file: #{thefile}"
|
||||
Squib::logger.error { "Layout file not found: #{file}" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
title:
|
||||
x: 275
|
||||
y: 75
|
||||
width: 475
|
||||
height: 125
|
||||
art:
|
||||
x: 275
|
||||
y: 225
|
||||
width: 475
|
||||
height: 475
|
||||
description:
|
||||
x: 275
|
||||
y: 725
|
||||
width: 475
|
||||
height: 200
|
||||
snark:
|
||||
x: 275
|
||||
y: 950
|
||||
width: 475
|
||||
height: 100
|
||||
bonus1:
|
||||
x: 75
|
||||
y: 75
|
||||
width: 175
|
||||
height: 175
|
||||
bonus2:
|
||||
extends: bonus1
|
||||
y: += 198
|
||||
bonus3:
|
||||
extends: bonus2
|
||||
y: += 198
|
||||
bonus4:
|
||||
extends: bonus3
|
||||
y: += 198
|
||||
bonus5:
|
||||
extends: bonus4
|
||||
y: += 198
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
bonus_ul:
|
||||
x: 75
|
||||
y: 75
|
||||
width: 200
|
||||
height: 200
|
||||
bonus_lr:
|
||||
extends: bonus_ul
|
||||
x: 750
|
||||
y: 1050
|
||||
angle: 3.14159
|
||||
art:
|
||||
x: 150
|
||||
y: 275
|
||||
width: 525
|
||||
height: 575
|
||||
valign: middle
|
||||
align: center
|
||||
|
|
@ -39,3 +39,22 @@ Squib::Deck.new(layout:['custom-layout.yml', 'custom-layout2.yml']) do
|
|||
text str: 'The Description', layout: :description # from custom-layout2.yml
|
||||
save_png prefix: 'layout2_'
|
||||
end
|
||||
|
||||
# Built-in layouts are easy to use and extend
|
||||
Squib::Deck.new(layout: 'playing-card.yml') do
|
||||
text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
|
||||
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
|
||||
text str: "artwork here", layout: :art, hint: :red
|
||||
save_png prefix: 'layout_builtin_playing_card_'
|
||||
end
|
||||
|
||||
# Built-in layouts are easy to use and extend
|
||||
Squib::Deck.new(layout: 'hand.yml') do
|
||||
%w(title bonus1 bonus2 bonus3 bonus4 bonus5
|
||||
description snark art).each do |icon|
|
||||
text str: icon.capitalize, layout: icon,
|
||||
hint: :red, valign: 'middle', align: 'center'
|
||||
end
|
||||
png file: 'pokercard.png', alpha: 0.5
|
||||
save_png prefix: 'layout_builtin_hand_'
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue