From 003a26ae681ca0d670250e99968ca239161d5819 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Sun, 26 Jul 2015 00:59:12 -0400 Subject: [PATCH] Two new built-in layouts: fantasy.yml and economy.yml Contributes to #97 --- CHANGELOG.md | 3 +- README.md | 10 ++- lib/squib/layouts/economy.yml | 85 ++++++++++++++++++++++++ lib/squib/layouts/fantasy.yml | 101 +++++++++++++++++++++++++++++ lib/squib/layouts/hand.yml | 16 +++++ lib/squib/layouts/playing-card.yml | 19 +++++- samples/color_shortcuts.rb | 6 ++ samples/layouts_builtin.rb | 52 +++++++++++++++ 8 files changed, 287 insertions(+), 5 deletions(-) create mode 100644 lib/squib/layouts/economy.yml create mode 100644 lib/squib/layouts/fantasy.yml create mode 100644 samples/color_shortcuts.rb create mode 100644 samples/layouts_builtin.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3af64..43249e5 100644 --- a/CHANGELOG.md +++ b/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. diff --git a/README.md b/README.md index 7a9a81d..e7c5fc0 100644 --- a/README.md +++ b/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. \ No newline at end of file +* 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. diff --git a/lib/squib/layouts/economy.yml b/lib/squib/layouts/economy.yml new file mode 100644 index 0000000..00f4c37 --- /dev/null +++ b/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 diff --git a/lib/squib/layouts/fantasy.yml b/lib/squib/layouts/fantasy.yml new file mode 100644 index 0000000..79f2bca --- /dev/null +++ b/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 diff --git a/lib/squib/layouts/hand.yml b/lib/squib/layouts/hand.yml index 4c3265b..adab230 100644 --- a/lib/squib/layouts/hand.yml +++ b/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 diff --git a/lib/squib/layouts/playing-card.yml b/lib/squib/layouts/playing-card.yml index 741e282..a491be3 100644 --- a/lib/squib/layouts/playing-card.yml +++ b/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 diff --git a/samples/color_shortcuts.rb b/samples/color_shortcuts.rb new file mode 100644 index 0000000..14da3bc --- /dev/null +++ b/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 diff --git a/samples/layouts_builtin.rb b/samples/layouts_builtin.rb new file mode 100644 index 0000000..d5af9ed --- /dev/null +++ b/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