squib 0.18.0 → 0.19.0a

Sign up to get free protection for your applications and to get access to all the features.
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,30 +1,30 @@
1
- require 'squib'
2
-
3
- # Note that this sample has no bleed - you might want to have bleed
4
- # but tighter than usual: 0.1 instead of 0.125in since this sprue is
5
- # crowded horizontally on US letter
6
- Squib::Deck.new(width: '2.5in', height: '3.5in', cards: 8) do
7
- background color: :white
8
- rect stroke_width: 5, stroke_color: :red
9
- # Note that we are interleaving strings
10
- # This could be used as a secondary Squib script that loads
11
- # Squib-generated individual images
12
- strings = [
13
- "Front 1",
14
- "Back 1",
15
- "Front 2",
16
- "Back 2",
17
- "Front 3",
18
- "Back 3",
19
- "Front 4",
20
- "Back 4",
21
- ]
22
-
23
- text str: strings,font: 'Sans 32', align: :center, valign: :middle,
24
- height: :deck, width: :deck
25
-
26
- save_sheet prefix: 'foldable_',
27
- sprue: 'letter_poker_foldable_8up.yml' # built-in sprue
28
- save_pdf file: 'foldable.pdf',
29
- sprue: 'letter_poker_foldable_8up.yml' # built-in sprue
30
- end
1
+ require 'squib'
2
+
3
+ # Note that this sample has no bleed - you might want to have bleed
4
+ # but tighter than usual: 0.1 instead of 0.125in since this sprue is
5
+ # crowded horizontally on US letter
6
+ Squib::Deck.new(width: '2.5in', height: '3.5in', cards: 8) do
7
+ background color: :white
8
+ rect stroke_width: 5, stroke_color: :red
9
+ # Note that we are interleaving strings
10
+ # This could be used as a secondary Squib script that loads
11
+ # Squib-generated individual images
12
+ strings = [
13
+ "Front 1",
14
+ "Back 1",
15
+ "Front 2",
16
+ "Back 2",
17
+ "Front 3",
18
+ "Back 3",
19
+ "Front 4",
20
+ "Back 4",
21
+ ]
22
+
23
+ text str: strings,font: 'Sans 32', align: :center, valign: :middle,
24
+ height: :deck, width: :deck
25
+
26
+ save_sheet prefix: 'foldable_',
27
+ sprue: 'letter_poker_foldable_8up.yml' # built-in sprue
28
+ save_pdf file: 'foldable.pdf',
29
+ sprue: 'letter_poker_foldable_8up.yml' # built-in sprue
30
+ end
@@ -1,15 +1,15 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: '65.8mm', height: '76mm', cards: 9) do
4
- polygon(
5
- x: '32.9mm', y: '38mm', n: 6, radius: '38mm', angle: 1.571,
6
- stroke_color: :black, stroke_width: '0.014in', fill_color: :pink
7
- )
8
- text(
9
- str: %w[One Two Three Four Five Six Seven Eight Nine],
10
- x: '22mm', y: '35mm', width: '21.8mm', height: '6mm',
11
- align: :center, valign: :middle
12
- )
13
- save_pdf file: 'hex_tiles.pdf',
14
- sprue: 'my_sprues/hex_tiles.yml'
15
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: '65.8mm', height: '76mm', cards: 9) do
4
+ polygon(
5
+ x: '32.9mm', y: '38mm', n: 6, radius: '38mm', angle: 1.571,
6
+ stroke_color: :black, stroke_width: '0.014in', fill_color: :pink
7
+ )
8
+ text(
9
+ str: %w[One Two Three Four Five Six Seven Eight Nine],
10
+ x: '22mm', y: '35mm', width: '21.8mm', height: '6mm',
11
+ align: :center, valign: :middle
12
+ )
13
+ save_pdf file: 'hex_tiles.pdf',
14
+ sprue: 'my_sprues/hex_tiles.yml'
15
+ end
@@ -1,11 +1,11 @@
1
- require 'squib'
2
-
3
- # An example deck that uses "mint" sized cards (e.g. Altoids).
4
- # These cards are pretty small but comfortably fit in a mint tin
5
-
6
- Squib::Deck.new(cards: 21, width: '54.0mm', height: '68.0mm') do
7
- background color: :gray
8
- rect
9
- text str: (1..21).to_a
10
- save_pdf sprue: 'my_sprues/us_letter_mints.yml'
11
- end
1
+ require 'squib'
2
+
3
+ # An example deck that uses "mint" sized cards (e.g. Altoids).
4
+ # These cards are pretty small but comfortably fit in a mint tin
5
+
6
+ Squib::Deck.new(cards: 21, width: '54.0mm', height: '68.0mm') do
7
+ background color: :gray
8
+ rect
9
+ text str: (1..21).to_a
10
+ save_pdf sprue: 'my_sprues/us_letter_mints.yml'
11
+ end
@@ -1,7 +1,7 @@
1
- require_relative '../../lib/squib'
2
-
3
- Squib::Deck.new(width: 100, height: 100, cards: 3) do
4
- background color: :grey
5
- text str: 'Hello', font: 'Sans Bold 10'
6
- save_sheet sprue: 'my_sprues/negatives.yml', prefix: 'sprue_negatives_'
1
+ require_relative '../../lib/squib'
2
+
3
+ Squib::Deck.new(width: 100, height: 100, cards: 3) do
4
+ background color: :grey
5
+ text str: 'Hello', font: 'Sans Bold 10'
6
+ save_sheet sprue: 'my_sprues/negatives.yml', prefix: 'sprue_negatives_'
7
7
  end
@@ -1,11 +1,11 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(cards: 9) do
4
- background color: :white
5
- rect stroke_width: 5, stroke_color: :red
6
- text str: (0..9).map{ |i| "Card #{i}\n2.5x3.5in" },
7
- font: 'Sans 32', align: :center, valign: :middle,
8
- height: :deck, width: :deck
9
- save_sheet sprue: 'letter_poker_card_9up.yml',
10
- prefix: "sprue_example_"
11
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 9) do
4
+ background color: :white
5
+ rect stroke_width: 5, stroke_color: :red
6
+ text str: (0..9).map{ |i| "Card #{i}\n2.5x3.5in" },
7
+ font: 'Sans 32', align: :center, valign: :middle,
8
+ height: :deck, width: :deck
9
+ save_sheet sprue: 'letter_poker_card_9up.yml',
10
+ prefix: "sprue_example_"
11
+ end
@@ -1,14 +1,14 @@
1
- # require 'squib'
2
- require_relative '../../lib/squib'
3
-
4
- # Per issue #334, sometimes Pango doesn't find the font file you want
5
- # Pango requires fonts to be installed on the system, but sometimes the
6
- # font name is not obvious. e.g. "Foo Regular" might be actually named "Foo"
7
- # Use these methods to debug this problem
8
-
9
- # Usually you would just run this method to see what fonts are installed
10
- # This is commented out to make our test cases
11
- # Squib.print_system_fonts
12
-
13
- Squib.system_fonts.include? 'Open Sans' # checks if we have Open Sans installed
14
- # Note: does nothing since it's just a check
1
+ # require 'squib'
2
+ require_relative '../../lib/squib'
3
+
4
+ # Per issue #334, sometimes Pango doesn't find the font file you want
5
+ # Pango requires fonts to be installed on the system, but sometimes the
6
+ # font name is not obvious. e.g. "Foo Regular" might be actually named "Foo"
7
+ # Use these methods to debug this problem
8
+
9
+ # Usually you would just run this method to see what fonts are installed
10
+ # This is commented out to make our test cases
11
+ # Squib.print_system_fonts
12
+
13
+ Squib.system_fonts.include? 'Open Sans' # checks if we have Open Sans installed
14
+ # Note: does nothing since it's just a check
@@ -1,128 +1,128 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new do
4
- background color: :white
5
- rect x: 0, y: 0, width: 825, height: 1125, stroke_width: 2.0
6
-
7
- embed_text = 'Take 11 :tool: and gain 2 :health:. Take <b>2</b> :tool: <i>and gain 3 :purse: if level 2.</i>'
8
- text(str: embed_text, font: 'Sans 7',
9
- x: 0, y: 0, width: 180, hint: :red,
10
- align: :left, ellipsize: false, justify: false) do |embed|
11
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
12
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
13
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
14
- end
15
-
16
- embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
17
- text(str: embed_text, font: 'Sans 7',
18
- x: 200, y: 0, width: 180, height: 300, valign: :middle,
19
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
20
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
21
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
22
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
23
- end
24
-
25
- embed_text = 'This :tool: aligns on the bottom properly. :purse:'
26
- text(str: embed_text, font: 'Sans 7',
27
- x: 400, y: 0, width: 180, height: 300, valign: :bottom,
28
- align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
29
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
30
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
31
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
32
- end
33
-
34
- embed_text = 'Yes, this wraps strangely. We are trying to determine the cause. These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
35
- text(str: embed_text, font: 'Sans 6',
36
- x: 600, y: 0, width: 180, height: 300, wrap: :word_char,
37
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
38
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
39
- end
40
-
41
- embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
42
- text(str: embed_text, font: 'Sans 7',
43
- x: 0, y: 320, width: 180, height: 300, valign: :bottom,
44
- align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
45
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
46
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
47
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
48
- end
49
-
50
- embed_text = 'Right-aligned works :tool: with :health: and :purse:'
51
- text(str: embed_text, font: 'Sans 7',
52
- x: 200, y: 320, width: 180, height: 300, valign: :bottom,
53
- align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
54
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
55
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
56
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
57
- end
58
-
59
- embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
60
- text(str: embed_text, font: 'Sans 7',
61
- x: 400, y: 320, width: 180, height: 300,
62
- align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
63
- embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
64
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
65
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
66
- end
67
-
68
- embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
69
- text(str: embed_text, font: 'Serif 6', markup: true,
70
- x: 600, y: 320, width: 180, height: 300,
71
- align: :center, hint: :magenta) do |embed|
72
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
73
- end
74
-
75
- embed_text = ':tool:' # JUST the icon
76
- text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
77
- font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
78
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
79
- end
80
-
81
- embed_text = ':purse:' # JUST the icon
82
- text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
83
- font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
84
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
85
- end
86
-
87
- embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
88
- text(str: embed_text, font: 'Sans Bold 8', stroke_width: 2,
89
- color: :red, stroke_color: :blue, dash: '3 3', align: :left,
90
- valign: :middle, x: 0, y: 700, width: 380, height: 150,
91
- hint: :magenta) do |embed|
92
- embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
93
- embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
94
- end
95
-
96
- embed_text = 'You can adjust the icon with dx and dy. Normal: :tool: Adjusted: :heart:'
97
- text(str: embed_text, font: 'Sans 6', x: 400, y: 640, width: 180,
98
- height: 300, hint: :magenta) do |embed|
99
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
100
- embed.svg key: ':heart:', width: 28, height: 28, dx: 10, dy: 10,
101
- file: 'glass-heart.svg'
102
- end
103
-
104
- embed_text = "Native sizes work too\n:tool:\n\n\n\n\n\n:shiny-purse:\n\n\n\n\n\n:tool2:"
105
- text(str: embed_text, font: 'Sans 6', x: 600, y: 640, width: 180,
106
- height: 475, hint: :magenta) do |embed|
107
- embed.svg key: ':tool:', width: :native, height: :native,
108
- file: 'spanner.svg'
109
- embed.svg key: ':tool2:', width: :native, height: :native,
110
- data: File.open('spanner.svg','r').read
111
- embed.png key: ':shiny-purse:', width: :native, height: :native,
112
- file: 'shiny-purse.png'
113
- end
114
-
115
- save_png prefix: 'embed_'
116
- end
117
-
118
- Squib::Deck.new(cards: 3) do
119
- background color: :white
120
- str = 'Take 1 :tool: and gain 2 :health:.'
121
- text(str: str, font: 'Sans', font_size: [6, 8.5, 11.5],
122
- x: 0, y: 0, width: 180, height: 300, valign: :bottom,
123
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
124
- embed.svg key: ':tool:', width: [28, 42, 56], height: [28, 42, 56], file: 'spanner.svg'
125
- embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'glass-heart.svg'
126
- end
127
- save_sheet prefix: 'embed_multisheet_', columns: 3
128
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new do
4
+ background color: :white
5
+ rect x: 0, y: 0, width: 825, height: 1125, stroke_width: 2.0
6
+
7
+ embed_text = 'Take 11 :tool: and gain 2 :health:. Take <b>2</b> :tool: <i>and gain 3 :purse: if level 2.</i>'
8
+ text(str: embed_text, font: 'Sans 7',
9
+ x: 0, y: 0, width: 180, hint: :red,
10
+ align: :left, ellipsize: false, justify: false) do |embed|
11
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
12
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
13
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
14
+ end
15
+
16
+ embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
17
+ text(str: embed_text, font: 'Sans 7',
18
+ x: 200, y: 0, width: 180, height: 300, valign: :middle,
19
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
20
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
21
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
22
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
23
+ end
24
+
25
+ embed_text = 'This :tool: aligns on the bottom properly. :purse:'
26
+ text(str: embed_text, font: 'Sans 7',
27
+ x: 400, y: 0, width: 180, height: 300, valign: :bottom,
28
+ align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
29
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
30
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
31
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
32
+ end
33
+
34
+ embed_text = 'Yes, this wraps strangely. We are trying to determine the cause. These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
35
+ text(str: embed_text, font: 'Sans 6',
36
+ x: 600, y: 0, width: 180, height: 300, wrap: :word_char,
37
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
38
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
39
+ end
40
+
41
+ embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
42
+ text(str: embed_text, font: 'Sans 7',
43
+ x: 0, y: 320, width: 180, height: 300, valign: :bottom,
44
+ align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
45
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
46
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
47
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
48
+ end
49
+
50
+ embed_text = 'Right-aligned works :tool: with :health: and :purse:'
51
+ text(str: embed_text, font: 'Sans 7',
52
+ x: 200, y: 320, width: 180, height: 300, valign: :bottom,
53
+ align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
54
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
55
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
56
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
57
+ end
58
+
59
+ embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
60
+ text(str: embed_text, font: 'Sans 7',
61
+ x: 400, y: 320, width: 180, height: 300,
62
+ align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
63
+ embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
64
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
65
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
66
+ end
67
+
68
+ embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
69
+ text(str: embed_text, font: 'Serif 6', markup: true,
70
+ x: 600, y: 320, width: 180, height: 300,
71
+ align: :center, hint: :magenta) do |embed|
72
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
73
+ end
74
+
75
+ embed_text = ':tool:' # JUST the icon
76
+ text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
77
+ font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
78
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
79
+ end
80
+
81
+ embed_text = ':purse:' # JUST the icon
82
+ text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
83
+ font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
84
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
85
+ end
86
+
87
+ embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
88
+ text(str: embed_text, font: 'Sans Bold 8', stroke_width: 2,
89
+ color: :red, stroke_color: :blue, dash: '3 3', align: :left,
90
+ valign: :middle, x: 0, y: 700, width: 380, height: 150,
91
+ hint: :magenta) do |embed|
92
+ embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
93
+ embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
94
+ end
95
+
96
+ embed_text = 'You can adjust the icon with dx and dy. Normal: :tool: Adjusted: :heart:'
97
+ text(str: embed_text, font: 'Sans 6', x: 400, y: 640, width: 180,
98
+ height: 300, hint: :magenta) do |embed|
99
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
100
+ embed.svg key: ':heart:', width: 28, height: 28, dx: 10, dy: 10,
101
+ file: 'glass-heart.svg'
102
+ end
103
+
104
+ embed_text = "Native sizes work too\n:tool:\n\n\n\n\n\n:shiny-purse:\n\n\n\n\n\n:tool2:"
105
+ text(str: embed_text, font: 'Sans 6', x: 600, y: 640, width: 180,
106
+ height: 475, hint: :magenta) do |embed|
107
+ embed.svg key: ':tool:', width: :native, height: :native,
108
+ file: 'spanner.svg'
109
+ embed.svg key: ':tool2:', width: :native, height: :native,
110
+ data: File.open('spanner.svg','r').read
111
+ embed.png key: ':shiny-purse:', width: :native, height: :native,
112
+ file: 'shiny-purse.png'
113
+ end
114
+
115
+ save_png prefix: 'embed_'
116
+ end
117
+
118
+ Squib::Deck.new(cards: 3) do
119
+ background color: :white
120
+ str = 'Take 1 :tool: and gain 2 :health:.'
121
+ text(str: str, font: 'Sans', font_size: [6, 8.5, 11.5],
122
+ x: 0, y: 0, width: 180, height: 300, valign: :bottom,
123
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
124
+ embed.svg key: ':tool:', width: [28, 42, 56], height: [28, 42, 56], file: 'spanner.svg'
125
+ embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'glass-heart.svg'
126
+ end
127
+ save_sheet prefix: 'embed_multisheet_', columns: 3
128
+ end
@@ -1,52 +1,52 @@
1
- require 'squib'
2
- require 'squib/sample_helpers'
3
-
4
- Squib::Deck.new(width: 1000, height: 1450) do
5
- draw_graph_paper width, height
6
-
7
- sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
8
- text font: 'Arial bold italic 11', str: 'Bold and italic!', x: x, y: y - 50
9
- text font: 'Arial weight=300 11', str: 'Light bold!', x: x, y: y
10
- text font: 'Times New Roman, 11', str: 'Times New Roman', x: x, y: y + 50
11
- text font: 'NoSuchFont,Arial 11', str: 'Arial Backup', x: x, y: y + 100
12
- end
13
-
14
- sample 'Specify width and height to see a text box. Also: set "hint" to see the extents of your text box' do |x, y|
15
- text str: 'This has fixed width and height.', x: x, y: y,
16
- hint: :red, width: 300, height: 100, font: 'Serif bold 8'
17
- end
18
-
19
- sample 'If you specify the width only, the text will ellipsize.' do |x, y|
20
- text str: 'The meaning of life is 42', x: x - 50, y: y,
21
- hint: :red, width: 350, font: 'Serif bold 7'
22
- end
23
-
24
- sample 'If you specify ellipsize: :autosize, the font size will autoscale.' do |x, y|
25
- text str: 'This text doeas not fit with font size 7. It is autoscaled to the largest size that fits instead.', x: x - 50, y: y,
26
- hint: :red, width: 350, height: 100, ellipsize: :autoscale, font: 'Serif bold 7'
27
- end
28
-
29
- sample 'If you specify the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
30
- text str: 'This has fixed width, but not fixed height.', x: x, y: y,
31
- hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
32
- end
33
-
34
- sample 'The text method returns the ink extents of each card\'s rendered text. So you can custom-fit a shape around it.' do |x, y|
35
- ['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
36
- text_y = y + i * 50
37
- extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
38
-
39
- # Extents come back as an array of hashes, which can get split out like this
40
- text_width = extents[0][:width]
41
- text_height = extents[0][:height]
42
- rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
43
- stroke_color: :purple, stroke_width: 3
44
- end
45
- end
46
-
47
- sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
48
- text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
49
- end
50
-
51
- save_png prefix: '_text_'
52
- end
1
+ require 'squib'
2
+ require 'squib/sample_helpers'
3
+
4
+ Squib::Deck.new(width: 1000, height: 1450) do
5
+ draw_graph_paper width, height
6
+
7
+ sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
8
+ text font: 'Arial bold italic 11', str: 'Bold and italic!', x: x, y: y - 50
9
+ text font: 'Arial weight=300 11', str: 'Light bold!', x: x, y: y
10
+ text font: 'Times New Roman, 11', str: 'Times New Roman', x: x, y: y + 50
11
+ text font: 'NoSuchFont,Arial 11', str: 'Arial Backup', x: x, y: y + 100
12
+ end
13
+
14
+ sample 'Specify width and height to see a text box. Also: set "hint" to see the extents of your text box' do |x, y|
15
+ text str: 'This has fixed width and height.', x: x, y: y,
16
+ hint: :red, width: 300, height: 100, font: 'Serif bold 8'
17
+ end
18
+
19
+ sample 'If you specify the width only, the text will ellipsize.' do |x, y|
20
+ text str: 'The meaning of life is 42', x: x - 50, y: y,
21
+ hint: :red, width: 350, font: 'Serif bold 7'
22
+ end
23
+
24
+ sample 'If you specify ellipsize: :autosize, the font size will autoscale.' do |x, y|
25
+ text str: 'This text doeas not fit with font size 7. It is autoscaled to the largest size that fits instead.', x: x - 50, y: y,
26
+ hint: :red, width: 350, height: 100, ellipsize: :autoscale, font: 'Serif bold 7'
27
+ end
28
+
29
+ sample 'If you specify the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
30
+ text str: 'This has fixed width, but not fixed height.', x: x, y: y,
31
+ hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
32
+ end
33
+
34
+ sample 'The text method returns the ink extents of each card\'s rendered text. So you can custom-fit a shape around it.' do |x, y|
35
+ ['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
36
+ text_y = y + i * 50
37
+ extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
38
+
39
+ # Extents come back as an array of hashes, which can get split out like this
40
+ text_width = extents[0][:width]
41
+ text_height = extents[0][:height]
42
+ rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
43
+ stroke_color: :purple, stroke_width: 3
44
+ end
45
+ end
46
+
47
+ sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
48
+ text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
49
+ end
50
+
51
+ save_png prefix: '_text_'
52
+ end