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,3 @@
1
+ .. :orphan:
2
+
3
+ All of these options support arrays and singleton expansion (except for **range**). See :doc:`/arrays` for deeper explanation.
@@ -0,0 +1,6 @@
1
+ .. :orphan:
2
+
3
+ layout
4
+ default: ``nil``
5
+
6
+ entry in the layout to use as defaults for this command. See :doc:`/layouts`.
@@ -0,0 +1,6 @@
1
+ .. :orphan:
2
+
3
+ dir
4
+ default: ``_output``
5
+
6
+ The directory for the output to be sent to. Will be created if it doesn't exist. Relative to the current directory.
@@ -0,0 +1,6 @@
1
+ .. :orphan:
2
+
3
+ range
4
+ default: ``:all``
5
+
6
+ the range of cards over which this will be rendered. See :ref:`using_ranges`
@@ -0,0 +1,51 @@
1
+ .. :orphan:
2
+
3
+ angle
4
+ default: ``0``
5
+
6
+ Rotation of the in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky.
7
+
8
+ crop_x
9
+ default: ``0``
10
+
11
+ Crop the loaded image at this x coordinate. Supports :doc:`/units`.
12
+
13
+ crop_y
14
+ default: ``0``
15
+
16
+ Crop the loaded image at this y coordinate. Supports :doc:`/units`.
17
+
18
+ crop_corner_radius
19
+ default: ``0``
20
+
21
+ Radius for rounded corners, both x and y. When set, overrides crop_corner_x_radius and crop_corner_y_radius. Supports :doc:`/units`.
22
+
23
+ crop_corner_x_radius
24
+ default: ``0``
25
+
26
+ x radius for rounded corners of cropped image. Supports :doc:`/units`.
27
+
28
+ crop_corner_y_radius
29
+ default: ``0``
30
+
31
+ y radius for rounded corners of cropped image. Supports :doc:`/units`.
32
+
33
+ crop_width
34
+ default: ``:native``
35
+
36
+ Width of the cropped image. Supports :doc:`/units`.
37
+
38
+ crop_height
39
+ default: ``:native``
40
+
41
+ Height of the cropped image. Supports :doc:`/units`.
42
+
43
+ flip_horiztonal
44
+ default: ``false``
45
+
46
+ Flip this image about its center horizontally (i.e. left becomes right and vice versa).
47
+
48
+ flip_vertical
49
+ default: ``false``
50
+
51
+ Flip this image about its center verticall (i.e. top becomes bottom and vice versa).
@@ -0,0 +1,11 @@
1
+ .. :orphan:
2
+
3
+ trim
4
+ default: ``0``
5
+
6
+ the margin around the card to trim before putting into the image
7
+
8
+ trim_radius
9
+ default: ``0``
10
+
11
+ the rounded rectangle radius around the card to trim before putting into the image
data/docs/args/wh.rst ADDED
@@ -0,0 +1,12 @@
1
+ .. :orphan:
2
+
3
+ width
4
+ default: ``:deck`` (the width of the deck)
5
+
6
+ the width of the box. Supports :doc:`/units`.
7
+
8
+
9
+ height
10
+ default: ``:deck`` (the height of the deck)
11
+
12
+ the height of the box. Supports :doc:`/units`.
data/docs/args/xy.rst ADDED
@@ -0,0 +1,12 @@
1
+ .. :orphan:
2
+
3
+ x
4
+ default: ``0``
5
+
6
+ the x-coordinate to place, relative to the upper-left corner of the card and moving right as it increases. Supports :doc:`/units`.
7
+
8
+
9
+ y
10
+ default: ``0``
11
+
12
+ the y-coordinate to place, relative to the upper-left corner of the card and moving downward as it increases. Supports :doc:`/units`.
data/docs/arrays.rst ADDED
@@ -0,0 +1,77 @@
1
+ Squib Thinks in Arrays
2
+ ======================
3
+
4
+ When prototyping card games, you usually want some things (e.g. icons, text) to remain the same across every card, but then other things need to change per card. Maybe you want the same background for every card, but a different title.
5
+
6
+ The vast majority of Squib's DSL methods can accept two kinds of input: whatever it's expecting, or an array of whatever it's expecting. If it's an array, then Squib expects each element of the array to correspond to a different card.
7
+
8
+ Think of this like "singleton expansion", where Squib goes "Is this an array? No? Then just repeat it the same across every card". Thus, these two DSL calls are logically equivalent::
9
+
10
+ Squib::Deck.new(cards: 2) do
11
+ text str: 'Hello'
12
+ text str: ['Hello', 'Hello'] # same effect
13
+ end
14
+
15
+ But then to use a different string on each card you can do::
16
+
17
+ Squib::Deck.new(cards: 2) do
18
+ text str: ['Hello', 'World']
19
+ end
20
+
21
+ .. note::
22
+
23
+ Technically, Squib is only looking for something that responds to ``each`` (i.e. an Enumerable). So whatever you give it should just respond to ``each`` and it will work as expected.
24
+
25
+ What if you have an array that doesn't match the size of the deck? No problem - Ruby won't complain about indexing an array out of bounds - it simply returns ``nil``. So these are equivalent::
26
+
27
+ Squib::Deck.new(cards: 3) do
28
+ text str: ['Hello', 'Hello']
29
+ text str: ['Hello', 'Hello', nil] # same effect
30
+ end
31
+
32
+ In the case of the :doc:`/dsl/text` method, giving it an ``str: nil`` will mean the method won't do anything for that card and move on. Different methods react differently to getting ``nil`` as an option, however, so watch out for that.
33
+
34
+
35
+ .. _using_ranges:
36
+
37
+ Using ``range`` to specify cards
38
+ --------------------------------
39
+
40
+ There's another way to limit a DSL method to certain cards: the ``range`` parameter.
41
+
42
+ Most of Squib's DSL methods allow a ``range`` to be specified. This can be an actual Ruby ``Range``, or anything that implements ``each`` (i.e. an Enumerable) that corresponds to the **index** of each card.
43
+
44
+ Integers are also supported for changing one card only. Negatives work from the back of the deck.
45
+
46
+ Some quick examples::
47
+
48
+ text range: 0..2 # only cards 0, 1, and 2
49
+ text range: [0,2] # only cards 0 and 2
50
+ text range: 0 # only card 0
51
+
52
+ Behold! The Power of Ruby Arrays
53
+ --------------------------------
54
+
55
+ One of the more distinctive benefits of Ruby is in its rich set of features for manipulating and accessing arrays. Between ``range`` and using arrays, you can specify subsets of cards quite succinctly. The following methods in Ruby are particularly helpful:
56
+
57
+ * `Array#each <http://ruby-doc.org/core-2.2.0/Array.html#method-i-each>`_ - do something on each element of the array (Ruby folks seldom use for-loops!)
58
+ * `Array#map <http://ruby-doc.org/core-2.2.0/Array.html#method-i-map>`_ - do something on each element of an array and put it into a new array
59
+ * `Array#select <http://ruby-doc.org/core-2.2.0/Array.html#method-i-select>`_ - select a subset of an array
60
+ * `Enumerable#each_with_index <http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-each_with_index>`_ - do something to each element, also being aware of the index
61
+ * `Enumerable#inject <http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-inject>`_ - accumulate elements of an array in a custom way
62
+ * `Array#zip <http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-zip>`_ - combine two arrays, element by element
63
+
64
+ Examples
65
+ --------
66
+
67
+ Here are a few recipes for using arrays and ranges in practice:
68
+
69
+ .. raw:: HTML
70
+
71
+ <script src="https://gist.github.com/andymeneely/25b0da2a84ab906bd44b.js"></script>
72
+
73
+
74
+ Contribute Recipes!
75
+ -------------------
76
+
77
+ There are a lot more great recipes we could come up with. Feel free to contribute! You can add them here via pull request or `via the wiki <https://github.com/andymeneely/squib/wiki>`_
data/docs/backends.rst ADDED
@@ -0,0 +1,20 @@
1
+ Vector vs. Raster Backends
2
+ ==========================
3
+
4
+ Squib's graphics rendering engine, Cairo, has the ability to support a variety of surfaces to draw on, including both raster images stored in memory and vectors stored in SVG files. Thus, Squib supports the ability to handle both. They are options in the configuration file ``backend: memory`` or ``backend: svg`` described in :doc:`/config`.
5
+
6
+ If you use :doc:`/dsl/save_pdf` then this backend option will determine how your cards are saved too. For `memory`, the PDF will be filled with compressed raster images and be a larger file (yet it will still print at high quality... see discussion below). For SVG backends, PDFs will be smaller. If you have your deck backed by SVG, then the cards are auto-saved, so there is no ``save_svg`` in Squib. (Technically, the operations are stored and then flushed to the SVG file at the very end.)
7
+
8
+ There are trade-offs to consider here.
9
+
10
+ * Print quality is **usually higher** for raster images. This seems counterintuitive at first, but consider where Squib sits in your workflow. It's the final assembly line for your cards before they get printed. Cairo puts *a ton* of work into rendering each pixel perfectly when it works with raster images. Printers, on the other hand, don't think in vectors and will render your paths in their own memory with their own embedded libraries without putting a lot of work into antialiasing and various other graphical esoterica. You may notice that print-on-demand companies such as The Game Crafter `only accept raster file types <http://help.thegamecrafter.com/article/38-supported-file-types>`_, because they don't want their customers complaining about their printers not rendering vectors with enough care.
11
+ * Print quality is **sometimes higher** for vector images, particularly in laser printers. We have noticed this on a few printers, so it's worth testing out.
12
+ * PDFs are **smaller** for SVG back ends. If file size is a limitation for you, and it can be for some printers or internet forums, then an SVG back end for vectorized PDFs is the way to go.
13
+ * Squib is **greedy** with memory. While I've tested Squib with big decks on older computers, the `memory` backend is quite greedy with RAM. If memory is at a premium for you, switching to SVG might help.
14
+ * Squib does **not support every feature** with SVG back ends. There are some nasty corner cases here. If it doesn't, please file an issue so we can look into it. Not every feature in Cairo perfectly translates to SVG.
15
+
16
+ .. note::
17
+
18
+ You can still load PNGs into an SVG-backed deck and load SVGs into a memory-backed deck. To me, the sweet spot is to keep all of my icons, text, and other stuff in vector form for infinite scaling and then render them all to pixels with Squib.
19
+
20
+ Fortunately, switching backends in Squib is as trivial as changing the setting in the config file (see :doc:`/config`). So go ahead and experiment with both and see what works for you.
data/docs/bleed.rst ADDED
@@ -0,0 +1,13 @@
1
+ Always Have Bleed
2
+ =================
3
+
4
+ .. note::
5
+
6
+ TODO: Under construction
7
+
8
+ * Always plan to have a printing bleed around the edge of your cards. 1/8 in is standard
9
+ * Have a safe zone too
10
+ * Layouts make this easy (see the built-in layouts)
11
+ * Can use png overlays from templates to make sure it fits
12
+ * Trim option is what is used everywhere in Squib
13
+ * Trim_radius also lets you show your cards off like how they'll really look
@@ -0,0 +1,47 @@
1
+ Group Your Builds
2
+ =================
3
+
4
+ Often in the prototyping process you'll find yourself cycling between running your overall build and building a single card. You'll probably be commenting out code in the process.
5
+
6
+ And even after your code is stable, you'll probably want to build your deck multiple ways: maybe a printer-friendly black-and-white version for print-and-play and then a full color version.
7
+
8
+ Squib's Build Groups help you with these situations. By grouping your Squib code into different groups, you can run parts of it at a time without having to go back and commenting out code.
9
+
10
+ Here's a basic example:
11
+
12
+ .. raw:: html
13
+
14
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
15
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.4/gist-embed.min.js"></script>
16
+ <code data-gist-id="bda48487e3b8c9d15edb" data-gist-file="build_groups.rb"></code>
17
+
18
+ Only one group is enabled by default: ``:all``. All other groups are disabled by default. To see which groups are enabled currently, the :doc:`/dsl/groups` returns the set.
19
+
20
+ Groups can be enabled and disabled in several ways:
21
+
22
+ * The :doc:`/dsl/enable_group` and :doc:`/dsl/disable_group` DSL methods can explicitly enable/disable a group. Again, you're back to commenting out the *enable_group* call, but that's easier than remembering what lines to comment out each time.
23
+ * When a ``Squib::Deck`` is initialized, the `environment variable <https://en.wikipedia.org/wiki/Environment_variable>`_ ``SQUIB_BUILD`` is consulted for a comma-separated string. These are converted to Ruby symbols and the corresponding groups are enabled.
24
+
25
+ Note that the environment variables are intended to change from run to run, from the command line (see above gist for examples in various OS's).
26
+
27
+ .. note::
28
+
29
+ There should be no need to set the SQUIB_BUILD variable globally on your system.
30
+
31
+ Don't like how Windows specifies environment variables? One adaptation of this is to do the environment setting in a ``Rakefile``. Rake is the build utility that comes with Ruby, and it allows us to set different tasks exactly in this way. This Rakefile works nicely with our above code example:
32
+
33
+
34
+ .. raw:: html
35
+
36
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
37
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.4/gist-embed.min.js"></script>
38
+ <code data-gist-id="bda48487e3b8c9d15edb" data-gist-file="Rakefile"></code>
39
+
40
+
41
+ Thus, you can just run this code with commands like these::
42
+
43
+ $ rake
44
+ $ rake pnp
45
+ $ rake color
46
+ $ rake test
47
+ $ rake both
data/docs/colors.rst ADDED
@@ -0,0 +1,64 @@
1
+ Specifying Colors & Gradients
2
+ =============================
3
+
4
+ Colors
5
+ ------
6
+
7
+ by hex-string
8
+ ^^^^^^^^^^^^^
9
+
10
+ You can specify a color via the standard hexadecimal string for RGB (as in HTML and CSS). You also have a few other options as well. You can use:
11
+
12
+ * 12-bit (3 hex numbers), RGB. e.g. ``'#f08'``
13
+ * 24-bit (6 hex numbers), RRGGBB. e.g. ``'#ff0088'``
14
+ * 48-bit (9 hex numbers), RRRGGGBBB. e.g. ``'#fff000888'``
15
+
16
+
17
+ Additionally, you can specify the alpha (i.e. transparency) of the color as RGBA. An alpha of ``0`` is full transparent, and ``f`` is fully opaque. Thus, you can also use:
18
+
19
+ * 12-bit (4 hex numbers), RGBA. e.g. ``'#f085'``
20
+ * 24-bit (8 hex numbers), RRGGBBAA. e.g. ``'#ff008855'``
21
+ * 48-bit (12 hex numbers), RRRGGGBBBAAA. e.g. ``'#fff000888555'``
22
+
23
+ The ``#`` at the beginning is optional, but encouraged for readability. In layout files (described in :doc:`/layouts`), the ``#`` character will initiate a comment in Yaml. So to specify a color in a layout file, just quote it::
24
+
25
+ # this is a comment in yaml
26
+ attack:
27
+ fill_color: '#fff'
28
+
29
+
30
+ by name
31
+ ^^^^^^^
32
+
33
+ Under the hood, Squib uses the rcairo `color parser <https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb>`_ to accept around 300 named colors. The full list can be found `here <https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb>`_.
34
+
35
+ Names of colors can be either strings or symbols, and case does not matter. Multiple words are separated by underscores. For example, ``'white'``, ``:burnt_orange``, or ``'ALIZARIN_CRIMSON'`` are all acceptable names.
36
+
37
+ by custom name
38
+ ^^^^^^^^^^^^^^
39
+
40
+ In your ``config.yml``, as described in :doc:`/config`, you can specify custom names of colors. For example, ``'foreground'``.
41
+
42
+ Gradients
43
+ --------
44
+
45
+ In most places where colors are allowed, you may also supply a string that defines a gradient. Squib supports two flavors of gradients: linear and radial. Gradients are specified by supplying some xy coordinates, which are relative to the card (not the command). Each stop must be between ``0.0`` and ``1.0``, and you can supply as many as you like. Colors can be specified as above (in any of the hex notations or built-in constant). If you add two or more colors at the same stop, then the gradient keeps the colors in the in order specified and treats it like sharp transition.
46
+
47
+ The format for linear gradient strings look like this::
48
+
49
+ '(x1,y1)(x2,y2) color1@stop1 color2@stop2'
50
+
51
+ The xy coordinates define the angle of the gradient.
52
+
53
+ The format for radial gradients look like this::
54
+
55
+ '(x1,y1,radius1)(x2,y2,radius2) color1@stop1 color2@stop2'
56
+
57
+ The coordinates specify an inner circle first, then an outer circle.
58
+
59
+ In both of these formats, whitespace is ignored between tokens so as to make complex gradients more readable.
60
+
61
+ If you need something more powerful than these two types of gradients (e.g. mesh gradients), then we suggest encapsulating your logic within an SVG and using the :doc:`/dsl/svg` method to render it.
62
+
63
+ Examples
64
+ --------
data/docs/conf.py ADDED
@@ -0,0 +1,287 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Squib documentation build configuration file, created by
4
+ # sphinx-quickstart on Sat Jan 23 21:56:41 2016.
5
+ #
6
+ # This file is execfile()d with the current directory set to its
7
+ # containing dir.
8
+ #
9
+ # Note that not all possible configuration values are present in this
10
+ # autogenerated file.
11
+ #
12
+ # All configuration values have a default; values that are commented out
13
+ # serve to show the default.
14
+
15
+ import sys
16
+ import os
17
+ import sphinx_rtd_theme
18
+
19
+ # If extensions (or modules to document with autodoc) are in another directory,
20
+ # add these directories to sys.path here. If the directory is relative to the
21
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
22
+ #sys.path.insert(0, os.path.abspath('.'))
23
+
24
+ # -- General configuration ------------------------------------------------
25
+
26
+ # If your documentation needs a minimal Sphinx version, state it here.
27
+ #needs_sphinx = '1.0'
28
+
29
+ # Add any Sphinx extension module names here, as strings. They can be
30
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
31
+ # ones.
32
+ extensions = []
33
+
34
+ # Add any paths that contain templates here, relative to this directory.
35
+ templates_path = ['_templates']
36
+
37
+ # The suffix(es) of source filenames.
38
+ # You can specify multiple suffix as a list of string:
39
+ # source_suffix = ['.rst', '.md']
40
+ source_suffix = '.rst'
41
+
42
+ # The encoding of source files.
43
+ #source_encoding = 'utf-8-sig'
44
+
45
+ # The master toctree document.
46
+ master_doc = 'index'
47
+
48
+ # General information about the project.
49
+ project = u'Squib'
50
+ copyright = u'MIT License'
51
+ author = u'Andy Meneely'
52
+
53
+ # The version info for the project you're documenting, acts as replacement for
54
+ # |version| and |release|, also used in various other places throughout the
55
+ # built documents.
56
+ #
57
+ # The short X.Y version.
58
+ version = u'0.9.0'
59
+ # The full version, including alpha/beta/rc tags.
60
+ release = u'0.9.0'
61
+
62
+ # The language for content autogenerated by Sphinx. Refer to documentation
63
+ # for a list of supported languages.
64
+ #
65
+ # This is also used if you do content translation via gettext catalogs.
66
+ # Usually you set "language" from the command line for these cases.
67
+ language = None
68
+
69
+ # There are two options for replacing |today|: either, you set today to some
70
+ # non-false value, then it is used:
71
+ #today = ''
72
+ # Else, today_fmt is used as the format for a strftime call.
73
+ #today_fmt = '%B %d, %Y'
74
+
75
+ # List of patterns, relative to source directory, that match files and
76
+ # directories to ignore when looking for source files.
77
+ exclude_patterns = ['_build']
78
+
79
+ # The reST default role (used for this markup: `text`) to use for all
80
+ # documents.
81
+ #default_role = None
82
+
83
+ # If true, '()' will be appended to :func: etc. cross-reference text.
84
+ #add_function_parentheses = True
85
+
86
+ # If true, the current module name will be prepended to all description
87
+ # unit titles (such as .. function::).
88
+ #add_module_names = True
89
+
90
+ # If true, sectionauthor and moduleauthor directives will be shown in the
91
+ # output. They are ignored by default.
92
+ #show_authors = False
93
+
94
+ # The name of the Pygments (syntax highlighting) style to use.
95
+ pygments_style = 'sphinx'
96
+ highlight_language = 'ruby'
97
+
98
+ # A list of ignored prefixes for module index sorting.
99
+ #modindex_common_prefix = []
100
+
101
+ # If true, keep warnings as "system message" paragraphs in the built documents.
102
+ #keep_warnings = False
103
+
104
+ # If true, `todo` and `todoList` produce output, else they produce nothing.
105
+ todo_include_todos = False
106
+
107
+
108
+ # -- Options for HTML output ----------------------------------------------
109
+
110
+ # The theme to use for HTML and HTML Help pages. See the documentation for
111
+ # a list of builtin themes.
112
+ html_theme = 'sphinx_rtd_theme' # https://github.com/snide/sphinx_rtd_theme
113
+ html_style = 'css/squibdocs.css'
114
+
115
+ # Theme options are theme-specific and customize the look and feel of a theme
116
+ # further. For a list of options available for each theme, see the
117
+ # documentation.
118
+ #html_theme_options = {}
119
+
120
+ # Add any paths that contain custom themes here, relative to this directory.
121
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
122
+
123
+ # The name for this set of Sphinx documents. If None, it defaults to
124
+ # "<project> v<release> documentation".
125
+ #html_title = None
126
+
127
+ # A shorter title for the navigation bar. Default is the same as html_title.
128
+ #html_short_title = None
129
+
130
+ # The name of an image file (relative to this directory) to place at the top
131
+ # of the sidebar.
132
+ #html_logo = None
133
+
134
+ # The name of an image file (within the static path) to use as favicon of the
135
+ # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136
+ # pixels large.
137
+ #html_favicon = None
138
+
139
+ # Add any paths that contain custom static files (such as style sheets) here,
140
+ # relative to this directory. They are copied after the builtin static files,
141
+ # so a file named "default.css" will overwrite the builtin "default.css".
142
+ html_static_path = ['_static']
143
+
144
+ # Add any extra paths that contain custom files (such as robots.txt or
145
+ # .htaccess) here, relative to this directory. These files are copied
146
+ # directly to the root of the documentation.
147
+ html_extra_path = ['../samples']
148
+
149
+
150
+ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
151
+ # using the given strftime format.
152
+ #html_last_updated_fmt = '%b %d, %Y'
153
+
154
+ # If true, SmartyPants will be used to convert quotes and dashes to
155
+ # typographically correct entities.
156
+ #html_use_smartypants = True
157
+
158
+ # Custom sidebar templates, maps document names to template names.
159
+ #html_sidebars = {}
160
+
161
+ # Additional templates that should be rendered to pages, maps page names to
162
+ # template names.
163
+ #html_additional_pages = {}
164
+
165
+ # If false, no module index is generated.
166
+ #html_domain_indices = True
167
+
168
+ # If false, no index is generated.
169
+ #html_use_index = True
170
+
171
+ # If true, the index is split into individual pages for each letter.
172
+ #html_split_index = False
173
+
174
+ # If true, links to the reST sources are added to the pages.
175
+ #html_show_sourcelink = True
176
+
177
+ # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
178
+ #html_show_sphinx = True
179
+
180
+ # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
181
+ #html_show_copyright = True
182
+
183
+ # If true, an OpenSearch description file will be output, and all pages will
184
+ # contain a <link> tag referring to it. The value of this option must be the
185
+ # base URL from which the finished HTML is served.
186
+ #html_use_opensearch = ''
187
+
188
+ # This is the file name suffix for HTML files (e.g. ".xhtml").
189
+ #html_file_suffix = None
190
+
191
+ # Language to be used for generating the HTML full-text search index.
192
+ # Sphinx supports the following languages:
193
+ # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
194
+ # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
195
+ #html_search_language = 'en'
196
+
197
+ # A dictionary with options for the search language support, empty by default.
198
+ # Now only 'ja' uses this config value
199
+ #html_search_options = {'type': 'default'}
200
+
201
+ # The name of a javascript file (relative to the configuration directory) that
202
+ # implements a search results scorer. If empty, the default will be used.
203
+ #html_search_scorer = 'scorer.js'
204
+
205
+ # Output file base name for HTML help builder.
206
+ htmlhelp_basename = 'Squibdoc'
207
+
208
+ # -- Options for LaTeX output ---------------------------------------------
209
+
210
+ latex_elements = {
211
+ # The paper size ('letterpaper' or 'a4paper').
212
+ #'papersize': 'letterpaper',
213
+
214
+ # The font size ('10pt', '11pt' or '12pt').
215
+ #'pointsize': '10pt',
216
+
217
+ # Additional stuff for the LaTeX preamble.
218
+ #'preamble': '',
219
+
220
+ # Latex figure (float) alignment
221
+ #'figure_align': 'htbp',
222
+ }
223
+
224
+ # Grouping the document tree into LaTeX files. List of tuples
225
+ # (source start file, target name, title,
226
+ # author, documentclass [howto, manual, or own class]).
227
+ latex_documents = [
228
+ (master_doc, 'Squib.tex', u'Squib Documentation',
229
+ u'Andy Meneely', 'manual'),
230
+ ]
231
+
232
+ # The name of an image file (relative to this directory) to place at the top of
233
+ # the title page.
234
+ #latex_logo = None
235
+
236
+ # For "manual" documents, if this is true, then toplevel headings are parts,
237
+ # not chapters.
238
+ #latex_use_parts = False
239
+
240
+ # If true, show page references after internal links.
241
+ #latex_show_pagerefs = False
242
+
243
+ # If true, show URL addresses after external links.
244
+ #latex_show_urls = False
245
+
246
+ # Documents to append as an appendix to all manuals.
247
+ #latex_appendices = []
248
+
249
+ # If false, no module index is generated.
250
+ #latex_domain_indices = True
251
+
252
+
253
+ # -- Options for manual page output ---------------------------------------
254
+
255
+ # One entry per manual page. List of tuples
256
+ # (source start file, name, description, authors, manual section).
257
+ man_pages = [
258
+ (master_doc, 'squib', u'Squib Documentation',
259
+ [author], 1)
260
+ ]
261
+
262
+ # If true, show URL addresses after external links.
263
+ #man_show_urls = False
264
+
265
+
266
+ # -- Options for Texinfo output -------------------------------------------
267
+
268
+ # Grouping the document tree into Texinfo files. List of tuples
269
+ # (source start file, target name, title, author,
270
+ # dir menu entry, description, category)
271
+ texinfo_documents = [
272
+ (master_doc, 'Squib', u'Squib Documentation',
273
+ author, 'Squib', 'One line description of project.',
274
+ 'Miscellaneous'),
275
+ ]
276
+
277
+ # Documents to append as an appendix to all manuals.
278
+ #texinfo_appendices = []
279
+
280
+ # If false, no module index is generated.
281
+ #texinfo_domain_indices = True
282
+
283
+ # How to display URL addresses: 'footnote', 'no', or 'inline'.
284
+ #texinfo_show_urls = 'footnote'
285
+
286
+ # If true, do not generate a @detailmenu in the "Top" node's menu.
287
+ #texinfo_no_detailmenu = False