squib 0.18.0 → 0.19.0a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -39
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +22 -22
  4. data/.github/ISSUE_TEMPLATE/help-wanted.md +13 -13
  5. data/.github/ISSUE_TEMPLATE/release-todo.md +45 -33
  6. data/.github/PULL_REQUEST_TEMPLATE.md +13 -13
  7. data/.github/workflows/tests.yml +22 -22
  8. data/.gitignore +41 -41
  9. data/.vscode/settings.json +4 -3
  10. data/CHANGELOG.md +460 -460
  11. data/CONTRIBUTING.md +40 -40
  12. data/Dockerfile +27 -27
  13. data/Gemfile +2 -2
  14. data/Guardfile +8 -8
  15. data/LICENSE.txt +22 -22
  16. data/README.md +139 -139
  17. data/Rakefile +51 -51
  18. data/bin/squib +5 -5
  19. data/lib/squib/api/settings.rb +21 -21
  20. data/lib/squib/args/arg_loader.rb +138 -138
  21. data/lib/squib/args/box.rb +59 -59
  22. data/lib/squib/args/card_range.rb +34 -34
  23. data/lib/squib/args/color_validator.rb +7 -7
  24. data/lib/squib/args/coords.rb +49 -49
  25. data/lib/squib/args/csv_opts.rb +22 -22
  26. data/lib/squib/args/dir_validator.rb +11 -11
  27. data/lib/squib/args/draw.rb +93 -93
  28. data/lib/squib/args/drop_shadow.rb +39 -39
  29. data/lib/squib/args/embed_adjust.rb +22 -22
  30. data/lib/squib/args/embed_key.rb +12 -12
  31. data/lib/squib/args/hand_special.rb +37 -37
  32. data/lib/squib/args/import.rb +67 -67
  33. data/lib/squib/args/input_file.rb +55 -55
  34. data/lib/squib/args/paint.rb +43 -43
  35. data/lib/squib/args/paragraph.rb +118 -118
  36. data/lib/squib/args/save_batch.rb +65 -65
  37. data/lib/squib/args/scale_box.rb +57 -57
  38. data/lib/squib/args/sheet.rb +165 -165
  39. data/lib/squib/args/showcase_special.rb +41 -41
  40. data/lib/squib/args/sprue_file.rb +44 -44
  41. data/lib/squib/args/svg_special.rb +37 -37
  42. data/lib/squib/args/transform.rb +55 -55
  43. data/lib/squib/args/typographer.rb +115 -115
  44. data/lib/squib/args/unit_conversion.rb +27 -27
  45. data/lib/squib/args/xywh_shorthands.rb +50 -50
  46. data/lib/squib/builtin/layouts/economy.yml +85 -85
  47. data/lib/squib/builtin/layouts/fantasy.yml +101 -101
  48. data/lib/squib/builtin/layouts/hand.yml +62 -62
  49. data/lib/squib/builtin/layouts/party.yml +94 -94
  50. data/lib/squib/builtin/layouts/playing-card.yml +35 -35
  51. data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
  52. data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
  53. data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
  54. data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
  55. data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
  56. data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
  57. data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
  58. data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
  59. data/lib/squib/builtin/projects/advanced/config.yml +49 -49
  60. data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
  61. data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
  62. data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
  63. data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
  64. data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
  65. data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
  66. data/lib/squib/builtin/projects/basic/.gitignore +4 -4
  67. data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
  68. data/lib/squib/builtin/projects/basic/Gemfile +3 -3
  69. data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
  70. data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
  71. data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
  72. data/lib/squib/builtin/projects/basic/RULES.md +21 -21
  73. data/lib/squib/builtin/projects/basic/Rakefile +7 -7
  74. data/lib/squib/builtin/projects/basic/config.yml +50 -50
  75. data/lib/squib/builtin/projects/basic/deck.rb +6 -6
  76. data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
  77. data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
  78. data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
  79. data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
  80. data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
  81. data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
  82. data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
  83. data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
  84. data/lib/squib/card.rb +75 -75
  85. data/lib/squib/commands/cli.rb +39 -39
  86. data/lib/squib/commands/data/template_option.rb +109 -109
  87. data/lib/squib/commands/make_sprue.rb +277 -277
  88. data/lib/squib/commands/new.rb +77 -77
  89. data/lib/squib/conf.rb +149 -149
  90. data/lib/squib/constants.rb +17 -17
  91. data/lib/squib/deck.rb +138 -138
  92. data/lib/squib/dsl/background.rb +35 -35
  93. data/lib/squib/dsl/circle.rb +39 -39
  94. data/lib/squib/dsl/csv.rb +42 -42
  95. data/lib/squib/dsl/curve.rb +35 -35
  96. data/lib/squib/dsl/cut_zone.rb +47 -47
  97. data/lib/squib/dsl/ellipse.rb +37 -37
  98. data/lib/squib/dsl/grid.rb +35 -35
  99. data/lib/squib/dsl/groups.rb +54 -54
  100. data/lib/squib/dsl/hand.rb +42 -42
  101. data/lib/squib/dsl/line.rb +35 -35
  102. data/lib/squib/dsl/png.rb +57 -57
  103. data/lib/squib/dsl/polygon.rb +36 -36
  104. data/lib/squib/dsl/rect.rb +37 -37
  105. data/lib/squib/dsl/safe_zone.rb +48 -48
  106. data/lib/squib/dsl/save.rb +21 -21
  107. data/lib/squib/dsl/save_pdf.rb +50 -50
  108. data/lib/squib/dsl/save_png.rb +48 -48
  109. data/lib/squib/dsl/save_sheet.rb +53 -53
  110. data/lib/squib/dsl/showcase.rb +43 -43
  111. data/lib/squib/dsl/star.rb +37 -37
  112. data/lib/squib/dsl/svg.rb +63 -63
  113. data/lib/squib/dsl/text.rb +54 -54
  114. data/lib/squib/dsl/text_embed.rb +79 -79
  115. data/lib/squib/dsl/triangle.rb +35 -35
  116. data/lib/squib/dsl/units.rb +37 -37
  117. data/lib/squib/dsl/xlsx.rb +40 -40
  118. data/lib/squib/dsl/yaml.rb +40 -40
  119. data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -14
  120. data/lib/squib/graphics/background.rb +14 -14
  121. data/lib/squib/graphics/cairo_context_wrapper.rb +115 -115
  122. data/lib/squib/graphics/embedding_utils.rb +28 -28
  123. data/lib/squib/graphics/gradient_regex.rb +47 -47
  124. data/lib/squib/graphics/hand.rb +42 -42
  125. data/lib/squib/graphics/image.rb +123 -123
  126. data/lib/squib/graphics/save_doc.rb +77 -77
  127. data/lib/squib/graphics/save_images.rb +91 -91
  128. data/lib/squib/graphics/save_pdf.rb +90 -90
  129. data/lib/squib/graphics/save_sprue.rb +231 -231
  130. data/lib/squib/graphics/shapes.rb +143 -143
  131. data/lib/squib/graphics/showcase.rb +85 -85
  132. data/lib/squib/graphics/text.rb +202 -202
  133. data/lib/squib/import/csv_importer.rb +45 -45
  134. data/lib/squib/import/data_frame.rb +108 -108
  135. data/lib/squib/import/quantity_exploder.rb +17 -17
  136. data/lib/squib/import/xlsx_importer.rb +28 -28
  137. data/lib/squib/import/yaml_importer.rb +30 -30
  138. data/lib/squib/layout_parser.rb +155 -155
  139. data/lib/squib/progress.rb +38 -38
  140. data/lib/squib/sample_helpers.rb +34 -34
  141. data/lib/squib/sprues/crop_line.rb +28 -28
  142. data/lib/squib/sprues/crop_line_dash.rb +35 -35
  143. data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
  144. data/lib/squib/sprues/sprue.rb +208 -208
  145. data/lib/squib/sprues/sprue_schema.rb +51 -51
  146. data/lib/squib/system_fonts.rb +16 -16
  147. data/lib/squib/version.rb +11 -11
  148. data/lib/squib.rb +35 -35
  149. data/samples/autoscale_font/_autoscale_font.rb +98 -98
  150. data/samples/backend/_backend.rb +26 -26
  151. data/samples/basic.rb +19 -19
  152. data/samples/build_groups/build_groups.rb +36 -36
  153. data/samples/colors/_colors.rb +44 -44
  154. data/samples/colors/_gradients.rb +34 -34
  155. data/samples/colors/_switch_color.rb +33 -33
  156. data/samples/config/config_text_markup.rb +20 -20
  157. data/samples/config/custom_config.rb +18 -18
  158. data/samples/data/_csv.rb +33 -33
  159. data/samples/data/_excel.rb +55 -55
  160. data/samples/data/_yaml.rb +12 -12
  161. data/samples/hello_world.rb +6 -6
  162. data/samples/images/_cairo_access.rb +39 -39
  163. data/samples/images/_images.rb +104 -104
  164. data/samples/images/_more_load_images.rb +102 -102
  165. data/samples/images/_placeholders.rb +48 -48
  166. data/samples/intro/01_hello.rb +8 -8
  167. data/samples/intro/02_options.rb +14 -14
  168. data/samples/intro/03_layout.rb +11 -11
  169. data/samples/intro/04_arrays.rb +15 -15
  170. data/samples/intro/05_excel.rb +14 -14
  171. data/samples/layouts/builtin_layouts.rb +97 -97
  172. data/samples/layouts/layouts.rb +71 -71
  173. data/samples/project/src/characters.rb +8 -8
  174. data/samples/project/src/skills.rb +7 -7
  175. data/samples/proofs/_tgc_proofs.rb +16 -16
  176. data/samples/ranges/_ranges.rb +64 -64
  177. data/samples/saves/_hand.rb +23 -23
  178. data/samples/saves/_portrait_landscape.rb +23 -23
  179. data/samples/saves/_save_filenames.rb +28 -28
  180. data/samples/saves/_save_pdf.rb +29 -29
  181. data/samples/saves/_saves.rb +75 -75
  182. data/samples/saves/_showcase.rb +25 -25
  183. data/samples/shadows/_shadow.rb +71 -71
  184. data/samples/shapes/_draw_shapes.rb +60 -60
  185. data/samples/shapes/_proofs.rb +22 -22
  186. data/samples/sprues/_advanced_sprues.rb +25 -25
  187. data/samples/sprues/_builtin_sprues.rb +22 -22
  188. data/samples/sprues/_fold_sheet.rb +30 -30
  189. data/samples/sprues/_hex_tiles.rb +15 -15
  190. data/samples/sprues/_mints.rb +11 -11
  191. data/samples/sprues/_negative_coords.rb +6 -6
  192. data/samples/sprues/_sprue_example.rb +11 -11
  193. data/samples/system_font_debug/_list_fonts.rb +14 -14
  194. data/samples/text/_embed_text.rb +128 -128
  195. data/samples/text/_text.rb +52 -52
  196. data/samples/text/_text_options.rb +103 -103
  197. data/samples/text/bug134.rb +14 -14
  198. data/samples/units/_cells.rb +50 -50
  199. data/samples/units/_shorthands.rb +48 -48
  200. data/samples/units/_units.rb +39 -39
  201. data/squib.gemspec +58 -58
  202. metadata +21 -21
@@ -1,102 +1,102 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.yml') do
4
- background color: '#0b7c8e'
5
- rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
6
-
7
- png file: 'shiny-purse.png', x: 620, y: 75 # no scaling is done by default
8
- svg file: 'spanner.svg', x: 620, y: 218
9
-
10
- # Can be scaled if width and height are set
11
- svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
12
- png file: 'shiny-purse.png', x: 305, y: 50, width: 250, height: 250
13
- # ...but PNGs will warn if it's an upscale, unless you disable them in config.yml
14
-
15
- # Can be scaled using just width or height, if one of them is set to :scale
16
- svg file: 'spanner.svg', x: 200, y: 350, width: 35, height: :scale
17
- svg file: 'spanner.svg', x: 200, y: 390, width: :scale, height: 35
18
- png file: 'shiny-purse.png', x: 240, y: 350, width: 35, height: :scale
19
- png file: 'shiny-purse.png', x: 240, y: 390, width: :scale, height: 35
20
-
21
- # You can also crop the loaded images, so you can work from a sprite sheet
22
- png file: 'sprites.png', x: 300, y: 350 # entire sprite sheet
23
- png file: 'sprites.png', x: 300, y: 425, # just the robot golem image
24
- crop_x: 0, crop_y: 0, crop_corner_radius: 10,
25
- crop_width: 64, crop_height: 64
26
- png file: 'sprites.png', x: 400, y: 425, # just the drakkar ship image
27
- crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
28
- crop_width: 64, crop_height: 64
29
- png file: 'sprites.png', x: 500, y: 415, # just the drakkar ship image, rotated
30
- crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
31
- crop_width: 64, crop_height: 64, angle: Math::PI / 6
32
-
33
- # Cropping also works on SVGs too
34
- svg file: 'spanner.svg', x: 300, y: 500, width: 64, height: 64,
35
- crop_x: 32, crop_y: 32, crop_width: 32, crop_height:32
36
-
37
- # We can flip our images too
38
- png file: 'sprites.png', x: 300, y: 535, flip_vertical: true, flip_horizontal: true
39
- svg file: 'spanner.svg', x: 300, y: 615, width: 64, height: 64,
40
- flip_vertical: true, flip_horizontal: true
41
-
42
- # We can also limit our rendering to a single object, if the SVG ID is set
43
- svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
44
- # Squib prepends a #-sign if one is not specified
45
- svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
46
-
47
- # We can also load SVGs as a string of XML
48
- svg data: File.read('spanner.svg'), x: 50, y: 600, width: 75, height: 75
49
-
50
- # The svg data field works nicely with modifying the SVG XML on-the-fly.
51
- # To run this one, do `gem install game_icons` and uncomment the following
52
- #
53
- # require 'game_icons'
54
- # svg data: GameIcons.get('angler-fish').recolor(fg: '#ccc', bg: '#333').string,
55
- # x: 150, y: 600, width: 75, height: 75
56
- #
57
- # More examples at https://github.com/andymeneely/game_icons
58
- # (or `gem install game_icons`) to get & manipulate art from game-icons.net
59
- # Nokogiri (already included in Squib) is also great for XML manipulation.
60
-
61
- # WARNING! If you choose to use the SVG ID, the x-y coordinates are still
62
- # relative to the SVG page. See this example in an SVG editor
63
- svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600
64
-
65
- # Over 15 different blending operators are supported.
66
- # See http://cairographics.org/operators
67
- # Alpha transparency too
68
- png file: 'ball.png', x: 50, y: 700
69
- png file: 'grit.png', x: 70, y: 750, blend: :color_burn, alpha: 0.75
70
-
71
- # Images can be rotated around their upper-left corner
72
- png file: 'shiny-purse.png', x: 300, y: 700, angle: 0.0 # default (no rotate)
73
- png file: 'shiny-purse.png', x: 300, y: 800, angle: Math::PI / 4
74
- svg file: 'spanner.svg', x: 300, y: 900, angle: Math::PI / 2 - 0.1
75
-
76
- # Images can also be used as masks instead of being directly painted.
77
- # This is particularly useful for switching directly over to black-and-white for printing
78
- # Or, if you want the same image to be used but with different colors/gradients
79
- svg mask: '#00ff00',
80
- file: 'glass-heart.svg',
81
- x: 500, y: 600, width: 200, height: 200
82
- svg mask: '(0,0)(0,500) #ccc@0.0 #333@1.0',
83
- file: 'glass-heart.svg',
84
- x: 500, y: 800, width: 200, height: 200
85
-
86
- # Masks are based on the alpha channel, so this is just a magenta square
87
- png mask: :magenta, file: 'shiny-purse.png',
88
- x: 650, y: 950
89
-
90
- # Note that this method does nothing, even though it would normally fill up
91
- # the card. force_id: true looks to the id field to be non-empty to render.
92
- # This is useful if you have multiple different icons in one SVG file,
93
- # but sometimes want to use none.
94
- # e.g. id: [:attack, :defend, nil]
95
- svg file: 'spanner.svg', width: :deck, height: :deck,
96
- force_id: true, id: nil # <-- the important part
97
-
98
- # Squib can handle incorrectly formatted svg files
99
- svg file: 'bad-svg.svg'
100
-
101
- save prefix: 'load_images_', format: :png
102
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.yml') do
4
+ background color: '#0b7c8e'
5
+ rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
6
+
7
+ png file: 'shiny-purse.png', x: 620, y: 75 # no scaling is done by default
8
+ svg file: 'spanner.svg', x: 620, y: 218
9
+
10
+ # Can be scaled if width and height are set
11
+ svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
12
+ png file: 'shiny-purse.png', x: 305, y: 50, width: 250, height: 250
13
+ # ...but PNGs will warn if it's an upscale, unless you disable them in config.yml
14
+
15
+ # Can be scaled using just width or height, if one of them is set to :scale
16
+ svg file: 'spanner.svg', x: 200, y: 350, width: 35, height: :scale
17
+ svg file: 'spanner.svg', x: 200, y: 390, width: :scale, height: 35
18
+ png file: 'shiny-purse.png', x: 240, y: 350, width: 35, height: :scale
19
+ png file: 'shiny-purse.png', x: 240, y: 390, width: :scale, height: 35
20
+
21
+ # You can also crop the loaded images, so you can work from a sprite sheet
22
+ png file: 'sprites.png', x: 300, y: 350 # entire sprite sheet
23
+ png file: 'sprites.png', x: 300, y: 425, # just the robot golem image
24
+ crop_x: 0, crop_y: 0, crop_corner_radius: 10,
25
+ crop_width: 64, crop_height: 64
26
+ png file: 'sprites.png', x: 400, y: 425, # just the drakkar ship image
27
+ crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
28
+ crop_width: 64, crop_height: 64
29
+ png file: 'sprites.png', x: 500, y: 415, # just the drakkar ship image, rotated
30
+ crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
31
+ crop_width: 64, crop_height: 64, angle: Math::PI / 6
32
+
33
+ # Cropping also works on SVGs too
34
+ svg file: 'spanner.svg', x: 300, y: 500, width: 64, height: 64,
35
+ crop_x: 32, crop_y: 32, crop_width: 32, crop_height:32
36
+
37
+ # We can flip our images too
38
+ png file: 'sprites.png', x: 300, y: 535, flip_vertical: true, flip_horizontal: true
39
+ svg file: 'spanner.svg', x: 300, y: 615, width: 64, height: 64,
40
+ flip_vertical: true, flip_horizontal: true
41
+
42
+ # We can also limit our rendering to a single object, if the SVG ID is set
43
+ svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
44
+ # Squib prepends a #-sign if one is not specified
45
+ svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
46
+
47
+ # We can also load SVGs as a string of XML
48
+ svg data: File.read('spanner.svg'), x: 50, y: 600, width: 75, height: 75
49
+
50
+ # The svg data field works nicely with modifying the SVG XML on-the-fly.
51
+ # To run this one, do `gem install game_icons` and uncomment the following
52
+ #
53
+ # require 'game_icons'
54
+ # svg data: GameIcons.get('angler-fish').recolor(fg: '#ccc', bg: '#333').string,
55
+ # x: 150, y: 600, width: 75, height: 75
56
+ #
57
+ # More examples at https://github.com/andymeneely/game_icons
58
+ # (or `gem install game_icons`) to get & manipulate art from game-icons.net
59
+ # Nokogiri (already included in Squib) is also great for XML manipulation.
60
+
61
+ # WARNING! If you choose to use the SVG ID, the x-y coordinates are still
62
+ # relative to the SVG page. See this example in an SVG editor
63
+ svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600
64
+
65
+ # Over 15 different blending operators are supported.
66
+ # See http://cairographics.org/operators
67
+ # Alpha transparency too
68
+ png file: 'ball.png', x: 50, y: 700
69
+ png file: 'grit.png', x: 70, y: 750, blend: :color_burn, alpha: 0.75
70
+
71
+ # Images can be rotated around their upper-left corner
72
+ png file: 'shiny-purse.png', x: 300, y: 700, angle: 0.0 # default (no rotate)
73
+ png file: 'shiny-purse.png', x: 300, y: 800, angle: Math::PI / 4
74
+ svg file: 'spanner.svg', x: 300, y: 900, angle: Math::PI / 2 - 0.1
75
+
76
+ # Images can also be used as masks instead of being directly painted.
77
+ # This is particularly useful for switching directly over to black-and-white for printing
78
+ # Or, if you want the same image to be used but with different colors/gradients
79
+ svg mask: '#00ff00',
80
+ file: 'glass-heart.svg',
81
+ x: 500, y: 600, width: 200, height: 200
82
+ svg mask: '(0,0)(0,500) #ccc@0.0 #333@1.0',
83
+ file: 'glass-heart.svg',
84
+ x: 500, y: 800, width: 200, height: 200
85
+
86
+ # Masks are based on the alpha channel, so this is just a magenta square
87
+ png mask: :magenta, file: 'shiny-purse.png',
88
+ x: 650, y: 950
89
+
90
+ # Note that this method does nothing, even though it would normally fill up
91
+ # the card. force_id: true looks to the id field to be non-empty to render.
92
+ # This is useful if you have multiple different icons in one SVG file,
93
+ # but sometimes want to use none.
94
+ # e.g. id: [:attack, :defend, nil]
95
+ svg file: 'spanner.svg', width: :deck, height: :deck,
96
+ force_id: true, id: nil # <-- the important part
97
+
98
+ # Squib can handle incorrectly formatted svg files
99
+ svg file: 'bad-svg.svg'
100
+
101
+ save prefix: 'load_images_', format: :png
102
+ end
@@ -1,49 +1,49 @@
1
- # require 'squib'
2
- require_relative '../../lib/squib'
3
-
4
- # By default Squib will simply warn you if an image is missing
5
- # Instead, you can give it a `placeholder`
6
- Squib.configure img_missing: :silent # no warnings, no errors, no placeholder
7
- # Squib.configure img_missing: :warn # default
8
- # Squib.configure img_missing: :error # pre Squib v0.18 behavior... blech
9
-
10
- Squib::Deck.new(width: 100, height: 100, cards: 3) do
11
- background color: :white
12
-
13
- files = %w(angler-fish.png does-not-exist.png) # last one is nil
14
- png file: files, placeholder: 'grit.png'
15
- save_sheet columns: 1, prefix: 'placeholder_sheet_'
16
- end
17
-
18
- # Placeholders can be per-image too.
19
- # What if a placeholder is specified but doesn't exist? It'll always warn.
20
- Squib.configure img_missing: :warn # default
21
- Squib::Deck.new(width: 100, height: 100, cards: 4) do
22
- background color: :white
23
-
24
- files = %w(angler-fish.png does-not-exist.png does-not-exist.png does-not-exist.png)
25
- placeholders = %w(grit.png does-not-exist.png grit.png )
26
- png file: files, placeholder: placeholders
27
-
28
- # text embeds can have placeholders too
29
- text(str: 'A', color: :red) do |embed|
30
- embed.png key: 'A', file: files, placeholder: placeholders, width: 30, height: 30
31
- end
32
-
33
- save_sheet columns: 1, prefix: 'multi_placeholder_sheet_'
34
- end
35
-
36
- # Do errors work?
37
- # If you REALLY want the old, pre-Squib v0.18 functionality
38
- # ...you can still have it
39
- # This is really more of a regression test than example.
40
- Squib.configure img_missing: :error
41
- Squib::Deck.new(width: 100, height: 100, cards: 1) do
42
- begin
43
- png file: 'does-not-exist.png' # no placeholder... should error!
44
- raise Exception.new 'Runtime Error should have been thrown!'
45
- rescue RuntimeError => e
46
- # a runtime error should have happened here. So nothing happens. Good.
47
- Squib.logger.error 'Yay! An error we expected was thrown.'
48
- end
1
+ # require 'squib'
2
+ require_relative '../../lib/squib'
3
+
4
+ # By default Squib will simply warn you if an image is missing
5
+ # Instead, you can give it a `placeholder`
6
+ Squib.configure img_missing: :silent # no warnings, no errors, no placeholder
7
+ # Squib.configure img_missing: :warn # default
8
+ # Squib.configure img_missing: :error # pre Squib v0.18 behavior... blech
9
+
10
+ Squib::Deck.new(width: 100, height: 100, cards: 3) do
11
+ background color: :white
12
+
13
+ files = %w(angler-fish.png does-not-exist.png) # last one is nil
14
+ png file: files, placeholder: 'grit.png'
15
+ save_sheet columns: 1, prefix: 'placeholder_sheet_'
16
+ end
17
+
18
+ # Placeholders can be per-image too.
19
+ # What if a placeholder is specified but doesn't exist? It'll always warn.
20
+ Squib.configure img_missing: :warn # default
21
+ Squib::Deck.new(width: 100, height: 100, cards: 4) do
22
+ background color: :white
23
+
24
+ files = %w(angler-fish.png does-not-exist.png does-not-exist.png does-not-exist.png)
25
+ placeholders = %w(grit.png does-not-exist.png grit.png )
26
+ png file: files, placeholder: placeholders
27
+
28
+ # text embeds can have placeholders too
29
+ text(str: 'A', color: :red) do |embed|
30
+ embed.png key: 'A', file: files, placeholder: placeholders, width: 30, height: 30
31
+ end
32
+
33
+ save_sheet columns: 1, prefix: 'multi_placeholder_sheet_'
34
+ end
35
+
36
+ # Do errors work?
37
+ # If you REALLY want the old, pre-Squib v0.18 functionality
38
+ # ...you can still have it
39
+ # This is really more of a regression test than example.
40
+ Squib.configure img_missing: :error
41
+ Squib::Deck.new(width: 100, height: 100, cards: 1) do
42
+ begin
43
+ png file: 'does-not-exist.png' # no placeholder... should error!
44
+ raise Exception.new 'Runtime Error should have been thrown!'
45
+ rescue RuntimeError => e
46
+ # a runtime error should have happened here. So nothing happens. Good.
47
+ Squib.logger.error 'Yay! An error we expected was thrown.'
48
+ end
49
49
  end
@@ -1,8 +1,8 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new cards: 1 do
4
- background color: 'pink'
5
- rect
6
- text str: 'Draw two cards.'
7
- save_png prefix: 'part1_'
8
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1 do
4
+ background color: 'pink'
5
+ rect
6
+ text str: 'Draw two cards.'
7
+ save_png prefix: 'part1_'
8
+ end
@@ -1,14 +1,14 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new cards: 1 do
4
- background color: '#252322'
5
- rect fill_color: '#0B3736',
6
- x: 38, y: 38, width: 750, height: 1050, radius: 38
7
- text str: 'Robot Golem', font: 'True Crimes, Sans 24',
8
- align: :center, x: 75, width: :deck, color: '#DFDFE1', y: 90
9
- svg file: 'auto-repair.svg', x: 75, y: 75, width: 100, height: :scale
10
- svg file: 'robot-golem.svg', x: 75, y: 300, width: 675, height: :scale
11
- text str: 'Draw two cards', font: 'Serif 12',
12
- align: :center, width: :deck, color: '#DFDFE1', y: 1000
13
- save_png prefix: 'part2_'
14
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1 do
4
+ background color: '#252322'
5
+ rect fill_color: '#0B3736',
6
+ x: 38, y: 38, width: 750, height: 1050, radius: 38
7
+ text str: 'Robot Golem', font: 'True Crimes, Sans 24',
8
+ align: :center, x: 75, width: :deck, color: '#DFDFE1', y: 90
9
+ svg file: 'auto-repair.svg', x: 75, y: 75, width: 100, height: :scale
10
+ svg file: 'robot-golem.svg', x: 75, y: 300, width: 675, height: :scale
11
+ text str: 'Draw two cards', font: 'Serif 12',
12
+ align: :center, width: :deck, color: '#DFDFE1', y: 1000
13
+ save_png prefix: 'part2_'
14
+ end
@@ -1,11 +1,11 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new cards: 1, layout: 'part3_layout.yml' do
4
- background color: '#252322'
5
- rect layout: 'backdrop'
6
- text str: 'Robot Golem', layout: 'title'
7
- svg layout: 'drone'
8
- svg file: 'robot-golem.svg', layout: 'art'
9
- text str: 'Draw two cards.', layout: 'power'
10
- save_png prefix: 'part3_'
11
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ text str: 'Robot Golem', layout: 'title'
7
+ svg layout: 'drone'
8
+ svg file: 'robot-golem.svg', layout: 'art'
9
+ text str: 'Draw two cards.', layout: 'power'
10
+ save_png prefix: 'part3_'
11
+ end
@@ -1,15 +1,15 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new cards: 2, layout: 'part3_layout.yml' do
4
- background color: '#252322'
5
- rect layout: 'backdrop'
6
- text str: ['Robot Golem', 'Ninja'],
7
- layout: 'title'
8
- svg layout: ['drone', 'human']
9
- svg file: ['robot-golem.svg','ninja-mask.svg'],
10
- layout: 'art'
11
- text str: ['Draw two cards',
12
- 'Use the power of another player'],
13
- layout: 'power'
14
- save_png prefix: 'part4_'
15
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 2, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ text str: ['Robot Golem', 'Ninja'],
7
+ layout: 'title'
8
+ svg layout: ['drone', 'human']
9
+ svg file: ['robot-golem.svg','ninja-mask.svg'],
10
+ layout: 'art'
11
+ text str: ['Draw two cards',
12
+ 'Use the power of another player'],
13
+ layout: 'power'
14
+ save_png prefix: 'part4_'
15
+ end
@@ -1,14 +1,14 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new cards: 4, layout: 'part3_layout.yml' do
4
- background color: '#252322'
5
- rect layout: 'backdrop'
6
- data = xlsx file: 'data.xlsx'
7
- text str: data['name'], layout: 'title'
8
- svg layout: data['class']
9
- svg file: data['art'], layout: 'art'
10
- text str: data['power'], layout: 'power'
11
- save_png prefix: 'part5_'
12
- hand file: 'part5_hand.png', trim_radius: 38
13
- showcase file: 'part5_showcase.png'
14
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 4, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ data = xlsx file: 'data.xlsx'
7
+ text str: data['name'], layout: 'title'
8
+ svg layout: data['class']
9
+ svg file: data['art'], layout: 'art'
10
+ text str: data['power'], layout: 'power'
11
+ save_png prefix: 'part5_'
12
+ hand file: 'part5_hand.png', trim_radius: 38
13
+ showcase file: 'part5_showcase.png'
14
+ end
@@ -1,97 +1,97 @@
1
- require 'squib'
2
-
3
- # This sample demonstrates the built-in layouts for Squib.
4
- # Each card demonstrates a different built-in layout.
5
- Squib::Deck.new(layout: 'fantasy.yml') do
6
- background color: 'white'
7
-
8
- set font: 'Times New Roman,Serif 10.5'
9
- hint text: '#333' # show extents of text boxes to demo the layout
10
-
11
- text str: 'fantasy.yml', layout: :title
12
- text str: 'ur', layout: :upper_right
13
- text str: 'art', layout: :art
14
- text str: 'type', layout: :type
15
- text str: 'tr', layout: :type_right
16
- text str: 'description', layout: :description
17
- text str: 'lr', layout: :lower_right
18
- text str: 'll', layout: :lower_left
19
- text str: 'credits', layout: :copy
20
-
21
- rect layout: :safe
22
- rect layout: :cut
23
- save_png prefix: 'layouts_builtin_fantasy_'
24
- end
25
-
26
- Squib::Deck.new(layout: 'economy.yml') do
27
- background color: 'white'
28
-
29
- set font: 'Times New Roman,Serif 10.5'
30
- hint text: '#333' # show extents of text boxes to demo the layout
31
-
32
- text str: 'economy.yml', layout: :title
33
- text str: 'art', layout: :art
34
- text str: 'description', layout: :description
35
- text str: 'type', layout: :type
36
- text str: 'lr', layout: :lower_right
37
- text str: 'll', layout: :lower_left
38
- text str: 'credits', layout: :copy
39
-
40
- rect layout: :safe
41
- rect layout: :cut
42
- save_png prefix: 'layouts_builtin_economy_'
43
- end
44
-
45
- Squib::Deck.new(layout: 'hand.yml') do
46
- background color: 'white'
47
- %w(title bonus1 bonus2 bonus3 bonus4 bonus5 description
48
- snark art).each do |icon|
49
- text str: icon.capitalize, layout: icon,
50
- hint: :red, valign: 'middle', align: 'center'
51
- end
52
- save_png prefix: 'layouts_builtin_hand_'
53
- end
54
-
55
- Squib::Deck.new(layout: 'playing-card.yml') do
56
- background color: 'white'
57
- text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 33', hint: :red
58
- text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 33', hint: :red
59
- text str: 'artwork here', layout: :art, hint: :red
60
- save_png prefix: 'layouts_builtin_playing_card_'
61
- end
62
-
63
- Squib::Deck.new(layout: 'tuck_box.yml', width: 2325, height: 1950) do
64
- background color: 'white'
65
- rect layout: :top_rect
66
- rect layout: :bottom_rect
67
- rect layout: :right_rect
68
- rect layout: :left_rect
69
- rect layout: :back_rect
70
- rect layout: :front_rect
71
- curve layout: :front_curve
72
-
73
- save_png prefix: 'layouts_builtin_tuck_box_'
74
- end
75
-
76
- Squib::Deck.new(layout: 'party.yml') do
77
- background color: 'white'
78
- # hint text: :black # uncomment to see the text box boundaries
79
-
80
- rect layout: :title_box,
81
- fill_color: :deep_sky_blue, stroke_width: 0
82
- text str: "A SILLY NAME", layout: :title
83
- text str: '✔', layout: :type_icon
84
- text str: 'TYPE', layout: :type
85
- text str: 'A Silly Name', layout: :title_middle
86
- rect fill_color: :black, layout: :middle_rect
87
-
88
- str = 'Rule or story text. Be funny ha ha ha this is a party.'
89
- text str: str, layout: :rule_top
90
- text str: str, layout: :rule_bottom
91
-
92
- text str: 'Tiny text', layout: :copyright
93
-
94
- rect layout: :safe
95
- rect layout: :cut
96
- save_png prefix: 'layouts_builtin_party_'
97
- end
1
+ require 'squib'
2
+
3
+ # This sample demonstrates the built-in layouts for Squib.
4
+ # Each card demonstrates a different built-in layout.
5
+ Squib::Deck.new(layout: 'fantasy.yml') do
6
+ background color: 'white'
7
+
8
+ set font: 'Times New Roman,Serif 10.5'
9
+ hint text: '#333' # show extents of text boxes to demo the layout
10
+
11
+ text str: 'fantasy.yml', layout: :title
12
+ text str: 'ur', layout: :upper_right
13
+ text str: 'art', layout: :art
14
+ text str: 'type', layout: :type
15
+ text str: 'tr', layout: :type_right
16
+ text str: 'description', layout: :description
17
+ text str: 'lr', layout: :lower_right
18
+ text str: 'll', layout: :lower_left
19
+ text str: 'credits', layout: :copy
20
+
21
+ rect layout: :safe
22
+ rect layout: :cut
23
+ save_png prefix: 'layouts_builtin_fantasy_'
24
+ end
25
+
26
+ Squib::Deck.new(layout: 'economy.yml') do
27
+ background color: 'white'
28
+
29
+ set font: 'Times New Roman,Serif 10.5'
30
+ hint text: '#333' # show extents of text boxes to demo the layout
31
+
32
+ text str: 'economy.yml', layout: :title
33
+ text str: 'art', layout: :art
34
+ text str: 'description', layout: :description
35
+ text str: 'type', layout: :type
36
+ text str: 'lr', layout: :lower_right
37
+ text str: 'll', layout: :lower_left
38
+ text str: 'credits', layout: :copy
39
+
40
+ rect layout: :safe
41
+ rect layout: :cut
42
+ save_png prefix: 'layouts_builtin_economy_'
43
+ end
44
+
45
+ Squib::Deck.new(layout: 'hand.yml') do
46
+ background color: 'white'
47
+ %w(title bonus1 bonus2 bonus3 bonus4 bonus5 description
48
+ snark art).each do |icon|
49
+ text str: icon.capitalize, layout: icon,
50
+ hint: :red, valign: 'middle', align: 'center'
51
+ end
52
+ save_png prefix: 'layouts_builtin_hand_'
53
+ end
54
+
55
+ Squib::Deck.new(layout: 'playing-card.yml') do
56
+ background color: 'white'
57
+ text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 33', hint: :red
58
+ text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 33', hint: :red
59
+ text str: 'artwork here', layout: :art, hint: :red
60
+ save_png prefix: 'layouts_builtin_playing_card_'
61
+ end
62
+
63
+ Squib::Deck.new(layout: 'tuck_box.yml', width: 2325, height: 1950) do
64
+ background color: 'white'
65
+ rect layout: :top_rect
66
+ rect layout: :bottom_rect
67
+ rect layout: :right_rect
68
+ rect layout: :left_rect
69
+ rect layout: :back_rect
70
+ rect layout: :front_rect
71
+ curve layout: :front_curve
72
+
73
+ save_png prefix: 'layouts_builtin_tuck_box_'
74
+ end
75
+
76
+ Squib::Deck.new(layout: 'party.yml') do
77
+ background color: 'white'
78
+ # hint text: :black # uncomment to see the text box boundaries
79
+
80
+ rect layout: :title_box,
81
+ fill_color: :deep_sky_blue, stroke_width: 0
82
+ text str: "A SILLY NAME", layout: :title
83
+ text str: '✔', layout: :type_icon
84
+ text str: 'TYPE', layout: :type
85
+ text str: 'A Silly Name', layout: :title_middle
86
+ rect fill_color: :black, layout: :middle_rect
87
+
88
+ str = 'Rule or story text. Be funny ha ha ha this is a party.'
89
+ text str: str, layout: :rule_top
90
+ text str: str, layout: :rule_bottom
91
+
92
+ text str: 'Tiny text', layout: :copyright
93
+
94
+ rect layout: :safe
95
+ rect layout: :cut
96
+ save_png prefix: 'layouts_builtin_party_'
97
+ end