Browse Source

Two new built-in layouts: fantasy.yml and economy.yml

Contributes to #97
dev
Andy Meneely 11 years ago
parent
commit
003a26ae68
  1. 3
      CHANGELOG.md
  2. 10
      README.md
  3. 85
      lib/squib/layouts/economy.yml
  4. 101
      lib/squib/layouts/fantasy.yml
  5. 16
      lib/squib/layouts/hand.yml
  6. 19
      lib/squib/layouts/playing-card.yml
  7. 6
      samples/color_shortcuts.rb
  8. 52
      samples/layouts_builtin.rb

3
CHANGELOG.md

@ -11,7 +11,8 @@ Features
* The `text` method and several other methods will throw errors on invalid input. This means your scripts will be more likely to break if you provide bad input. Please report bugs if you thinkg this unfairly breaks your code.
* The `text` embedding icon now allows singleton expansion, which means that you can have icons have different sizes on different cards. The sample `embed_text.rb` demonstrates this. (#54)
* The `text` method will throw a warning when it needs to ellipsize text (i.e. too much text for a fixed-size text box). Can be turned off in `config.yml`. (#80)
* Upgraded roo (Excel parsing) to 2.1.0. Macro-enabled Excel files can be parsed now (i.e. `xlsm`), although I've only mildly tested this.
* Upgraded roo (Excel parsing) to 2.1.0. Macro-enabled Excel files can be parsed now (i.e. `xlsm`), although I've only mildly tested this. (cddea47ba56add286639e493d5cc0146245eca68)
* New built-in layouts: `fantasy.yml` and `economy.yml`. Demonstrated in new sample `layouts_builtin.rb` (#97)
Compatibility:
* All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This means that your `stroke_width` might render wider than before, but now it's accurate.

10
README.md

@ -411,7 +411,11 @@ YAML merge keys are NOT supported across multiple files - use `extends` instead.
### Built-in Layout Files
If your layout file is not found in the current directory, Squib will search for its own set of layout files (here's the latest the development version [on GitHub](https://github.com/andymeneely/squib/tree/master/lib/squib/layouts). See the `layouts.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/) for some demonstrative examples.
Why mess with x-y coordinates when you're first prototyping your game?!?!? Just use a built-in layout to get your game to the table as quickly as possible.
If your layout file is not found in the current directory, Squib will search for its own set of layout files. The latest the development version of these can be found [on GitHub](https://github.com/andymeneely/squib/tree/master/lib/squib/layouts). The `layouts_builtin.rb` sample (found [here](https://github.com/andymeneely/squib/tree/master/samples/)) demonstrate built-in layouts based on popular games (e.g. `fantasy.yml` and `economy.yml`)
Contributions in this area are particularly welcome!
### Layout Sample
This sample demonstrates many different ways of using and combining layouts. This is the `layouts.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
@ -531,7 +535,7 @@ We don't officially support Google Sheets ([yet](https://github.com/andymeneely/
## Combining Multiple Columns
Say you have multiple columns in your Excel sheet that need to be combined into one text field on your card. Consider using `zip` in conjunction with `map`.
Say you have multiple columns in your Excel sheet that need to be combined into one text field on your card. Consider using `zip` in conjunction with `map`.
```ruby
data['BuyText'] = data['BuyAmount'].zip(data['BuyType']).map do |amt, type|
@ -579,4 +583,4 @@ Truthfully, I just thought it was a cool, simple word that was not used much in
* Squibs are small explosive devices, much like Squib "explodes" your rules into a playable game
* Squibs are often used in heist movies, leading to a sudden plot twist that often resembles the twists of good tabletop game
* Squibs are also part of the Harry Potter world - they are people who are non-magical but wizard-born. Squib is aware of wizarding magic and comes from that heritage, but it's not magical itself.
* Squibs are also part of the Harry Potter world - they are people who are non-magical but wizard-born. Squib is aware of wizarding magic and comes from that heritage, but it's not magical itself.

85
lib/squib/layouts/economy.yml

@ -0,0 +1,85 @@
#This layout inspired by popular fantasy games
title:
x: 90
y: 90
width: 635
height: 50
align: center
art:
x: 75
y: 150
width: 675
height: 520
description:
x: 100
y: 675
width: 625
height: 275
valign: middle
align: center
font_size: 18
desc: # alias
extends: description
type:
x: 90
y: 955
width: 645
height: 50
align: center
lower_right:
x: 675
y: 975
width: 75
height: 75
font_size: 18
valign: bottom
align: right
lr: #alias
extends: lower_right
lower_left:
x: 75
y: 975
width: 75
height: 75
font_size: 18
valign: bottom
align: left
ll: # alias
extends: lower_left
copyright:
x: 75
y: 1025
width: 675
height: 25
font_size: 16
align: center
valign: bottom
#aliases for copyright
copy:
extends: copyright
credit:
extends: copyright
credits:
extends: copyright
# The "cut line", without rounded corners
cut:
x: 37.5
y: 37.5
width: 750
height: 1050
# The "safe zone" as defined by TheGameCrafter poker cards
safe:
x: 75
y: 75
width: 675
height: 975
radius: 16
dash: 3 3

101
lib/squib/layouts/fantasy.yml

@ -0,0 +1,101 @@
#This layout inspired by popular fantasy games
title:
x: 90
y: 90
width: 500
height: 50
upper_right:
x: 595
y: 90
width: 135
height: 50
align: right
ur: # alias
extends: upper_right
art:
x: 75
y: 150
width: 675
height: 520
type:
x: 90
y: 675
width: 500
height: 50
type_right:
x: 595
y: 675
width: 135
height: 50
align: right
tr: #alias
extends: type_right
description:
x: 100
y: 730
width: 625
height: 275
valign: middle
align: center
font_size: 18
desc: # alias
extends: description
lower_right:
x: 675
y: 975
width: 75
height: 75
font_size: 18
valign: bottom
align: right
lr: #alias
extends: lower_right
lower_left:
x: 75
y: 975
width: 75
height: 75
font_size: 18
valign: bottom
align: left
ll: # alias
extends: lower_left
copyright:
x: 75
y: 1025
width: 675
height: 25
font_size: 16
align: center
valign: bottom
#aliases for copyright
copy:
extends: copyright
credit:
extends: copyright
credits:
extends: copyright
# The "cut line", without rounded corners
cut:
x: 37.5
y: 37.5
width: 750
height: 1050
# The "safe zone" as defined by TheGameCrafter poker cards
safe:
x: 75
y: 75
width: 675
height: 975
radius: 16
dash: 3 3

16
lib/squib/layouts/hand.yml

@ -44,3 +44,19 @@ bonus4:
bonus5:
extends: bonus4
y: += 198
# The "cut line", without rounded corners
cut:
x: 37.5
y: 37.5
width: 750
height: 1050
# The "safe zone" as defined by TheGameCrafter poker cards
safe:
x: 75
y: 75
width: 675
height: 975
radius: 16
dash: 3 3

19
lib/squib/layouts/playing-card.yml

@ -1,4 +1,5 @@
# A basic playing card layout with bonuses in the upper-left and lower-right. The lower-right angle is rotated for text.
# A basic playing card layout with bonuses in the upper-left and lower-right.
# The lower-right angle is rotated for text.
bonus_ul:
x: 75
y: 75
@ -16,3 +17,19 @@ art:
height: 575
valign: middle
align: center
# The "cut line", without rounded corners
cut:
x: 37.5
y: 37.5
width: 750
height: 1050
# The "safe zone" as defined by TheGameCrafter poker cards
safe:
x: 75
y: 75
width: 675
height: 975
radius: 16
dash: 3 3

6
samples/color_shortcuts.rb

@ -0,0 +1,6 @@
require 'squib'
Squib::Deck.new do
circle color: 'black', fill_color: 'black'
save_png prefix: 'color_shortcuts_'
end

52
samples/layouts_builtin.rb

@ -0,0 +1,52 @@
require 'squib'
# This sample demonstrates the built-in layouts for Squib.
# Each card demonstrates a different built-in layout.
Squib::Deck.new(layout: 'fantasy.yml') do
background color: 'white'
set font: 'Times New Roman,Serif 32'
hint text: '#333' # show extents of text boxes to demo the layout
text str: 'fantasy.yml', layout: :title
text str: 'ur', layout: :upper_right
text str: 'art', layout: :art
text str: 'type', layout: :type
text str: 'tr', layout: :type_right
text str: 'description', layout: :description
text str: 'lr', layout: :lower_right
text str: 'll', layout: :lower_left
text str: 'credits', layout: :copy
rect layout: :safe
rect layout: :cut
save_png prefix: 'layouts_builtin_fantasy_'
end
Squib::Deck.new(layout: 'economy.yml') do
background color: 'white'
set font: 'Times New Roman,Serif 32'
hint text: '#333' # show extents of text boxes to demo the layout
text str: 'economy.yml', layout: :title
text str: 'art', layout: :art
text str: 'description', layout: :description
text str: 'type', layout: :type
text str: 'lr', layout: :lower_right
text str: 'll', layout: :lower_left
text str: 'credits', layout: :copy
rect layout: :safe
rect layout: :cut
save_png prefix: 'layouts_builtin_economy_'
end
# Stitch together a deck of all the above examples
Squib::Deck.new(cards: 2) do
puts Dir.glob('_output/layouts_builtin_*.png')
Dir.glob('_output/layouts_builtin_*.png').each.with_index do |file, i|
png file: file, range: i
end
save_sheet prefix: 'layouts_builtinsheet_'
end
Loading…
Cancel
Save