squib 0.15.2 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +41 -41
  3. data/.travis.yml +17 -17
  4. data/CHANGELOG.md +400 -395
  5. data/CONTRIBUTING.md +40 -40
  6. data/Dockerfile +25 -25
  7. data/Gemfile +2 -2
  8. data/LICENSE.txt +22 -22
  9. data/README.md +145 -145
  10. data/RELEASE TODO.md +21 -21
  11. data/Rakefile +48 -48
  12. data/appveyor.yml +25 -25
  13. data/bin/squib +4 -4
  14. data/lib/squib.rb +32 -32
  15. data/lib/squib/api/background.rb +15 -15
  16. data/lib/squib/api/data.rb +137 -137
  17. data/lib/squib/api/groups.rb +54 -54
  18. data/lib/squib/api/image.rb +49 -49
  19. data/lib/squib/api/save.rb +83 -83
  20. data/lib/squib/api/settings.rb +21 -21
  21. data/lib/squib/api/shapes.rb +124 -124
  22. data/lib/squib/api/text.rb +25 -25
  23. data/lib/squib/api/text_embed.rb +71 -71
  24. data/lib/squib/api/units.rb +27 -27
  25. data/lib/squib/args/arg_loader.rb +126 -126
  26. data/lib/squib/args/box.rb +55 -55
  27. data/lib/squib/args/card_range.rb +32 -32
  28. data/lib/squib/args/color_validator.rb +12 -12
  29. data/lib/squib/args/coords.rb +35 -35
  30. data/lib/squib/args/csv_opts.rb +25 -25
  31. data/lib/squib/args/dir_validator.rb +16 -16
  32. data/lib/squib/args/draw.rb +92 -92
  33. data/lib/squib/args/embed_adjust.rb +25 -25
  34. data/lib/squib/args/embed_key.rb +17 -17
  35. data/lib/squib/args/hand_special.rb +37 -37
  36. data/lib/squib/args/import.rb +40 -40
  37. data/lib/squib/args/input_file.rb +37 -37
  38. data/lib/squib/args/paint.rb +44 -44
  39. data/lib/squib/args/paragraph.rb +116 -116
  40. data/lib/squib/args/save_batch.rb +63 -63
  41. data/lib/squib/args/scale_box.rb +53 -53
  42. data/lib/squib/args/sheet.rb +172 -172
  43. data/lib/squib/args/showcase_special.rb +41 -41
  44. data/lib/squib/args/sprue_file.rb +44 -44
  45. data/lib/squib/args/svg_special.rb +37 -37
  46. data/lib/squib/args/transform.rb +61 -61
  47. data/lib/squib/args/typographer.rb +119 -119
  48. data/lib/squib/args/unit_conversion.rb +29 -29
  49. data/lib/squib/builtin/layouts/economy.yml +85 -85
  50. data/lib/squib/builtin/layouts/fantasy.yml +101 -101
  51. data/lib/squib/builtin/layouts/hand.yml +62 -62
  52. data/lib/squib/builtin/layouts/party.yml +94 -94
  53. data/lib/squib/builtin/layouts/playing-card.yml +35 -35
  54. data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
  55. data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
  56. data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
  57. data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
  58. data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
  59. data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
  60. data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
  61. data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
  62. data/lib/squib/builtin/projects/advanced/config.yml +49 -49
  63. data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
  64. data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
  65. data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
  66. data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
  67. data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
  68. data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
  69. data/lib/squib/builtin/projects/basic/.gitignore +4 -4
  70. data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
  71. data/lib/squib/builtin/projects/basic/Gemfile +3 -3
  72. data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
  73. data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
  74. data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
  75. data/lib/squib/builtin/projects/basic/RULES.md +21 -21
  76. data/lib/squib/builtin/projects/basic/Rakefile +7 -7
  77. data/lib/squib/builtin/projects/basic/config.yml +49 -49
  78. data/lib/squib/builtin/projects/basic/deck.rb +6 -6
  79. data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
  80. data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
  81. data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
  82. data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
  83. data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
  84. data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
  85. data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
  86. data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
  87. data/lib/squib/card.rb +75 -75
  88. data/lib/squib/commands/cli.rb +39 -39
  89. data/lib/squib/commands/data/template_option.rb +109 -109
  90. data/lib/squib/commands/make_sprue.rb +277 -277
  91. data/lib/squib/commands/new.rb +77 -77
  92. data/lib/squib/conf.rb +139 -139
  93. data/lib/squib/constants.rb +17 -17
  94. data/lib/squib/deck.rb +116 -116
  95. data/lib/squib/graphics/background.rb +14 -14
  96. data/lib/squib/graphics/cairo_context_wrapper.rb +113 -113
  97. data/lib/squib/graphics/embedding_utils.rb +28 -28
  98. data/lib/squib/graphics/gradient_regex.rb +47 -47
  99. data/lib/squib/graphics/hand.rb +42 -42
  100. data/lib/squib/graphics/image.rb +123 -123
  101. data/lib/squib/graphics/save_doc.rb +61 -61
  102. data/lib/squib/graphics/save_images.rb +52 -52
  103. data/lib/squib/graphics/save_pdf.rb +90 -90
  104. data/lib/squib/graphics/save_sprue.rb +219 -219
  105. data/lib/squib/graphics/shapes.rb +143 -143
  106. data/lib/squib/graphics/showcase.rb +85 -85
  107. data/lib/squib/graphics/text.rb +174 -174
  108. data/lib/squib/import/data_frame.rb +108 -108
  109. data/lib/squib/layout_parser.rb +138 -138
  110. data/lib/squib/progress.rb +38 -38
  111. data/lib/squib/sample_helpers.rb +34 -34
  112. data/lib/squib/sprues/crop_line.rb +28 -28
  113. data/lib/squib/sprues/crop_line_dash.rb +35 -35
  114. data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
  115. data/lib/squib/sprues/sprue.rb +206 -206
  116. data/lib/squib/sprues/sprue_schema.rb +50 -50
  117. data/lib/squib/version.rb +10 -10
  118. data/samples/autoscale_font/_autoscale_font.rb +29 -29
  119. data/samples/backend/_backend.rb +26 -26
  120. data/samples/basic.rb +19 -19
  121. data/samples/build_groups/build_groups.rb +36 -36
  122. data/samples/colors/_colors.rb +44 -44
  123. data/samples/colors/_gradients.rb +34 -34
  124. data/samples/colors/_switch_color.rb +33 -33
  125. data/samples/config/config_text_markup.rb +20 -20
  126. data/samples/config/custom_config.rb +18 -18
  127. data/samples/data/_csv.rb +33 -33
  128. data/samples/data/_excel.rb +55 -55
  129. data/samples/data/_yaml.rb +12 -12
  130. data/samples/hello_world.rb +6 -6
  131. data/samples/images/_cairo_access.rb +39 -39
  132. data/samples/images/_images.rb +104 -104
  133. data/samples/images/_more_load_images.rb +102 -102
  134. data/samples/intro/01_hello.rb +8 -8
  135. data/samples/intro/02_options.rb +14 -14
  136. data/samples/intro/03_layout.rb +11 -11
  137. data/samples/intro/04_arrays.rb +15 -15
  138. data/samples/intro/05_excel.rb +14 -14
  139. data/samples/layouts/builtin_layouts.rb +97 -97
  140. data/samples/layouts/layouts.rb +71 -71
  141. data/samples/project/src/characters.rb +8 -8
  142. data/samples/project/src/skills.rb +7 -7
  143. data/samples/proofs/_tgc_proofs.rb +16 -16
  144. data/samples/ranges/_ranges.rb +64 -64
  145. data/samples/saves/_hand.rb +23 -23
  146. data/samples/saves/_portrait_landscape.rb +23 -23
  147. data/samples/saves/_save_filenames.rb +24 -24
  148. data/samples/saves/_save_pdf.rb +29 -29
  149. data/samples/saves/_saves.rb +51 -51
  150. data/samples/saves/_showcase.rb +25 -25
  151. data/samples/shapes/_draw_shapes.rb +60 -60
  152. data/samples/shapes/_proofs.rb +22 -22
  153. data/samples/sprues/_advanced_sprues.rb +25 -25
  154. data/samples/sprues/_builtin_sprues.rb +21 -21
  155. data/samples/sprues/_fold_sheet.rb +27 -27
  156. data/samples/sprues/_hex_tiles.rb +15 -15
  157. data/samples/sprues/_mints.rb +11 -11
  158. data/samples/sprues/_sprue_example.rb +11 -11
  159. data/samples/text/_embed_text.rb +128 -128
  160. data/samples/text/_text.rb +47 -47
  161. data/samples/text/_text_options.rb +102 -102
  162. data/samples/text/bug134.rb +14 -14
  163. data/samples/units/_units.rb +32 -32
  164. data/squib.gemspec +52 -52
  165. metadata +62 -63
@@ -1,27 +1,27 @@
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
- save_sheet prefix: 'foldable_',
26
- sprue: 'letter_poker_foldable_8up.yml'
27
- 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
+ save_sheet prefix: 'foldable_',
26
+ sprue: 'letter_poker_foldable_8up.yml'
27
+ 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,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