squib 0.14.2 → 0.14.3.pre1

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 (163) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +41 -41
  3. data/.travis.yml +19 -19
  4. data/CHANGELOG.md +366 -357
  5. data/CONTRIBUTING.md +40 -40
  6. data/Gemfile +2 -2
  7. data/LICENSE.txt +22 -22
  8. data/README.md +121 -121
  9. data/RELEASE TODO.md +21 -21
  10. data/Rakefile +48 -48
  11. data/appveyor.yml +24 -24
  12. data/bin/squib +4 -4
  13. data/lib/squib.rb +32 -32
  14. data/lib/squib/api/background.rb +15 -15
  15. data/lib/squib/api/data.rb +137 -137
  16. data/lib/squib/api/groups.rb +54 -54
  17. data/lib/squib/api/image.rb +49 -49
  18. data/lib/squib/api/save.rb +83 -83
  19. data/lib/squib/api/settings.rb +21 -21
  20. data/lib/squib/api/shapes.rb +124 -124
  21. data/lib/squib/api/text.rb +25 -25
  22. data/lib/squib/api/text_embed.rb +71 -71
  23. data/lib/squib/api/units.rb +27 -27
  24. data/lib/squib/args/arg_loader.rb +126 -126
  25. data/lib/squib/args/box.rb +55 -55
  26. data/lib/squib/args/card_range.rb +32 -32
  27. data/lib/squib/args/color_validator.rb +12 -12
  28. data/lib/squib/args/coords.rb +35 -35
  29. data/lib/squib/args/csv_opts.rb +25 -25
  30. data/lib/squib/args/dir_validator.rb +16 -16
  31. data/lib/squib/args/draw.rb +92 -92
  32. data/lib/squib/args/embed_adjust.rb +25 -25
  33. data/lib/squib/args/embed_key.rb +17 -17
  34. data/lib/squib/args/hand_special.rb +37 -37
  35. data/lib/squib/args/import.rb +40 -40
  36. data/lib/squib/args/input_file.rb +37 -37
  37. data/lib/squib/args/paint.rb +44 -44
  38. data/lib/squib/args/paragraph.rb +116 -116
  39. data/lib/squib/args/save_batch.rb +63 -63
  40. data/lib/squib/args/scale_box.rb +53 -53
  41. data/lib/squib/args/sheet.rb +172 -172
  42. data/lib/squib/args/showcase_special.rb +38 -38
  43. data/lib/squib/args/sprue_file.rb +44 -44
  44. data/lib/squib/args/svg_special.rb +37 -37
  45. data/lib/squib/args/transform.rb +61 -61
  46. data/lib/squib/args/typographer.rb +119 -119
  47. data/lib/squib/args/unit_conversion.rb +29 -29
  48. data/lib/squib/builtin/layouts/economy.yml +85 -85
  49. data/lib/squib/builtin/layouts/fantasy.yml +101 -101
  50. data/lib/squib/builtin/layouts/hand.yml +62 -62
  51. data/lib/squib/builtin/layouts/party.yml +94 -94
  52. data/lib/squib/builtin/layouts/playing-card.yml +35 -35
  53. data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
  54. data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
  55. data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
  56. data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
  57. data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
  58. data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
  59. data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
  60. data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
  61. data/lib/squib/builtin/projects/advanced/config.yml +53 -49
  62. data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
  63. data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
  64. data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
  65. data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
  66. data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
  67. data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
  68. data/lib/squib/builtin/projects/basic/.gitignore +4 -4
  69. data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
  70. data/lib/squib/builtin/projects/basic/Gemfile +3 -3
  71. data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
  72. data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
  73. data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
  74. data/lib/squib/builtin/projects/basic/RULES.md +21 -21
  75. data/lib/squib/builtin/projects/basic/Rakefile +7 -7
  76. data/lib/squib/builtin/projects/basic/config.yml +53 -49
  77. data/lib/squib/builtin/projects/basic/deck.rb +6 -6
  78. data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
  79. data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
  80. data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
  81. data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
  82. data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
  83. data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
  84. data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
  85. data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
  86. data/lib/squib/card.rb +75 -75
  87. data/lib/squib/commands/cli.rb +39 -39
  88. data/lib/squib/commands/data/template_option.rb +109 -109
  89. data/lib/squib/commands/make_sprue.rb +275 -275
  90. data/lib/squib/commands/new.rb +77 -77
  91. data/lib/squib/conf.rb +144 -139
  92. data/lib/squib/constants.rb +17 -17
  93. data/lib/squib/deck.rb +116 -116
  94. data/lib/squib/graphics/background.rb +14 -14
  95. data/lib/squib/graphics/cairo_context_wrapper.rb +113 -113
  96. data/lib/squib/graphics/embedding_utils.rb +28 -28
  97. data/lib/squib/graphics/gradient_regex.rb +47 -47
  98. data/lib/squib/graphics/hand.rb +42 -42
  99. data/lib/squib/graphics/image.rb +129 -108
  100. data/lib/squib/graphics/save_doc.rb +61 -61
  101. data/lib/squib/graphics/save_images.rb +52 -52
  102. data/lib/squib/graphics/save_pdf.rb +90 -90
  103. data/lib/squib/graphics/save_sprue.rb +204 -204
  104. data/lib/squib/graphics/shapes.rb +143 -143
  105. data/lib/squib/graphics/showcase.rb +85 -85
  106. data/lib/squib/graphics/text.rb +174 -174
  107. data/lib/squib/import/data_frame.rb +108 -108
  108. data/lib/squib/layout_parser.rb +138 -138
  109. data/lib/squib/progress.rb +38 -38
  110. data/lib/squib/sample_helpers.rb +34 -34
  111. data/lib/squib/sprues/crop_line.rb +28 -28
  112. data/lib/squib/sprues/crop_line_dash.rb +35 -35
  113. data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
  114. data/lib/squib/sprues/sprue.rb +203 -203
  115. data/lib/squib/sprues/sprue_schema.rb +48 -48
  116. data/lib/squib/version.rb +10 -10
  117. data/samples/autoscale_font/_autoscale_font.rb +29 -29
  118. data/samples/backend/_backend.rb +26 -26
  119. data/samples/basic.rb +19 -19
  120. data/samples/bug256/_bug256.rb +13 -0
  121. data/samples/build_groups/build_groups.rb +36 -36
  122. data/samples/colors/_colors.rb +38 -38
  123. data/samples/colors/_gradients.rb +34 -34
  124. data/samples/config/config_text_markup.rb +20 -20
  125. data/samples/config/custom_config.rb +18 -18
  126. data/samples/data/_csv.rb +33 -33
  127. data/samples/data/_excel.rb +55 -55
  128. data/samples/data/_yaml.rb +12 -12
  129. data/samples/hello_world.rb +6 -6
  130. data/samples/images/_cairo_access.rb +39 -39
  131. data/samples/images/_images.rb +104 -104
  132. data/samples/images/_more_load_images.rb +102 -102
  133. data/samples/intro/01_hello.rb +8 -8
  134. data/samples/intro/02_options.rb +14 -14
  135. data/samples/intro/03_layout.rb +11 -11
  136. data/samples/intro/04_arrays.rb +15 -15
  137. data/samples/intro/05_excel.rb +14 -14
  138. data/samples/layouts/builtin_layouts.rb +97 -97
  139. data/samples/layouts/layouts.rb +71 -71
  140. data/samples/project/src/characters.rb +8 -8
  141. data/samples/project/src/skills.rb +7 -7
  142. data/samples/proofs/_tgc_proofs.rb +16 -16
  143. data/samples/ranges/_ranges.rb +64 -64
  144. data/samples/saves/_hand.rb +23 -23
  145. data/samples/saves/_portrait_landscape.rb +23 -23
  146. data/samples/saves/_save_pdf.rb +29 -29
  147. data/samples/saves/_saves.rb +51 -51
  148. data/samples/saves/_showcase.rb +25 -25
  149. data/samples/shapes/_draw_shapes.rb +60 -60
  150. data/samples/shapes/_proofs.rb +22 -22
  151. data/samples/sprues/_advanced_sprues.rb +24 -24
  152. data/samples/sprues/_builtin_sprues.rb +21 -21
  153. data/samples/sprues/_fold_sheet.rb +27 -27
  154. data/samples/sprues/_hex_tiles.rb +15 -15
  155. data/samples/sprues/_mints.rb +11 -11
  156. data/samples/sprues/_sprue_example.rb +11 -11
  157. data/samples/text/_embed_text.rb +128 -128
  158. data/samples/text/_text.rb +47 -47
  159. data/samples/text/_text_options.rb +102 -102
  160. data/samples/text/bug134.rb +14 -14
  161. data/samples/units/_units.rb +32 -32
  162. data/squib.gemspec +52 -52
  163. metadata +51 -48
@@ -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,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,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,47 +1,47 @@
1
- require 'squib'
2
- require 'squib/sample_helpers'
3
-
4
- Squib::Deck.new(width: 1000, height: 1250) 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 the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
25
- text str: 'This has fixed width, but not fixed height.', x: x, y: y,
26
- hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
27
- end
28
-
29
- 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|
30
- ['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
31
- text_y = y + i * 50
32
- extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
33
-
34
- # Extents come back as an array of hashes, which can get split out like this
35
- text_width = extents[0][:width]
36
- text_height = extents[0][:height]
37
- rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
38
- stroke_color: :purple, stroke_width: 3
39
- end
40
- end
41
-
42
- sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
43
- text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
44
- end
45
-
46
- save_png prefix: '_text_'
47
- end
1
+ require 'squib'
2
+ require 'squib/sample_helpers'
3
+
4
+ Squib::Deck.new(width: 1000, height: 1250) 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 the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
25
+ text str: 'This has fixed width, but not fixed height.', x: x, y: y,
26
+ hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
27
+ end
28
+
29
+ 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|
30
+ ['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
31
+ text_y = y + i * 50
32
+ extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
33
+
34
+ # Extents come back as an array of hashes, which can get split out like this
35
+ text_width = extents[0][:width]
36
+ text_height = extents[0][:height]
37
+ rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
38
+ stroke_color: :purple, stroke_width: 3
39
+ end
40
+ end
41
+
42
+ sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
43
+ text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
44
+ end
45
+
46
+ save_png prefix: '_text_'
47
+ end
@@ -1,102 +1,102 @@
1
- # encoding: UTF-8
2
- require 'squib'
3
-
4
- data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
5
- 'level' => [1, 2, 3] }
6
- longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
7
-
8
- Squib::Deck.new(width: 825, height: 1125, cards: 3) do
9
- background color: :white
10
- rect x: 15, y: 15, width: 795, height: 1095, x_radius: 50, y_radius: 50
11
- rect x: 30, y: 30, width: 128, height: 128, x_radius: 25, y_radius: 25
12
-
13
- # Arrays are rendered over each card
14
- text str: data['name'], x: 250, y: 55, font: 'Arial weight=900 18'
15
- text str: data['level'], x: 65, y: 40, font: 'Arial 24', color: :burnt_orange
16
-
17
- text str: 'Font strings are expressive!', x:65, y: 200,
18
- font: 'Impact bold italic 12'
19
-
20
- text str: 'Font strings are expressive!', x:65, y: 300,
21
- font: 'Arial,Verdana weight=900 style=oblique 12'
22
-
23
- text str: 'Font string sizes can be overridden per card.', x: 65, y: 350,
24
- font: 'Impact 12', font_size: [5, 7, 8]
25
-
26
- text str: 'This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint',
27
- hint: :red,
28
- x: 65, y: 400,
29
- width: 300, height: 125,
30
- align: :center, valign: 'MIDDLE', # these can be specified with case-insenstive strings too
31
- font: 'Serif 5'
32
-
33
- extents = text str: 'Ink extent return value',
34
- x: 65, y: 550,
35
- font: 'Sans Bold', font_size: [5, 7, 8]
36
- margin = 10
37
- # Extents come back as an array of hashes, which can get split out like this
38
- ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
39
- hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
40
- rect x: 65 - margin / 2, y: 550 - margin / 2,
41
- width: ws, height: hs,
42
- radius: 10, stroke_color: :black
43
-
44
- # If width & height are defined and the text will overflow the box, we can ellipsize.
45
- text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42",
46
- hint: :green, font: 'Arial 7',
47
- x: 450, y: 400,
48
- width: 280, height: 180,
49
- ellipsize: true
50
-
51
- # Text hints are guides for showing you how your text boxes are laid out exactly
52
- hint text: :cyan
53
- set font: 'Serif 7' # Impacts all future text calls (unless they specify differently)
54
- text str: 'Text hints & fonts are globally togglable!', x: 65, y: 625
55
- set font: :default # back to Squib-wide default
56
- hint text: :off
57
- text str: 'See? No hint here.',
58
- x: 565, y: 625,
59
- font: 'Arial 7'
60
-
61
- # Text can be rotated, in radians, about the upper-left corner of the text box.
62
- text str: 'Rotated',
63
- x: 565, y: 675, angle: 0.2,
64
- font: 'Arial 6', hint: :red
65
-
66
- # Text can be justified, and have newlines
67
- text str: longtext, font: 'Arial 5',
68
- x: 65, y: 700,
69
- width: '1.5in', height: inches(1),
70
- justify: true, spacing: -6
71
-
72
- # Here's how you embed images into text.
73
- # Pass a block to the method call and use the given context
74
- embed_text = 'Embedded icons! Take 1 :tool: and gain 2:health:. If Level 2, take 2 :tool:'
75
- text(str: embed_text, font: 'Sans 6',
76
- x: '1.8in', y: '2.5in', width: '0.85in',
77
- align: :left, ellipsize: false) do |embed|
78
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
79
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
80
- end
81
-
82
- text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
83
- color: :green, stroke_width: 2.0, stroke_color: :blue,
84
- x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 9', markup: true
85
-
86
- text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
87
- color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
88
- x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 9', markup: true
89
-
90
- text str: 'Dotted',
91
- color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
92
- x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 9', markup: true
93
- #
94
- text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
95
- markup: true,
96
- x: 50, y: 1000,
97
- width: 750, height: 100,
98
- valign: :bottom,
99
- font: 'Serif 6', hint: :cyan
100
-
101
- save prefix: 'text_options_', format: :png
102
- end
1
+ # encoding: UTF-8
2
+ require 'squib'
3
+
4
+ data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
5
+ 'level' => [1, 2, 3] }
6
+ longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
7
+
8
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
9
+ background color: :white
10
+ rect x: 15, y: 15, width: 795, height: 1095, x_radius: 50, y_radius: 50
11
+ rect x: 30, y: 30, width: 128, height: 128, x_radius: 25, y_radius: 25
12
+
13
+ # Arrays are rendered over each card
14
+ text str: data['name'], x: 250, y: 55, font: 'Arial weight=900 18'
15
+ text str: data['level'], x: 65, y: 40, font: 'Arial 24', color: :burnt_orange
16
+
17
+ text str: 'Font strings are expressive!', x:65, y: 200,
18
+ font: 'Impact bold italic 12'
19
+
20
+ text str: 'Font strings are expressive!', x:65, y: 300,
21
+ font: 'Arial,Verdana weight=900 style=oblique 12'
22
+
23
+ text str: 'Font string sizes can be overridden per card.', x: 65, y: 350,
24
+ font: 'Impact 12', font_size: [5, 7, 8]
25
+
26
+ text str: 'This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint',
27
+ hint: :red,
28
+ x: 65, y: 400,
29
+ width: 300, height: 125,
30
+ align: :center, valign: 'MIDDLE', # these can be specified with case-insenstive strings too
31
+ font: 'Serif 5'
32
+
33
+ extents = text str: 'Ink extent return value',
34
+ x: 65, y: 550,
35
+ font: 'Sans Bold', font_size: [5, 7, 8]
36
+ margin = 10
37
+ # Extents come back as an array of hashes, which can get split out like this
38
+ ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
39
+ hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
40
+ rect x: 65 - margin / 2, y: 550 - margin / 2,
41
+ width: ws, height: hs,
42
+ radius: 10, stroke_color: :black
43
+
44
+ # If width & height are defined and the text will overflow the box, we can ellipsize.
45
+ text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42",
46
+ hint: :green, font: 'Arial 7',
47
+ x: 450, y: 400,
48
+ width: 280, height: 180,
49
+ ellipsize: true
50
+
51
+ # Text hints are guides for showing you how your text boxes are laid out exactly
52
+ hint text: :cyan
53
+ set font: 'Serif 7' # Impacts all future text calls (unless they specify differently)
54
+ text str: 'Text hints & fonts are globally togglable!', x: 65, y: 625
55
+ set font: :default # back to Squib-wide default
56
+ hint text: :off
57
+ text str: 'See? No hint here.',
58
+ x: 565, y: 625,
59
+ font: 'Arial 7'
60
+
61
+ # Text can be rotated, in radians, about the upper-left corner of the text box.
62
+ text str: 'Rotated',
63
+ x: 565, y: 675, angle: 0.2,
64
+ font: 'Arial 6', hint: :red
65
+
66
+ # Text can be justified, and have newlines
67
+ text str: longtext, font: 'Arial 5',
68
+ x: 65, y: 700,
69
+ width: '1.5in', height: inches(1),
70
+ justify: true, spacing: -6
71
+
72
+ # Here's how you embed images into text.
73
+ # Pass a block to the method call and use the given context
74
+ embed_text = 'Embedded icons! Take 1 :tool: and gain 2:health:. If Level 2, take 2 :tool:'
75
+ text(str: embed_text, font: 'Sans 6',
76
+ x: '1.8in', y: '2.5in', width: '0.85in',
77
+ align: :left, ellipsize: false) do |embed|
78
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
79
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
80
+ end
81
+
82
+ text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
83
+ color: :green, stroke_width: 2.0, stroke_color: :blue,
84
+ x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 9', markup: true
85
+
86
+ text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
87
+ color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
88
+ x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 9', markup: true
89
+
90
+ text str: 'Dotted',
91
+ color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
92
+ x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 9', markup: true
93
+ #
94
+ text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
95
+ markup: true,
96
+ x: 50, y: 1000,
97
+ width: 750, height: 100,
98
+ valign: :bottom,
99
+ font: 'Serif 6', hint: :cyan
100
+
101
+ save prefix: 'text_options_', format: :png
102
+ end