squib 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +162 -133
  3. data/Gemfile +4 -4
  4. data/README.md +630 -550
  5. data/RELEASE TODO.md +18 -18
  6. data/Rakefile +99 -99
  7. data/lib/squib.rb +32 -32
  8. data/lib/squib/api/background.rb +20 -19
  9. data/lib/squib/api/data.rb +100 -99
  10. data/lib/squib/api/image.rb +90 -76
  11. data/lib/squib/api/save.rb +149 -103
  12. data/lib/squib/api/settings.rb +35 -37
  13. data/lib/squib/api/shapes.rb +230 -228
  14. data/lib/squib/api/text.rb +65 -66
  15. data/lib/squib/api/text_embed.rb +96 -66
  16. data/lib/squib/args/arg_loader.rb +138 -0
  17. data/lib/squib/args/box.rb +55 -0
  18. data/lib/squib/args/card_range.rb +32 -0
  19. data/lib/squib/args/color_validator.rb +12 -0
  20. data/lib/squib/args/coords.rb +33 -0
  21. data/lib/squib/args/dir_validator.rb +16 -0
  22. data/lib/squib/args/draw.rb +92 -0
  23. data/lib/squib/args/embed_adjust.rb +25 -0
  24. data/lib/squib/args/embed_key.rb +17 -0
  25. data/lib/squib/args/hand_special.rb +37 -0
  26. data/lib/squib/args/input_file.rb +37 -0
  27. data/lib/squib/args/paint.rb +44 -0
  28. data/lib/squib/args/paragraph.rb +115 -0
  29. data/lib/squib/args/save_batch.rb +60 -0
  30. data/lib/squib/args/scale_box.rb +53 -0
  31. data/lib/squib/args/sheet.rb +72 -0
  32. data/lib/squib/args/showcase_special.rb +38 -0
  33. data/lib/squib/args/svg_special.rb +37 -0
  34. data/lib/squib/args/transform.rb +25 -0
  35. data/lib/squib/args/typographer.rb +117 -117
  36. data/lib/squib/card.rb +67 -67
  37. data/lib/squib/conf.rb +117 -111
  38. data/lib/squib/constants.rb +178 -178
  39. data/lib/squib/deck.rb +113 -111
  40. data/lib/squib/graphics/cairo_context_wrapper.rb +99 -53
  41. data/lib/squib/graphics/gradient_regex.rb +46 -46
  42. data/lib/squib/graphics/hand.rb +42 -43
  43. data/lib/squib/graphics/image.rb +76 -73
  44. data/lib/squib/graphics/save_doc.rb +103 -137
  45. data/lib/squib/graphics/save_images.rb +33 -33
  46. data/lib/squib/graphics/shapes.rb +119 -152
  47. data/lib/squib/graphics/showcase.rb +85 -88
  48. data/lib/squib/graphics/text.rb +176 -216
  49. data/lib/squib/layout_parser.rb +91 -89
  50. data/lib/squib/layouts/economy.yml +85 -0
  51. data/lib/squib/layouts/fantasy.yml +101 -0
  52. data/lib/squib/layouts/hand.yml +62 -46
  53. data/lib/squib/layouts/playing-card.yml +35 -18
  54. data/lib/squib/project_template/config.yml +45 -40
  55. data/lib/squib/version.rb +10 -10
  56. data/samples/color_shortcuts.rb +6 -0
  57. data/samples/csv_import.rb +18 -18
  58. data/samples/custom-config.yml +5 -5
  59. data/samples/custom_config.rb +18 -18
  60. data/samples/draw_shapes.rb +45 -35
  61. data/samples/embed_text.rb +88 -90
  62. data/samples/hand.rb +24 -24
  63. data/samples/layouts.rb +62 -61
  64. data/samples/layouts_builtin.rb +51 -0
  65. data/samples/load_images.rb +78 -64
  66. data/samples/ranges.rb +64 -53
  67. data/samples/sample.csv +2 -2
  68. data/samples/text_options.rb +102 -94
  69. data/spec/api/api_data_spec.rb +57 -50
  70. data/spec/api/api_settings_spec.rb +37 -17
  71. data/spec/args/box_spec.rb +127 -0
  72. data/spec/args/draw_spec.rb +95 -0
  73. data/spec/args/embed_key_spec.rb +13 -0
  74. data/spec/args/input_file_spec.rb +21 -0
  75. data/spec/args/paint_spec.rb +22 -0
  76. data/spec/args/paragraph_spec.rb +153 -0
  77. data/spec/args/range_spec.rb +36 -0
  78. data/spec/args/save_batch_spec.rb +51 -0
  79. data/spec/args/scale_box_spec.rb +71 -0
  80. data/spec/args/sheet_spec.rb +58 -0
  81. data/spec/args/showcase_special_spec.rb +15 -0
  82. data/spec/data/samples/autoscale_font.rb.txt +84 -87
  83. data/spec/data/samples/basic.rb.txt +209 -203
  84. data/spec/data/samples/cairo_access.rb.txt +2 -2
  85. data/spec/data/samples/config_text_markup.rb.txt +72 -75
  86. data/spec/data/samples/csv_import.rb.txt +76 -80
  87. data/spec/data/samples/custom_config.rb.txt +48 -49
  88. data/spec/data/samples/draw_shapes.rb.txt +100 -42
  89. data/spec/data/samples/embed_text.rb.txt +283 -295
  90. data/spec/data/samples/excel.rb.txt +162 -171
  91. data/spec/data/samples/gradients.rb.txt +79 -67
  92. data/spec/data/samples/hand.rb.txt +538 -514
  93. data/spec/data/samples/hello_world.rb.txt +36 -38
  94. data/spec/data/samples/load_images.rb.txt +41 -5
  95. data/spec/data/samples/portrait-landscape.rb.txt +49 -51
  96. data/spec/data/samples/ranges.rb.txt +460 -429
  97. data/spec/data/samples/saves.rb.txt +801 -785
  98. data/spec/data/samples/showcase.rb.txt +5910 -5906
  99. data/spec/data/samples/text_options.rb.txt +1125 -981
  100. data/spec/data/samples/tgc_proofs.rb.txt +81 -79
  101. data/spec/data/samples/units.rb.txt +18 -12
  102. data/spec/data/xlsx/with_macros.xlsm +0 -0
  103. data/spec/graphics/cairo_context_wrapper_spec.rb +84 -75
  104. data/spec/graphics/graphics_images_spec.rb +94 -85
  105. data/spec/graphics/graphics_save_doc_spec.rb +67 -65
  106. data/spec/samples/expected/hand.png +0 -0
  107. data/spec/samples/expected/hand_pretty.png +0 -0
  108. data/spec/samples/expected/layout_00.png +0 -0
  109. data/spec/samples/expected/load_images_00.png +0 -0
  110. data/spec/samples/expected/ranges_00.png +0 -0
  111. data/spec/samples/expected/shape_00.png +0 -0
  112. data/spec/samples/expected/showcase.png +0 -0
  113. data/spec/samples/expected/showcase2.png +0 -0
  114. data/spec/samples/expected/showcase_individual_00.png +0 -0
  115. data/spec/samples/expected/showcase_individual_01.png +0 -0
  116. data/spec/samples/expected/showcase_individual_02.png +0 -0
  117. data/spec/samples/expected/showcase_individual_03.png +0 -0
  118. data/spec/samples/expected/text_00.png +0 -0
  119. data/spec/samples/expected/text_01.png +0 -0
  120. data/spec/samples/expected/text_02.png +0 -0
  121. data/spec/samples/samples_regression_spec.rb +82 -82
  122. data/spec/spec_helper.rb +3 -2
  123. data/squib.gemspec +48 -48
  124. data/squib.sublime-project +42 -36
  125. metadata +61 -33
  126. data/lib/squib/input_helpers.rb +0 -238
  127. data/spec/api/api_image_spec.rb +0 -38
  128. data/spec/api/api_text_spec.rb +0 -37
  129. data/spec/graphics/graphics_shapes_spec.rb +0 -85
  130. data/spec/graphics/graphics_text_spec.rb +0 -164
  131. data/spec/input_helpers_spec.rb +0 -238
  132. data/spec/samples/expected/embed_multi_00.png +0 -0
  133. data/spec/samples/expected/embed_multi_01.png +0 -0
  134. data/spec/samples/expected/embed_multi_02.png +0 -0
  135. data/spec/samples/expected/ranges_01.png +0 -0
  136. data/spec/samples/expected/ranges_02.png +0 -0
@@ -0,0 +1,6 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new do
4
+ circle color: 'black', fill_color: 'black'
5
+ save_png prefix: 'color_shortcuts_'
6
+ end
@@ -1,18 +1,18 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(cards: 2) do
4
- background color: :white
5
-
6
- # Outputs a hash of arrays with the header names as keys
7
- data = csv file: 'sample.csv'
8
- text str: data['Type'], x: 250, y: 55, font: 'Arial 54'
9
- text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
10
-
11
- save format: :png, prefix: 'sample_csv_'
12
-
13
- # You can also specify the sheet, starting at 0
14
- data = xlsx file: 'sample.xlsx', sheet: 2
15
- end
16
-
17
- # CSV is also a Squib-module-level function, so this also works:
18
- data = Squib.csv file: 'sample.csv'
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 2) do
4
+ background color: :white
5
+
6
+ # Outputs a hash of arrays with the header names as keys
7
+ data = csv file: 'sample.csv'
8
+ text str: data['Type'], x: 250, y: 55, font: 'Arial 54'
9
+ text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
10
+
11
+ save format: :png, prefix: 'sample_csv_'
12
+
13
+ # You can also specify the sheet, starting at 0
14
+ data = xlsx file: 'sample.xlsx', sheet: 2
15
+ end
16
+
17
+ # CSV is also a Squib-module-level function, so this also works:
18
+ data = Squib.csv file: 'sample.csv'
@@ -1,5 +1,5 @@
1
- progress_bars: true
2
- text_hint: '#FF0000'
3
- custom_colors:
4
- foo: '#ccc'
5
- img_dir: customconfig-imgdir
1
+ progress_bars: true
2
+ text_hint: '#FF0000'
3
+ custom_colors:
4
+ foo: '#ccc'
5
+ img_dir: customconfig-imgdir
@@ -1,18 +1,18 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(config: 'custom-config.yml') do
4
- # Custom color defined in our config
5
- background color: :foo
6
-
7
- # Hints can be turned on in the config file
8
- text str: 'The Title', x: 0, y: 78, width: 825,
9
- font: 'Arial 72', align: :center
10
-
11
- # Progress bars are shown for these commands
12
- # And images are taken from config-imgdir
13
- png file: 'shiny-purse2.png', x: 620, y: 75
14
- svg file: 'spanner2.svg', x: 620, y: 218
15
- save_png prefix: 'custom-config_'
16
- save_pdf file: 'custom-config-out.pdf'
17
-
18
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(config: 'custom-config.yml') do
4
+ # Custom color defined in our config
5
+ background color: :foo
6
+
7
+ # Hints can be turned on in the config file
8
+ text str: 'The Title', x: 0, y: 78, width: 825,
9
+ font: 'Arial 72', align: :center
10
+
11
+ # Progress bars are shown for these commands
12
+ # And images are taken from img_dir, not the cwd.
13
+ png file: 'shiny-purse2.png', x: 620, y: 75
14
+ svg file: 'spanner2.svg', x: 620, y: 218
15
+ save_png prefix: 'custom-config_'
16
+ save_pdf file: 'custom-config-out.pdf'
17
+
18
+ end
@@ -1,35 +1,45 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new do
4
- background color: :white
5
- rect x: 300, y: 300, width: 400, height: 400,
6
- fill_color: :blue, stroke_color: :red, stroke_width: 50.0
7
-
8
- circle x: 600, y: 600, radius: 75,
9
- fill_color: :gray, stroke_color: :green, stroke_width: 8.0
10
-
11
- triangle x1: 50, y1: 50,
12
- x2: 150, y2: 150,
13
- x3: 75, y3: 250
14
-
15
- line x1: 50, y1: 550,
16
- x2: 150, y2: 650,
17
- stroke_width: 25.0
18
-
19
- curve x1: 50, y1: 850, cx1: 150, cy1: 700,
20
- x2: 625, y2: 900, cx2: 150, cy2: 700,
21
- stroke_width: 12.0, stroke_color: :cyan,
22
- fill_color: :burgundy
23
-
24
- ellipse x: 50, y: 925, width: 200, height: 100,
25
- stroke_width: 5.0, stroke_color: :cyan,
26
- fill_color: :burgundy
27
-
28
- star x: 300, y: 1000, n: 5, inner_radius: 10, outer_radius: 25,
29
- fill_color: :burgundy, stroke_color: :cyan, stroke_width: 3
30
-
31
- polygon x: 500, y: 1000, n: 5, radius: 25, angle: Math::PI / 2,
32
- fill_color: :burgundy, stroke_color: :cyan, stroke_width: 2
33
-
34
- save_png prefix: 'shape_'
35
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new do
4
+ background color: :white
5
+
6
+ rect x: 300, y: 100, width: 200, height: 50, dash: '4 2'
7
+
8
+ rect x: 300, y: 300, width: 400, height: 400,
9
+ fill_color: :blue, stroke_color: :red, stroke_width: 50.0,
10
+ join: 'bevel'
11
+
12
+ circle x: 600, y: 600, radius: 75,
13
+ fill_color: :gray, stroke_color: :green, stroke_width: 8.0
14
+
15
+ triangle x1: 50, y1: 50,
16
+ x2: 150, y2: 150,
17
+ x3: 75, y3: 250,
18
+ fill_color: :gray, stroke_color: :green, stroke_width: 3.0
19
+
20
+ line x1: 50, y1: 550,
21
+ x2: 150, y2: 650,
22
+ stroke_width: 25.0
23
+
24
+ curve x1: 50, y1: 850, cx1: 150, cy1: 700,
25
+ x2: 625, y2: 900, cx2: 150, cy2: 700,
26
+ stroke_width: 12.0, stroke_color: :cyan,
27
+ fill_color: :burgundy, cap: 'round'
28
+
29
+ ellipse x: 50, y: 925, width: 200, height: 100,
30
+ stroke_width: 5.0, stroke_color: :cyan,
31
+ fill_color: :burgundy
32
+
33
+ star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
34
+ fill_color: :cyan, stroke_color: :burgundy, stroke_width: 5
35
+
36
+ #default draw is fill-then-stroke. Can be changed to stroke-then-fill
37
+ star x: 375, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
38
+ fill_color: :cyan, stroke_color: :burgundy,
39
+ stroke_width: 5, stroke_strategy: :stroke_first
40
+
41
+ polygon x: 500, y: 1000, n: 5, radius: 25, angle: Math::PI / 2,
42
+ fill_color: :cyan, stroke_color: :burgundy, stroke_width: 2
43
+
44
+ save_png prefix: 'shape_'
45
+ end
@@ -1,90 +1,88 @@
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 21',
9
- x: 0, y: 0, width: 180, hint: :red,
10
- align: :left, ellipsize: false, justify: false) do |embed|
11
- # Notice how we use dx and dy to adjust the icon to not rest directly on the baseline
12
- embed.svg key: ':tool:', width: 28, height: 28, dx: 0, dy: 4, file: 'spanner.svg'
13
- embed.svg key: ':health:', width: 28, height: 28, dx: -2, dy: 4, file: 'glass-heart.svg'
14
- embed.png key: ':purse:', width: 28, height: 28, dx: 0, dy: 4, file: 'shiny-purse.png'
15
- end
16
-
17
- embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
18
- text(str: embed_text, font: 'Sans 21',
19
- x: 200, y: 0, width: 180, height: 300, valign: :middle,
20
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
21
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
22
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
23
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
24
- end
25
-
26
- embed_text = 'This :tool: aligns on the bottom properly. :purse:'
27
- text(str: embed_text, font: 'Sans 21',
28
- x: 400, y: 0, width: 180, height: 300, valign: :bottom,
29
- align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
30
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
31
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
32
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
33
- end
34
-
35
- embed_text = 'Wrapping multiples: These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
36
- text(str: embed_text, font: 'Sans 21',
37
- x: 600, y: 0, width: 180, height: 300, valign: :middle,
38
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
39
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
40
- end
41
-
42
- embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
43
- text(str: embed_text, font: 'Sans 21',
44
- x: 0, y: 320, width: 180, height: 300, valign: :bottom,
45
- align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
46
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
47
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
48
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
49
- end
50
-
51
- embed_text = 'Right-aligned works :tool: with :health: and :purse:'
52
- text(str: embed_text, font: 'Sans 21',
53
- x: 200, y: 320, width: 180, height: 300, valign: :bottom,
54
- align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
55
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
56
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
57
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
58
- end
59
-
60
- embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
61
- text(str: embed_text, font: 'Sans 21',
62
- x: 400, y: 320, width: 180, height: 300,
63
- align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
64
- embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
65
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
66
- embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
67
- end
68
-
69
- embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
70
- text(str: embed_text, font: 'Serif 18', markup: true,
71
- x: 600, y: 320, width: 180, height: 300,
72
- align: :center, hint: :magenta) do |embed|
73
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
74
- end
75
-
76
- save_png prefix: 'embed_'
77
- end
78
-
79
- Squib::Deck.new(cards: 3) do
80
-
81
- embed_text = 'Take 1 :tool: and gain 2 :health:.'
82
- text(str: embed_text, font: 'Sans', font_size: [18, 32, 45],
83
- x: 0, y: 0, width: 180, height: 300, valign: :bottom,
84
- align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
85
- embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
86
- embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
87
- end
88
- save_png prefix: 'embed_multi_'
89
- save_sheet prefix: 'embed_multisheet_', columns: 3
90
- 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 21',
9
+ x: 0, y: 0, width: 180, hint: :red,
10
+ align: :left, ellipsize: false, justify: false) do |embed|
11
+ # Notice how we use dx and dy to adjust the icon to not rest directly on the baseline
12
+ embed.svg key: ':tool:', width: 28, height: 28, dx: 0, dy: 4, file: 'spanner.svg'
13
+ embed.svg key: ':health:', width: 28, height: 28, dx: -2, dy: 4, file: 'glass-heart.svg'
14
+ embed.png key: ':purse:', width: 28, height: 28, dx: 0, dy: 4, file: 'shiny-purse.png'
15
+ end
16
+
17
+ embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
18
+ text(str: embed_text, font: 'Sans 21',
19
+ x: 200, y: 0, width: 180, height: 300, valign: :middle,
20
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
21
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
22
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
23
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
24
+ end
25
+
26
+ embed_text = 'This :tool: aligns on the bottom properly. :purse:'
27
+ text(str: embed_text, font: 'Sans 21',
28
+ x: 400, y: 0, width: 180, height: 300, valign: :bottom,
29
+ align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
30
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
31
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
32
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
33
+ end
34
+
35
+ embed_text = 'Wrapping multiples: These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
36
+ text(str: embed_text, font: 'Sans 21',
37
+ x: 600, y: 0, width: 180, height: 300, valign: :middle,
38
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
39
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
40
+ end
41
+
42
+ embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
43
+ text(str: embed_text, font: 'Sans 21',
44
+ x: 0, y: 320, width: 180, height: 300, valign: :bottom,
45
+ align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
46
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
47
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
48
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
49
+ end
50
+
51
+ embed_text = 'Right-aligned works :tool: with :health: and :purse:'
52
+ text(str: embed_text, font: 'Sans 21',
53
+ x: 200, y: 320, width: 180, height: 300, valign: :bottom,
54
+ align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
55
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
56
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
57
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
58
+ end
59
+
60
+ embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
61
+ text(str: embed_text, font: 'Sans 21',
62
+ x: 400, y: 320, width: 180, height: 300,
63
+ align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
64
+ embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
65
+ embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
66
+ embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
67
+ end
68
+
69
+ embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
70
+ text(str: embed_text, font: 'Serif 18', markup: true,
71
+ x: 600, y: 320, width: 180, height: 300,
72
+ align: :center, hint: :magenta) do |embed|
73
+ embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
74
+ end
75
+
76
+ save_png prefix: 'embed_'
77
+ end
78
+
79
+ Squib::Deck.new(cards: 3) do
80
+ str = 'Take 1 :tool: and gain 2 :health:.'
81
+ text(str: str, font: 'Sans', font_size: [18, 26, 35],
82
+ x: 0, y: 0, width: 180, height: 300, valign: :bottom,
83
+ align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
84
+ embed.svg key: ':tool:', width: [28, 42, 56], height: [28, 42, 56], file: 'spanner.svg'
85
+ embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'glass-heart.svg'
86
+ end
87
+ save_sheet prefix: 'embed_multisheet_', columns: 3
88
+ end
@@ -1,24 +1,24 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do
4
- background color: :cyan
5
- rect x: 37, y: 37, width: 750, height: 1050, fill_color: :black, radius: 25
6
- rect x: 75, y: 75, width: 675, height: 975, fill_color: :white, radius: 20
7
- text str: ('A'..'Z').to_a, layout: :bonus_ul, font: 'Sans bold 100'
8
-
9
- # Defaults are sensible
10
- hand #saves to _output/hand.png
11
-
12
- # Here's a prettier version:
13
- # - Each card is trimmed with rounded corners
14
- # - Zero radius means cards rotate about the bottom of the card
15
- # - Cards are shown in reverse order
16
- hand trim: 37.5, trim_radius: 25,
17
- radius: 0,
18
- range: 7.downto(0),
19
- file: 'hand_pretty.png'
20
-
21
- # Tip: you can have the top card be on the left by reversing the range
22
- # angle_range: (Math::PI / 4)..(Math::PI / -4)
23
- end
24
-
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do
4
+ background color: :cyan
5
+ rect x: 37, y: 37, width: 750, height: 1050, fill_color: :black, radius: 25
6
+ rect x: 75, y: 75, width: 675, height: 975, fill_color: :white, radius: 20
7
+ text str: ('A'..'Z').to_a, layout: :bonus_ul, font: 'Sans bold 100'
8
+
9
+ # Defaults are sensible
10
+ hand #saves to _output/hand.png
11
+
12
+ # Here's a prettier version:
13
+ # - Each card is trimmed with rounded corners
14
+ # - Zero radius means cards rotate about the bottom of the card
15
+ # - Cards are shown in reverse order
16
+ hand trim: 37.5, trim_radius: 25,
17
+ radius: 0,
18
+ range: 7.downto(0),
19
+ file: 'hand_pretty.png'
20
+
21
+ # Tip: you can have the top card be on the left by reversing the range
22
+ # angle_range: (Math::PI / 4)..(Math::PI / -4)
23
+ end
24
+
@@ -1,61 +1,62 @@
1
- # encoding: utf-8
2
- require 'squib'
3
-
4
- Squib::Deck.new(layout: 'custom-layout.yml') do
5
- background color: :white
6
- hint text: :cyan
7
-
8
- # Layouts are YAML files that specify any option as a default
9
- rect layout: :frame
10
-
11
- # You can also override a given layout entry in the command
12
- circle layout: :frame, x: 50, y: 50, radius: 25
13
-
14
- # Lots of commands have the :layout option
15
- text str: 'The Title', layout: :title
16
-
17
- # Layouts also support YAML merge keys toreuse settings
18
- svg file: 'spanner.svg', layout: :icon_left
19
- png file: 'shiny-purse.png', layout: :icon_middle
20
- svg file: 'spanner.svg', layout: :icon_right
21
-
22
- # Squib has its own, richer merge key: "extends"
23
- rect fill_color: :black, layout: :bonus
24
- rect fill_color: :white, layout: :bonus_inner
25
- text str: 'Extends!', layout: :bonus_text
26
-
27
- # Strings can also be used to specify a layout (e.g. from a data file)
28
- text str: 'subtitle', layout: 'subtitle'
29
-
30
- # For debugging purposes, you can always print out the loaded layout
31
- #require 'pp'
32
- #pp @layout
33
-
34
- save_png prefix: 'layout_'
35
- end
36
-
37
- Squib::Deck.new(layout: ['custom-layout.yml', 'custom-layout2.yml']) do
38
- text str: 'The Title', layout: :title # from custom-layout.yml
39
- text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
40
- text str: 'The Description', layout: :description # from custom-layout2.yml
41
- save_png prefix: 'layout2_'
42
- end
43
-
44
- # Built-in layouts are easy to use and extend
45
- Squib::Deck.new(layout: 'playing-card.yml') do
46
- text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
47
- text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
48
- text str: "artwork here", layout: :art, hint: :red
49
- save_png prefix: 'layout_builtin_playing_card_'
50
- end
51
-
52
- # Built-in layouts are easy to use and extend
53
- Squib::Deck.new(layout: 'hand.yml') do
54
- %w(title bonus1 bonus2 bonus3 bonus4 bonus5
55
- description snark art).each do |icon|
56
- text str: icon.capitalize, layout: icon,
57
- hint: :red, valign: 'middle', align: 'center'
58
- end
59
- png file: 'pokercard.png', alpha: 0.5
60
- save_png prefix: 'layout_builtin_hand_'
61
- end
1
+ # encoding: utf-8
2
+ require 'squib'
3
+ require 'pp'
4
+
5
+ Squib::Deck.new(layout: 'custom-layout.yml') do
6
+ background color: :white
7
+ hint text: :cyan
8
+
9
+ # Layouts are YAML files that specify any option as a default
10
+ rect layout: :frame
11
+
12
+ # You can also override a given layout entry in the command
13
+ circle layout: :frame, x: 50, y: 50, radius: 25
14
+
15
+ # Lots of commands have the :layout option
16
+ text str: 'The Title', layout: :title
17
+
18
+ # Layouts also support YAML merge keys toreuse settings
19
+ svg file: 'spanner.svg', layout: :icon_left
20
+ png file: 'shiny-purse.png', layout: :icon_middle
21
+ svg file: 'spanner.svg', layout: :icon_right
22
+
23
+ # Squib has its own, richer merge key: "extends"
24
+ rect fill_color: :black, layout: :bonus
25
+ rect fill_color: :white, layout: :bonus_inner
26
+ text str: 'Extends!', layout: :bonus_text
27
+
28
+ # Strings can also be used to specify a layout (e.g. from a data file)
29
+ text str: 'subtitle', layout: 'subtitle'
30
+
31
+ # For debugging purposes, you can always print out the loaded layout
32
+ # require 'pp'
33
+ # pp layout
34
+
35
+ save_png prefix: 'layout_'
36
+ end
37
+
38
+ Squib::Deck.new(layout: ['custom-layout.yml', 'custom-layout2.yml']) do
39
+ text str: 'The Title', layout: :title # from custom-layout.yml
40
+ text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
41
+ text str: 'The Description', layout: :description # from custom-layout2.yml
42
+ save_png prefix: 'layout2_'
43
+ end
44
+
45
+ # Built-in layouts are easy to use and extend
46
+ Squib::Deck.new(layout: 'playing-card.yml') do
47
+ text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
48
+ text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
49
+ text str: "artwork here", layout: :art, hint: :red
50
+ save_png prefix: 'layout_builtin_playing_card_'
51
+ end
52
+
53
+ # Built-in layouts are easy to use and extend
54
+ Squib::Deck.new(layout: 'hand.yml') do
55
+ %w(title bonus1 bonus2 bonus3 bonus4 bonus5
56
+ description snark art).each do |icon|
57
+ text str: icon.capitalize, layout: icon,
58
+ hint: :red, valign: 'middle', align: 'center'
59
+ end
60
+ png file: 'pokercard.png', alpha: 0.5
61
+ save_png prefix: 'layout_builtin_hand_'
62
+ end