squib 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.gitmodules +22 -0
  4. data/.travis.yml +4 -5
  5. data/CHANGELOG.md +23 -0
  6. data/CONTRIBUTING.md +40 -0
  7. data/README.md +25 -553
  8. data/RELEASE TODO.md +2 -2
  9. data/Rakefile +6 -64
  10. data/appveyor.yml +0 -4
  11. data/benchmarks/antialias_best.rb +2 -2
  12. data/benchmarks/antialias_fast.rb +2 -2
  13. data/benchmarks/{backend-memory.rb → backend_memory.rb} +2 -2
  14. data/benchmarks/{backend-svg.rb → backend_svg.rb} +2 -2
  15. data/benchmarks/tons_of_png.rb +1 -1
  16. data/benchmarks/tons_of_svg.rb +1 -1
  17. data/benchmarks/tons_of_text.rb +1 -1
  18. data/docs/Makefile +216 -0
  19. data/docs/_static/css/squibdocs.css +18 -0
  20. data/docs/args/draw.rst +36 -0
  21. data/docs/args/expansion.rst +3 -0
  22. data/docs/args/layout.rst +6 -0
  23. data/docs/args/output_dir.rst +6 -0
  24. data/docs/args/range.rst +6 -0
  25. data/docs/args/transform.rst +51 -0
  26. data/docs/args/trim.rst +11 -0
  27. data/docs/args/wh.rst +12 -0
  28. data/docs/args/xy.rst +12 -0
  29. data/docs/arrays.rst +77 -0
  30. data/docs/backends.rst +20 -0
  31. data/docs/bleed.rst +13 -0
  32. data/docs/build_groups.rst +47 -0
  33. data/docs/colors.rst +64 -0
  34. data/docs/conf.py +287 -0
  35. data/docs/config.rst +117 -0
  36. data/docs/data.rst +22 -0
  37. data/docs/dsl/background.rst +20 -0
  38. data/docs/dsl/build.rst +32 -0
  39. data/docs/dsl/build_groups.rst +23 -0
  40. data/docs/dsl/circle.rst +27 -0
  41. data/docs/dsl/cm.rst +19 -0
  42. data/docs/dsl/csv.rst +62 -0
  43. data/docs/dsl/curve.rst +63 -0
  44. data/docs/dsl/deck.rst +45 -0
  45. data/docs/dsl/disable_build.rst +28 -0
  46. data/docs/dsl/ellipse.rst +17 -0
  47. data/docs/dsl/enable_build.rst +25 -0
  48. data/docs/dsl/grid.rst +31 -0
  49. data/docs/dsl/hand.rst +40 -0
  50. data/docs/dsl/hint.rst +15 -0
  51. data/docs/dsl/inches.rst +19 -0
  52. data/docs/dsl/index.rst +9 -0
  53. data/docs/dsl/line.rst +52 -0
  54. data/docs/dsl/png.rst +49 -0
  55. data/docs/dsl/polygon.rst +28 -0
  56. data/docs/dsl/rect.rst +18 -0
  57. data/docs/dsl/save.rst +23 -0
  58. data/docs/dsl/save_pdf.rst +48 -0
  59. data/docs/dsl/save_png.rst +46 -0
  60. data/docs/dsl/save_sheet.rst +55 -0
  61. data/docs/dsl/showcase.rst +65 -0
  62. data/docs/dsl/star.rst +35 -0
  63. data/docs/dsl/svg.rst +119 -0
  64. data/docs/dsl/text.rst +294 -0
  65. data/docs/dsl/triangle.rst +38 -0
  66. data/docs/dsl/use_layout.rst +16 -0
  67. data/docs/dsl/xlsx.rst +50 -0
  68. data/docs/guides/game_icons.rst +2 -0
  69. data/docs/guides/getting-started/index.rst +5 -0
  70. data/docs/guides/getting-started/part_0_learning_ruby.rst +145 -0
  71. data/docs/guides/getting-started/part_1_zero_to_game.rst +216 -0
  72. data/docs/guides/getting-started/part_2_iconography.rst +152 -0
  73. data/docs/guides/getting-started/part_3_workflows.rst +4 -0
  74. data/docs/guides/git.rst +13 -0
  75. data/docs/guides/hello_world.rst +6 -0
  76. data/docs/help.rst +157 -0
  77. data/docs/index.rst +35 -0
  78. data/docs/install.rst +66 -0
  79. data/docs/layouts.rst +235 -0
  80. data/docs/learning.rst +10 -0
  81. data/docs/make.bat +263 -0
  82. data/docs/parameters.rst +26 -0
  83. data/docs/server.bat +1 -0
  84. data/docs/text_feature.rst +86 -0
  85. data/docs/units.rst +6 -0
  86. data/lib/squib.rb +4 -4
  87. data/lib/squib/api/background.rb +5 -10
  88. data/lib/squib/api/data.rb +30 -54
  89. data/lib/squib/api/groups.rb +47 -0
  90. data/lib/squib/api/image.rb +8 -67
  91. data/lib/squib/api/save.rb +15 -105
  92. data/lib/squib/api/settings.rb +8 -22
  93. data/lib/squib/api/shapes.rb +15 -185
  94. data/lib/squib/api/text.rb +9 -49
  95. data/lib/squib/api/text_embed.rb +12 -12
  96. data/lib/squib/api/units.rb +3 -17
  97. data/lib/squib/args/arg_loader.rb +6 -6
  98. data/lib/squib/args/box.rb +2 -2
  99. data/lib/squib/args/card_range.rb +1 -1
  100. data/lib/squib/args/color_validator.rb +2 -2
  101. data/lib/squib/args/coords.rb +2 -2
  102. data/lib/squib/args/csv_opts.rb +25 -0
  103. data/lib/squib/args/dir_validator.rb +1 -1
  104. data/lib/squib/args/draw.rb +2 -2
  105. data/lib/squib/args/embed_adjust.rb +1 -1
  106. data/lib/squib/args/embed_key.rb +1 -1
  107. data/lib/squib/args/hand_special.rb +37 -37
  108. data/lib/squib/args/import.rb +2 -2
  109. data/lib/squib/args/input_file.rb +1 -1
  110. data/lib/squib/args/paint.rb +3 -3
  111. data/lib/squib/args/paragraph.rb +2 -2
  112. data/lib/squib/args/save_batch.rb +2 -2
  113. data/lib/squib/args/scale_box.rb +1 -1
  114. data/lib/squib/args/sheet.rb +3 -3
  115. data/lib/squib/args/showcase_special.rb +2 -2
  116. data/lib/squib/args/svg_special.rb +1 -1
  117. data/lib/squib/args/transform.rb +2 -2
  118. data/lib/squib/args/typographer.rb +5 -4
  119. data/lib/squib/args/unit_conversion.rb +4 -4
  120. data/lib/squib/card.rb +8 -8
  121. data/lib/squib/conf.rb +5 -5
  122. data/lib/squib/deck.rb +20 -18
  123. data/lib/squib/graphics/cairo_context_wrapper.rb +3 -3
  124. data/lib/squib/graphics/gradient_regex.rb +1 -1
  125. data/lib/squib/graphics/hand.rb +2 -2
  126. data/lib/squib/graphics/save_doc.rb +9 -8
  127. data/lib/squib/graphics/save_images.rb +24 -11
  128. data/lib/squib/graphics/shapes.rb +16 -17
  129. data/lib/squib/graphics/showcase.rb +9 -9
  130. data/lib/squib/graphics/text.rb +21 -21
  131. data/lib/squib/layout_parser.rb +9 -9
  132. data/lib/squib/layouts/economy.yml +85 -85
  133. data/lib/squib/layouts/fantasy.yml +101 -101
  134. data/lib/squib/layouts/hand.yml +62 -62
  135. data/lib/squib/layouts/playing-card.yml +35 -35
  136. data/lib/squib/layouts/tuck_box.yml +45 -45
  137. data/lib/squib/sample_helpers.rb +1 -1
  138. data/lib/squib/version.rb +1 -1
  139. data/samples/{backend.rb → backend/_backend.rb} +2 -2
  140. data/samples/basic.rb +3 -3
  141. data/samples/bug134.rb +14 -0
  142. data/samples/build_groups/build_groups.rb +36 -0
  143. data/samples/cairo_access.rb +12 -1
  144. data/samples/{colors.rb → colors/_colors.rb} +12 -12
  145. data/samples/{gradients.rb → colors/_gradients.rb} +1 -1
  146. data/samples/config_text_markup.rb +2 -2
  147. data/samples/custom-config.yml +5 -5
  148. data/samples/custom_config.rb +18 -18
  149. data/samples/{csv_import.rb → data/_csv.rb} +8 -1
  150. data/samples/{excel.rb → data/_excel.rb} +3 -3
  151. data/samples/embed_text.rb +21 -0
  152. data/samples/hello_world.rb +1 -1
  153. data/samples/{load_images.rb → images/_more_load_images.rb} +2 -2
  154. data/samples/layouts.rb +11 -1
  155. data/samples/layouts_builtin.rb +51 -51
  156. data/samples/offset.svg +71 -71
  157. data/samples/ranges.rb +7 -7
  158. data/samples/{hand.rb → saves/_hand.rb} +1 -2
  159. data/samples/{portrait-landscape.rb → saves/_portrait_landscape.rb} +4 -4
  160. data/samples/{saves.rb → saves/_saves.rb} +0 -0
  161. data/samples/{showcase.rb → saves/_showcase.rb} +2 -2
  162. data/samples/{draw_shapes.rb → shapes/_draw_shapes.rb} +1 -1
  163. data/samples/text/_text.rb +4 -3
  164. data/samples/text_options.rb +6 -6
  165. data/samples/unicode.rb +1 -1
  166. data/spec/api/api_data_spec.rb +59 -4
  167. data/spec/api/api_settings_spec.rb +1 -1
  168. data/spec/args/box_spec.rb +7 -7
  169. data/spec/args/draw_spec.rb +19 -19
  170. data/spec/args/embed_key_spec.rb +13 -13
  171. data/spec/args/input_file_spec.rb +2 -2
  172. data/spec/args/paint_spec.rb +5 -5
  173. data/spec/args/paragraph_spec.rb +28 -28
  174. data/spec/args/range_spec.rb +1 -1
  175. data/spec/args/save_batch_spec.rb +10 -10
  176. data/spec/args/scale_box_spec.rb +9 -9
  177. data/spec/args/sheet_spec.rb +8 -8
  178. data/spec/args/showcase_special_spec.rb +15 -15
  179. data/spec/args/transform_spec.rb +4 -4
  180. data/spec/args/typographer_spec.rb +11 -11
  181. data/spec/args/unit_conversion_spec.rb +2 -2
  182. data/spec/card_spec.rb +1 -1
  183. data/spec/commands/new_spec.rb +1 -1
  184. data/spec/data/csv/custom_opts.csv +2 -0
  185. data/spec/data/csv/newline.csv +3 -0
  186. data/spec/data/csv/qty.csv +2 -2
  187. data/spec/data/csv/qty_named.csv +2 -2
  188. data/spec/data/csv/with_spaces.csv +2 -2
  189. data/spec/data/csv/yield.csv +3 -0
  190. data/spec/data/samples/{autoscale_font.rb.txt → autoscale_font/_autoscale_font.rb.txt} +55 -18
  191. data/spec/data/samples/cairo_access.rb.txt +24 -0
  192. data/spec/data/samples/{gradients.rb.txt → colors/_gradients.rb.txt} +0 -0
  193. data/spec/data/samples/config_text_markup.rb.txt +72 -72
  194. data/spec/data/samples/custom_config.rb.txt +1 -0
  195. data/spec/data/samples/{csv_import.rb.txt → data/_csv.rb.txt} +0 -0
  196. data/spec/data/samples/{excel.rb.txt → data/_excel.rb.txt} +0 -0
  197. data/spec/data/samples/embed_text.rb.txt +79 -0
  198. data/spec/data/samples/hello_world.rb.txt +36 -36
  199. data/spec/data/samples/{load_images.rb.txt → images/_more_load_images.rb.txt} +4 -4
  200. data/spec/data/samples/{hand.rb.txt → saves/_hand.rb.txt} +0 -0
  201. data/spec/data/samples/{portrait-landscape.rb.txt → saves/_portrait_landscape.rb.txt} +11 -7
  202. data/spec/data/samples/{save_pdf.rb.txt → saves/_save_pdf.rb.txt} +0 -0
  203. data/spec/data/samples/{saves.rb.txt → saves/_saves.rb.txt} +3 -4
  204. data/spec/data/samples/{showcase.rb.txt → saves/_showcase.rb.txt} +0 -0
  205. data/spec/data/samples/{draw_shapes.rb.txt → shapes/_draw_shapes.rb.txt} +0 -0
  206. data/spec/data/samples/text_options.rb.txt +1125 -1125
  207. data/spec/graphics/cairo_context_wrapper_spec.rb +10 -10
  208. data/spec/graphics/graphics_save_doc_spec.rb +11 -5
  209. data/spec/layout_parser_spec.rb +21 -9
  210. data/spec/logger_spec.rb +2 -2
  211. data/spec/samples/run_samples_spec.rb +1 -1
  212. data/spec/samples/samples_regression_spec.rb +16 -18
  213. data/spec/samples/sanity.rb +9 -9
  214. data/spec/sanity/.gitignore +1 -0
  215. data/spec/sanity/sanity.html.erb +42 -0
  216. data/spec/sanity/sanity_test.rb +42 -0
  217. data/spec/sanity/tests.yml +12 -0
  218. data/spec/spec_helper.rb +22 -20
  219. data/squib.gemspec +3 -4
  220. metadata +143 -81
  221. data/.rspec +0 -1
  222. data/.yardopts +0 -10
  223. data/samples/autoscale_font.rb +0 -27
  224. data/samples/backend-config.yml +0 -5
  225. data/samples/color_shortcuts.rb +0 -6
  226. data/samples/explode_quantities.xlsx +0 -0
  227. data/samples/quantity_explosion.csv +0 -3
  228. data/samples/sample.csv +0 -3
  229. data/samples/sample.xlsx +0 -0
  230. data/squib.sublime-project +0 -42
@@ -0,0 +1,152 @@
1
+ The Squib Way pt 2: Iconography
2
+ ===================================
3
+
4
+ .. warning::
5
+
6
+ This chapter is still being written
7
+
8
+ In the previous guide, we walked you through the basics of going from ideas in your head to a very simple set of cards ready for playtesting at the table. In this guide we take the next step: creating a visual language.
9
+
10
+ Art: Graphic Design vs. Illustration
11
+ ------------------------------------
12
+
13
+ A common piece of advice in the prototyping world is "Don't worry about artwork, just focus on the game and do the artwork later". That's good advice, but a bit over-simplified. What folks usually mean by "artwork" is really "illustration", like the oil painting of a wizard sitting in the middle of the card or the intricate border around the edges.
14
+
15
+ But games are more than just artwork with text - they're a system of rules that need to be efficiently conveyed to the players. They're a *visual language*. When players are new to your game, the layout of the cards need to facilitate learning. When players are competing in their 30th game, though, they need the cards to maximize usability by reducing their memory load, moving gameplay along efficiently, and provide an overall aesthetic that conveys the game theme. That's what graphic design is all about, and requires a game designer's attention much more than commissioning an illustration.
16
+
17
+ Developing the visual language on your cards is not a trivial task. It's one that takes a lot of iteration, feedback, testing, improvement, failure, small successes, and reverse-engineering. It's something you should consider in your prototype early on. It's also a series of decisions that don't necessarily require artistic ability - just an intentional effort applied to usability.
18
+
19
+ Icons and the their placement are, perhaps, the most efficient and powerful tools in your toolbelt for conveying your game's world. In the prototyping process, you don't need to be worried about using icons that are your *final* icons, but you should put some thought into what the visuals will look like because you'll be iterating on that in the design process.
20
+
21
+ Iconography in Popular Games
22
+ ----------------------------
23
+
24
+ When you get a chance, I highly recommend studying the iconography of some popular games. What works for you? What didn't? What kinds of choices did the designers make that works *for their game*? Here are a few that come my mind:
25
+
26
+ Race for the Galaxy
27
+ ^^^^^^^^^^^^^^^^^^^
28
+
29
+ The majority of the cards in RFTG have no description text on them, and yet the game contains hundreds of unique cards. RFTG has a vast, rich visual iconography that conveys a all of the bonuses and trade-offs of a card efficiently to the user. As a drawback, though, the visual language can be intimidating to new players - every little symbol and icon means a new thing, and sometimes you just need to memorize that "this card does that", until you realize that the icons show that.
30
+
31
+ But once you know the structure of the game and what various bonuses mean, you can understand new cards very easily. Icons are combined in creative ways to show new bonuses. Text is used only when a bonus is much more complicated than what can be expressed with icons. Icons are primarily arranged along left side of the card so you can hold them in your hand and compare bonuses across cards quickly. All of these design decisions match the gameplay nicely because the game consists of a lot of scrolling through cards in your hand and evaluating which ones you want to play.
32
+
33
+ Go check out images of Race for the Galaxy `on BoardGameGeek.com <https://boardgamegeek.com/boardgame/28143/race-galaxy>`_.
34
+
35
+ Dominion
36
+ ^^^^^^^^
37
+
38
+ Unlike RFTG, Dominion has a much simpler iconography. Most of the bonuses are conveyed in a paragraph of text in the description, with a few classifications conveyed by color or format. The text has icons embedded in it to tie in the concept of Gold, Curses, or Victory Points.
39
+
40
+ But Dominion's gameplay is much different: instead of going through tons of different cards, you're only playing with 10 piles of cards in front of you. So each game really just requires you to remember what 10 cards mean. Once you purchase a card and it goes into your deck, you don't need to evaluate its worth quickly as in RFTG because you already bought it. Having most of the game's bonuses in prose means that new bonuses are extremely flexible in their expression. As a result, Dominion's bonuses and iconography is much more about text and identifying known cards than about evaluating new ones.
41
+
42
+ Go check out images of Dominion `on BoardGameGeek.com <https://boardgamegeek.com/boardgame/36218/dominion>`_
43
+
44
+ How Squib Supports Iconography
45
+ ------------------------------
46
+
47
+ Squib is good for supporting any kind of layout you can think of, but it's also good for supporting multiple ways of translating your data into icons on cards. Here are some ways that Squib provides support for your ever-evolving iconography:
48
+
49
+ * :doc:`/dsl/svg` method, and all of its features like scaling, ID-specific rendering, direct XML manipulation, and all that the SVG file format has to offer
50
+ * :doc:`/dsl/png` method, and all of its features like blending operators, alpha transparency, and masking
51
+ * Layout files allow multiple icons for one data column (see :doc:`/layouts`)
52
+ * Layout files also have the ``extends`` feature that allows icons to inherit details from each other
53
+ * The ``range`` option on :doc:`/dsl/text`, :doc:`/dsl/svg`, and :doc:`/dsl/png` allows you to specify text and icons for any subset of your files
54
+ * The :doc:`/dsl/text` method allows for embedded icons.
55
+ * Ruby provides neat ways of aggregating data with ``inject``, ``map``, and ``zip`` that supports iconography
56
+
57
+ Back to the Example: Drones vs. Humans
58
+ --------------------------------------
59
+
60
+ Ok, let's go back to our running example, project ``arctic-lemming`` from Part 1. We created cards for playtesting, but we never put down the faction for each card. That's a good candidate for an icon.
61
+
62
+ Let's get some stock icons for this exercise. For this example, I went to http://game-icons.net. I set my foreground color to black, and background to white. I then downloaded "auto-repair.svg" and "backup.svg". I'm choosing not to rename the files so that I can find them again on the website if I need to. (If you want to know how to do this process DIRECTLY from Ruby, and not going to the website, check out my *other* Ruby gem called `game_icons <https://github.com/andymeneely/game_icons>`_ - it's tailor-made for Squib!)
63
+
64
+ When we were brainstorming our game, we placed one category of icons in a single column ("faction"). Presumably, one would want the faction icon to be in the same place on every card, but a different icon depending on the card's faction. There are a couple of ways of accomplishing this in Squib. First, here some less-than-clean ways of doing it::
65
+
66
+ svg range: 0, file: 'auto_repair.svg' # hard-coded range number? not flexible
67
+ svg range: 1, file: 'auto_repair.svg' # hard-coded range number? not flexible
68
+ svg range: 2, file: 'backup.svg' # hard-coded range number? not flexible
69
+ svg range: 3, file: 'backup.svg' # hard-coded range number? not flexible
70
+ # This gets very hard to maintain over time
71
+ svg file: ['auto_repair.svg', 'auto_repair.svg', 'backup.svg', 'backup.svg']
72
+ # This is slightly easier to maintain, but is more verbose and still hardcoded
73
+ svg range: 0..1, file 'auto_repair.svg'
74
+ svg range: 2..3, file 'backup.svg'
75
+
76
+ That's too much hardcoding of data into our Ruby code. That's what layouts are for. Now, we've already specified a layout file in our prior example. Fortunately, Squib supports *multiple* layout files, which get combined into a single set of layout styles. So let's do that: we create our own layout file that defines what a ``human`` is and what a ``drone`` is. Then just tell ``svg`` to use the layout data. The data column is simply an array of factions, the icon call is just connecting the factions to their styles with::
77
+
78
+ svg layout: data['faction']
79
+
80
+ So, putting it all together, our code looks like this.
81
+
82
+ .. raw:: html
83
+
84
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
85
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.4/gist-embed.min.js"></script>
86
+ <code data-gist-id="d2bb2eb028b27cf1dace"
87
+ data-gist-file="_part2_01_factions.rb"
88
+ data-gist-highlight-line="13"
89
+ ></code>
90
+ <code data-gist-id="d2bb2eb028b27cf1dace"
91
+ data-gist-file="_part2_01_factions.yml"></code>
92
+ <code data-gist-id="d2bb2eb028b27cf1dace" data-gist-file="data.csv"></code>
93
+ <code data-gist-id="d2bb2eb028b27cf1dace"
94
+ data-gist-file="_part2_01_factions_00.png"></code>
95
+
96
+ **BUT!** There's a very important software design principle we're violating here. It's called DRY: Don't Repeat Yourself. In making the above layout file, I hit copy and paste. What happens later when we change our mind and want to move the faction icon!?!? We have to change TWO numbers. Blech.
97
+
98
+ There's a better way: ``extends``
99
+
100
+ The layout files in Squib also support a special keyword, ``extends``, that allows us to "copy" (or "inherit") another style onto our own, and then we can override as we see fit. Thus, the following layout is a bit more DRY:
101
+
102
+ .. raw:: html
103
+
104
+ <code data-gist-id="d2bb2eb028b27cf1dace"
105
+ data-gist-file="_part2_02_factions.yml"></code>
106
+
107
+ Much better!
108
+
109
+ Now if we want to add a new faction, we don't have to copy-pasta any code! We just extend from faction and call in our new SVG file. Suppose we add a new faction that needs a bigger icon - we can define our own ``width`` and ``height`` beneath the ``extends`` that will override the parent values of 75.
110
+
111
+ Looks great! Now let's get these cards out to the playtesting table!
112
+
113
+ At this point, we've got a very scalable design for our future iterations. Let's take side-trip and discuss why this design works.
114
+
115
+ Why Ruby+YAML+Spreadsheets Works
116
+ --------------------------------
117
+
118
+ In software design, a "good" design is one where the problem is broken down into a set of easier duties that each make sense on their own, where the interaction between duties is easy, and where to place new responsbilities is obvious.
119
+
120
+ In Squib, we're using automation to assist the prototyping process. This means that we're going to have a bunch of decisions and responsibilities, such as:
121
+
122
+ * *Game data decisions*. How many of this card should be in the deck? What should this card be called? What should the cost of this card be?
123
+ * *Style Decisions*. Where should this icon be? How big should the font be? What color should we use?
124
+ * *Logic Decisions*. Can we build this to a PDF, too? How do we save this in black-and-white? Can we include a time stamp on each card? Can we just save one card this time so we can test quickly?
125
+
126
+ With the Ruby+YAML+Spreadsheets design, we've separated these three kinds of questions into three areas:
127
+
128
+ * Game data is in a spreadsheet
129
+ * Styles are in YAML layout files
130
+ * Code is in Ruby
131
+
132
+ When you work with this design, you'll probably find yourself spending a lot of time working on one of these files for a long time. That means this design is working.
133
+
134
+ For example, you might be adjusting the exact location of an image by editing your layout file and re-running your code over and over again to make sure you get the exact x-y coordinates right. That's fine. You're not making game data decisions in that moment, so you shouldn't be presented with any of that stuff. This eases the cognitive complexity of what you're doing.
135
+
136
+ The best way to preserve this design is to try to keep the Ruby code clean. As wonderful as Ruby is, it's the hardest of the three to edit. It is code, after all. So don't clutter it up with game data or style data - let it be the glue between your styles and your game.
137
+
138
+ Ok, let's get back to this prototype.
139
+
140
+ Icons for Some, But Not All, Cards
141
+ ----------------------------------
142
+
143
+ .. note::
144
+
145
+ to be written
146
+
147
+ One Column per Icon
148
+ -------------------
149
+
150
+ .. note::
151
+
152
+ to be written
@@ -0,0 +1,4 @@
1
+ The Squib Way pt 3: Workflows
2
+ ===============================
3
+
4
+ To be written.
@@ -0,0 +1,13 @@
1
+ Squib + Git
2
+ ===========
3
+
4
+ .. note::
5
+
6
+ To be written
7
+
8
+
9
+ Ideas:
10
+ * Workflow
11
+ * Tracking binary data (show json method)
12
+ * Snippet about "what's changed"
13
+ * Releases via tags and versioning
@@ -0,0 +1,6 @@
1
+ Hello, World!
2
+ =============
3
+
4
+ .. note::
5
+
6
+ Under construction
data/docs/help.rst ADDED
@@ -0,0 +1,157 @@
1
+ Get Help and Give Help
2
+ ======================
3
+
4
+ .. raw:: html
5
+
6
+ On BoardGameGeek.com? Show your Squib pride by <a href="https://boardgamegeek.com/microbadge/37841">getting the microbadge <img src="https://cdn.rawgit.com/andymeneely/squib/gh-pages/images/microbadge.png"></a> and <a href="https://boardgamegeek.com/guilds/2601">joining our guild!</a>
7
+
8
+ Get Help
9
+ --------
10
+
11
+ Squib is powerful and customizable, which means it can get complicated pretty quickly. Don't settle for being stuck.
12
+
13
+ Here's an ordered list of how to find help:
14
+
15
+ 1. Go through this documentation
16
+ 2. Go through `the wiki <https://github.com/andymeneely/squib/wiki>`_
17
+ 3. Go through `the samples <https://github.com/andymeneely/squib/tree/master/samples>`_
18
+ 4. Google it - people have asked lots of questions about Squib already in many forums.
19
+ 5. Ask on Stackoverflow `using the tags "ruby" and "squib" <http://stackoverflow.com/questions/ask?tags=ruby squib>`_. You will get answers quickly from Ruby programmers it's and a great way for us to archive questions for future Squibbers.
20
+ 6. Our `thread on BoardGameGeek <http://boardgamegeek.com/thread/1293453>`_ or `our guild <https://boardgamegeek.com/guild/2601>`_ is quite active and informal (if a bit unstructured).
21
+
22
+ If you email me directly I'll probably ask you to post your question publicly so we can document answers for future Googling Squibbers.
23
+
24
+ Please use GitHub issues for bugs and feature requests.
25
+
26
+ Help by Troubleshooting
27
+ -----------------------
28
+
29
+ One of the best ways you can help the Squib community is to be active on the above forums. Help people out. Answer questions. Share your code. Most of those forums have a "subscribe" feature.
30
+
31
+ You can also watch the project on GitHub, which means you get notified when new bugs and features are entered. Try reproducing code on your own machine to confirm a bug. Help write minimal test cases. Suggest workarounds.
32
+
33
+ Help by Beta Testing
34
+ --------------------
35
+
36
+ .. Testers needed!! If you want to test new features as I develop them, or make sure I didn't break your code, you can always point your Gemfile to the repository and follow what I'm doing there. Your Gemfile specification looks like this::
37
+ ..
38
+ .. gem 'squib', git: 'git://github.com/andymeneely/squib', branch: 'dev'
39
+ ..
40
+ .. * The ``dev`` branch is where I am working on features in-process. I have not done much regression testing at this point, but would love testing feedback nonetheless.
41
+ .. * The ``master`` branch is where I consider features and bug that are done and tested, but not released yet.
42
+
43
+ Squib is a small operation. And programming is hard. So we need testers! In particular, I could use help from people to do the following:
44
+
45
+ * Test out new features as I write them
46
+ * Watch for regression bugs by running their current projects on new Squib code, checking for compatibility issues.
47
+
48
+ Want to join the mailing list and get notifications? https://groups.google.com/forum/#!forum/squib-testers
49
+
50
+ There's no time commitment expectation associated with signing up. Any help you can give is appreciated!
51
+
52
+ Beta: Using Pre-Builds
53
+ ^^^^^^^^^^^^^^^^^^^^^^
54
+
55
+ The preferred way of doing beta testing is by to get Squib directly from my GitHub repository. Bundler makes this easy.
56
+
57
+ If you are just starting out you'll need to install bundler::
58
+
59
+ $ gem install bundler
60
+
61
+ Then, in the root of your Squib project, create a file called `Gemfile` (capitalization counts). Put this in it::
62
+
63
+ source 'https://rubygems.org'
64
+
65
+ gem 'squib', git: 'git://github.com/andymeneely/squib', branch: 'master'
66
+
67
+ Then run::
68
+
69
+ $ bundle install
70
+
71
+ Your output will look something like this::
72
+
73
+
74
+ Fetching git://github.com/andymeneely/squib
75
+ Fetching gem metadata from https://rubygems.org/.........
76
+ Fetching version metadata from https://rubygems.org/...
77
+ Fetching dependency metadata from https://rubygems.org/..
78
+ Resolving dependencies...
79
+ Using pkg-config 1.1.6
80
+ Using cairo 1.14.3
81
+ Using glib2 3.0.7
82
+ Using gdk_pixbuf2 3.0.7
83
+ Using mercenary 0.3.5
84
+ Using mini_portile2 2.0.0
85
+ Using nokogiri 1.6.7
86
+ Using pango 3.0.7
87
+ Using rubyzip 1.1.7
88
+ Using roo 2.3.0
89
+ Using rsvg2 3.0.7
90
+ Using ruby-progressbar 1.7.5
91
+ Using squib 0.9.0b from git://github.com/andymeneely/squib (at master)
92
+ Using bundler 1.10.6
93
+ Bundle complete! 1 Gemfile dependency, 14 gems now installed.
94
+ Use `bundle show [gemname]` to see where a bundled gem is installed.
95
+
96
+ To double-check that you're using the test version of Squib, puts this in your code::
97
+
98
+ require 'squib'
99
+ puts Squib::VERSION # prints the Squib version to the console when you run this code
100
+
101
+ # Rest of your Squib code...
102
+
103
+ When you run your code, say ``deck.rb``, you'll need to put ``bundle exec`` in front of it. Otherwise Ruby will just go with full releases (e.g. ``0.8`` instead of pre-releases, e.g. ``0.9a``). That would look like this::
104
+
105
+ $ bundle exec ruby deck.rb
106
+
107
+ If you need to know the exact commit of the build, you can see that commit hash in the generated ``Gemfile.lock``. That ``revision`` field will tell you the *exact* version you're using, which can be helpful for debugging. That will look something like this::
108
+
109
+ remote: git://github.com/andymeneely/squib
110
+ revision: 440a8628ed83b24987b9f6af66ad9a6e6032e781
111
+ branch: master
112
+
113
+ To update to the latest from the repository, run ``bundle up``.
114
+
115
+ To remove Squib versions, run ``gem cleanup squib``. This will also remove old Squib releases.
116
+
117
+ Beta: About versions
118
+ ^^^^^^^^^^^^^^^^^^^^
119
+
120
+ * When the version ends in "a" (e.g. ``v0.9a``), then the build is "alpha". I could be putting in new code all the time without bumping the version. I try to keep things as stable after every commit, but this is considered the least stable code. (Testing still appreciated here, though.) This is also tracked by my ``dev`` branch.
121
+ * For versions ending in "b" (e.g. ``v0.9b``), then the build is in "beta". Features are frozen until release, and we're just looking for bug fixes. This tends to be tracked by the ``master`` branch in my repository.
122
+ * I follow the `Semantic Versioning <http://semver.org>`_ as best I can
123
+
124
+ Beta: About Bundler+RubyGems
125
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126
+
127
+ The Gemfile is a configuration file (technically it's a Ruby DSL) for a widely-used library in the Ruby community called Bundler. Bundler is a way of managing multiple RubyGems at once, and specifying exactly what you want.
128
+
129
+ Bundler is different from RubyGems. Technically, you CAN use RubyGems without Bundler: just ``gem install`` what you need and your ``require`` statements will work. BUT Bundler helps you specify versions with the Gemfile, and where to get your gems. If you're switching between different versions of gems (like with being tester!), then Bundler is the way to go. The Bundler website is here: http://bundler.io/.
130
+
131
+ By convention, your ``Gemfile`` should be in the root directory of your project. If you did ``squib new``, there will be one created by default. Normally, a Squib project Gemfile will look `like this <https://github.com/andymeneely/squib/blob/master/lib/squib/project_template/Gemfile>`_. That configuration just pulls the Squib from RubyGems.
132
+
133
+ But, as a tester, you'll want to have Bundler install Squib from my repository. That would look like this: https://github.com/andymeneely/project-spider-monkey/blob/master/Gemfile. (Just line 4 - ignore the other stuff.) I tend to work with two main branches - dev and master. Master is more stable, dev is more bleeding edge. Problems in the master branch will be a surprise to me, problems in the dev branch probably won't surprise me.
134
+
135
+ After changing your Gemfile, you'll need to run ``bundle install``. That will generate a ``Gemfile.lock`` file - that's Bundler's way of saying exactly what it's planning on using. You don't modify the Gemfile.lock, but you can look at it to see what version of Squib it's locked onto.
136
+
137
+
138
+
139
+ Help by Fixing Bugs
140
+ -------------------
141
+
142
+ A great way to make yourself known in the community is to go over `our backlog <https://github.com/andymeneely/squib/issues>`_ and work on fixing bugs. Even suggestions on troubleshooting what's going on (e.g. trying it out on different OS versions) can be a big help.
143
+
144
+ Help by Contributing Code
145
+ -------------------------
146
+
147
+ Our biggest needs are in community support. But, if you happen to have some code to contribute, follow this process:
148
+
149
+ 1. Fork the git repository ( https://github.com/[my-github-username]/squib/fork )
150
+ 2. Create your feature branch (``git checkout -b my-new-feature``)
151
+ 3. Commit your changes (``git commit -am 'Add some feature'``)
152
+ 4. Push to the branch (``git push origin my-new-feature``)
153
+ 5. Create a new Pull Request
154
+
155
+ Be sure to write tests and samples for new features.
156
+
157
+ Be sure to run the unit tests and packaging with just ``rake``. Also, you can check that the samples render properly with ``rake sanity``.
data/docs/index.rst ADDED
@@ -0,0 +1,35 @@
1
+ Squib Documentation
2
+ ===================
3
+
4
+ Welcome to the official Squib documentation!
5
+
6
+ Contents:
7
+
8
+ .. toctree::
9
+ :maxdepth: 3
10
+
11
+ install
12
+ learning
13
+ parameters
14
+ arrays
15
+ layouts
16
+ data
17
+ units
18
+ colors
19
+ text_feature
20
+ bleed
21
+ config
22
+ backends
23
+ build_groups
24
+ help
25
+ dsl/index.rst
26
+
27
+ Indices and tables
28
+ ==================
29
+
30
+ * :ref:`genindex`
31
+ * :ref:`search`
32
+
33
+
34
+ .. meta::
35
+ :google-site-verification: BWelviUOeiImUuyxt54P6YinZcSuxHm8_aQidm9ju-U
data/docs/install.rst ADDED
@@ -0,0 +1,66 @@
1
+ Install & Update
2
+ ================
3
+
4
+ Squib is a Ruby gem, and installation is handled like most gems.
5
+
6
+ Pre-requisites
7
+ --------------
8
+
9
+ * `Ruby 2.1+ <https://www.ruby-lang.org>`_
10
+
11
+ Squib works with both x86 and x86_64 versions of Ruby.
12
+
13
+ Typical Install
14
+ ---------------
15
+
16
+ Regardless of your OS, installation is::
17
+
18
+ $ gem install squib
19
+
20
+ If you're using `Bundler <http://bundler.io>`_, add this line to your application's Gemfile::
21
+
22
+ gem 'squib'
23
+
24
+ And then execute::
25
+
26
+ $ bundle install
27
+
28
+ Squib has some native dependencies, such as `Cairo <https://github.com/rcairo/rcairo>`_, `Pango <http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout>`_, and `Nokogiri <http://nokogiri.org/>`_, which will compile upon installation - this is normal.
29
+
30
+ Updating Squib
31
+ --------------
32
+
33
+ At this time we consider Squib to be still in initial development, so we are not supporting older versions. Please upgrade your Squib as often as possible.
34
+
35
+ To keep track of when new Squib releases come out, you can watch the `BoardGameGeek thread <https://boardgamegeek.com/thread/1293453>`_ or follow the RSS feed for Squib on its `RubyGems page <https://rubygems.org/gems/squib>`_.
36
+
37
+ In RubyGems, the command looks like this::
38
+
39
+ $ gem up squib
40
+
41
+ As a quirk of Ruby/RubyGems, sometimes older versions of gems get caught in caches. You can see which versions of Squib are installed and clean them up, use ``gem list`` and ``gem cleanup``::
42
+
43
+ $ gem list squib
44
+
45
+ *** LOCAL GEMS ***
46
+
47
+ squib (0.9.0, 0.8.0)
48
+
49
+ $ gem cleanup squib
50
+ Cleaning up installed gems...
51
+ Attempting to uninstall squib-0.8.0
52
+ Successfully uninstalled squib-0.8.0
53
+ Clean Up Complete
54
+
55
+ This will remove all prior versions of Squib.
56
+
57
+ As a sanity check, you can see what version of Squib you're using by referencing the ``Squib::VERSION`` constant::
58
+
59
+ require 'squib'
60
+ puts Squib::VERSION
61
+
62
+
63
+ OS-Specific Quirks
64
+ ------------------
65
+
66
+ See the `wiki <http://github.com/andymeneely/squib/wiki>`_ for idiosyncracies about specific operating systems, dependency clashes, and other installation issues. If you've run into issues and solved them, please post your solutions for others!
data/docs/layouts.rst ADDED
@@ -0,0 +1,235 @@
1
+ Layouts are Squib's Best Feature
2
+ ================================
3
+
4
+ Working with tons of options to a method can be tiresome. Ideally everything in a game prototype should be data-driven, easily changed, and your Ruby code should readable without being littered with `magic numbers <http://stackoverflow.com/questions/47882/what-is-a-magic-number-and-why-is-it-bad>`_.
5
+
6
+ For this, most Squib methods have a ``layout`` option. Layouts are a way of setting default values for any parameter given to the method. They let you group things logically, manipulate options, and use built-in stylings.
7
+
8
+ Think of layouts and DSL calls like CSS and HTML: you can always specify style in your logic (e.g. directly in an HTML tag), but a cleaner approach is to group your styles together in a separate sheet and work on them separately.
9
+
10
+ To use a layout, set the ``layout:`` option on ``Deck.new`` to point to a YAML file. Any command that allows a ``layout`` option can be set with a Ruby symbol or string, and the command will then load the specified options. The individual command can also override these options.
11
+
12
+ For example, instead of this::
13
+
14
+ # deck.rb
15
+ Squib::Deck.new do
16
+ rect x: 75, y: 75, width: 675, height: 975
17
+ end
18
+
19
+ You can put your logic in the layout file and reference them::
20
+
21
+ # custom-layout.yml
22
+ bleed:
23
+ x: 75
24
+ y: 75
25
+ width: 975
26
+ height: 675
27
+
28
+ Then your script looks like this::
29
+
30
+ # deck.rb
31
+ Squib::Deck.new(layout: 'custom-layout.yml') do
32
+ rect layout: 'bleed'
33
+ end
34
+
35
+ The goal is to make your Ruby code separate the data decisions from logic. For the above example, you are separating the decision to draw rectangle around the "bleed" area, and then your YAML file is defining specifically what "bleed" actually means. (Who is going to remember that ``x: 75`` means "bleed area"??) This process of separating logic from data makes your code more readable, changeable, and maintainable.
36
+
37
+ .. warning::
38
+
39
+ YAML is very finnicky about not allowing tab characters. Use two spaces for indentation instead. If you get a ``Psych`` syntax error, this is likely the culprit. Indendation is also strongly enforced in Yaml too. See the `Yaml docs <http://www.yaml.org/YAML_for_ruby.html>`_ for more info.
40
+
41
+ Order of Precedence for Options
42
+ -------------------------------
43
+
44
+ Layouts will override Squib's system defaults, but are overriden by anything specified in the command itself. Thus, the order of precedence looks like this:
45
+
46
+ 1. Use what the DSL method specified, e.g. ``rect x: 25``
47
+ 2. If anything was not yet specified, use what was given in a layout (if a layout was specified in the command and the file was given to the Deck). e.g. ``rect layout: :bleed``
48
+ 3. If still anything was not yet specified, use what was given in Squib's defaults as defined in the :doc:`dsl/index`.
49
+
50
+ For example, back to our example::
51
+
52
+ # custom-layout.yml
53
+ bleed:
54
+ x: 0.25in
55
+ y: 0.25in
56
+ width: 2.5in
57
+ height: 3.5in
58
+
59
+ (Note that this example makes use of :doc:`/units`)
60
+
61
+ Combined with this script:
62
+
63
+ .. code-block:: ruby
64
+
65
+ # deck.rb
66
+ Squib::Deck.new(layout: 'custom-layout.yml') do
67
+ rect layout: 'bleed', x: 50
68
+ end
69
+
70
+ The options that go into ``rect`` will be:
71
+
72
+ * ``x`` will be 50 because it's specified in the DSL method and overrides the layout
73
+ * ``y``, ``width``, and ``height`` were specified in the layout file, so their values are used
74
+ * The rect's ``stroke_color`` (and others options like it) was never specified anywhere, so the default for ``rect`` is used - as discussed in :doc:`parameters`.
75
+
76
+ .. note::
77
+
78
+ Defaults are not global for the name of the option - they are specific to the method itself. For example, the default ``fill_color`` for ``rect`` is ``'#0000'`` but for ``showcase`` it's ``:white``.
79
+
80
+ .. note::
81
+
82
+ Layouts work with *all* options (for DSL methods that support layouts), so you can use options like ``file`` or ``font`` or whatever is needed.
83
+
84
+ .. warning::
85
+
86
+ If you provide an option in the Yaml file that is not supported by the DSL method, the DSL method will simply ignore it. Same behavior as described in :doc:`parameters`.
87
+
88
+
89
+ When Layouts Are Similar, Use ``extends``
90
+ -----------------------------------------
91
+
92
+ Using layouts are a great way of keeping your Ruby code clean and concise. But those layout Yaml files can get pretty long. If you have a bunch of icons along the top of a card, for example, you're specifying the same ``y`` option over and over again. This is annoyingly verbose, and what if you want to move all those icons downward at once?
93
+
94
+ Squib provides a way of reusing layouts with the special `extends`` key. When defining an ```extends`` key, we can merge in another key and modify its data coming in if we want to. This allows us to do things like place text next to an icon and be able to move them with each other. Like this::
95
+
96
+ # If we change attack, we move defend too!
97
+ attack:
98
+ x: 100
99
+ y: 100
100
+ defend:
101
+ extends: attack
102
+ x: 150
103
+ #defend now is {:x => 150, :y => 100}
104
+
105
+ Over time, using ``extends`` saves you a lot of space in your Yaml files while also giving more structure and readability to the file itself.
106
+
107
+ You can also **modify** data as they get passed through extends::
108
+
109
+ # If we change attack, we move defend too!
110
+ attack:
111
+ x: 100
112
+ defend:
113
+ extends: attack
114
+ x: += 50
115
+ #defend now is {:x => 150, :y => 100}
116
+
117
+ The following operators are supported within evaluating ``extends``
118
+ * ``+=`` will add the giuven number to the inherited number
119
+ * ``-=`` will subtract the given number from the inherited number
120
+
121
+ Both operators also support :doc:`/units`
122
+
123
+ From a design point of view, you can also extract out a base design and have your other layouts extend from them::
124
+
125
+ top_icons:
126
+ y: 100
127
+ font: Arial 36
128
+ attack:
129
+ extends: top_icon
130
+ x: 25
131
+ defend:
132
+ extends: top_icon
133
+ x: 50
134
+ health:
135
+ extends: top_icon
136
+ x: 75
137
+ # ...and so on
138
+
139
+ .. note::
140
+
141
+ Those fluent in Yaml may notice that ``extends`` key is similar to Yaml's `merge keys <http://www.yaml.org/YAML_for_ruby.html#merge_key>`_. Technically, you can use these together - but I just recommend sticking with ``extends`` since it does what merge keys do *and more*. If you do choose to use both ``extends`` and Yaml merge keys, the Yaml merge keys are processed first (upon Yaml parsing), then ``extends`` (after parsing).
142
+
143
+ Yes, ``extends`` is Multi-Generational
144
+ --------------------------------------
145
+
146
+ As you might expect, ``extends`` can be composed multiple times::
147
+
148
+ socrates:
149
+ x: 100
150
+ plato:
151
+ extends: socrates
152
+ x: += 10 # evaluates to 150
153
+ aristotle:
154
+ extends: plato
155
+ x: += 20 # evaluates to 150
156
+
157
+ Yes, ``extends`` has Multiple Inheritance
158
+ -----------------------------------------
159
+
160
+ If you want to extend multiple parents, it looks like this::
161
+
162
+ socrates:
163
+ x: 100
164
+ plato:
165
+ y: 200
166
+ aristotle:
167
+ extends:
168
+ - socrates
169
+ - plato
170
+ x: += 50 # evaluates to 150
171
+
172
+ If multiple keys override the same keys in a parent, the later ("younger") child in the ``extends`` list takes precedent. Like this::
173
+
174
+ socrates:
175
+ x: 100
176
+ plato:
177
+ x: 200
178
+ aristotle:
179
+ extends:
180
+ - plato # note the order here
181
+ - socrates
182
+ x: += 50 # evaluates to 150 from socrates
183
+
184
+
185
+ Multiple Layout Files get Merged
186
+ --------------------------------
187
+
188
+ Squib also supports the combination of multiple layout files. If you provide an ``Array`` of files then Squib will merge them sequentially. Colliding keys will be completely re-defined by the later file. The ``extends`` key is processed after *each file*, but can be used across files. Here's an example::
189
+
190
+ # load order: a.yml, b.yml
191
+
192
+ ##############
193
+ # file a.yml #
194
+ ##############
195
+ grandparent:
196
+ x: 100
197
+ parent_a:
198
+ extends: grandparent
199
+ x: += 10 # evaluates to 110
200
+ parent_b:
201
+ extends: grandparent
202
+ x: += 20 # evaluates to 120
203
+
204
+ ##############
205
+ # file b.yml #
206
+ ##############
207
+ child_a:
208
+ extends: parent_a # i.e. extends a layout in a separate file
209
+ x: += 3 # evaluates to 113 (i.e 110 + 3)
210
+ parent_b: # redefined
211
+ extends: grandparent
212
+ x: += 30 # evaluates to 130 (i.e. 100 + 30)
213
+ child_b:
214
+ extends: parent_b
215
+ x: += 3 # evaluates to 133 (i.e. 130 + 3)
216
+
217
+ This can be helpful for:
218
+ * Creating a base layout for structure, and one for full color for easier color/black-and-white switching
219
+ * Sharing base layouts with other designers
220
+
221
+ Squib Comes with Built-In Layouts
222
+ ---------------------------------
223
+
224
+ 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.
225
+
226
+ 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>`_.
227
+
228
+ Contributions in this area are particularly welcome!!
229
+
230
+ See Layouts in Action
231
+ ---------------------
232
+
233
+ `This sample <https://github.com/andymeneely/squib/tree/master/samples/>`_ demonstrates many different ways of using and combining layouts.
234
+
235
+ `This sample <https://github.com/andymeneely/squib/tree/master/samples/>`_ demonstrates built-in layouts based on popular games (e.g. ``fantasy.yml`` and ``economy.yml``)