squib 0.8.0 → 0.9.0

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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +14 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +201 -175
  5. data/Gemfile +2 -4
  6. data/README.md +650 -645
  7. data/RELEASE TODO.md +18 -18
  8. data/Rakefile +106 -99
  9. data/appveyor.yml +29 -0
  10. data/lib/squib.rb +32 -32
  11. data/lib/squib/api/background.rb +20 -20
  12. data/lib/squib/api/data.rb +131 -131
  13. data/lib/squib/api/image.rb +108 -90
  14. data/lib/squib/api/save.rb +151 -149
  15. data/lib/squib/api/settings.rb +35 -35
  16. data/lib/squib/api/shapes.rb +255 -230
  17. data/lib/squib/api/text.rb +65 -65
  18. data/lib/squib/api/text_embed.rb +96 -96
  19. data/lib/squib/args/arg_loader.rb +138 -138
  20. data/lib/squib/args/box.rb +54 -54
  21. data/lib/squib/args/card_range.rb +32 -32
  22. data/lib/squib/args/color_validator.rb +11 -11
  23. data/lib/squib/args/coords.rb +32 -32
  24. data/lib/squib/args/dir_validator.rb +16 -16
  25. data/lib/squib/args/draw.rb +92 -92
  26. data/lib/squib/args/embed_adjust.rb +25 -25
  27. data/lib/squib/args/embed_key.rb +17 -17
  28. data/lib/squib/args/hand_special.rb +37 -37
  29. data/lib/squib/args/import.rb +39 -39
  30. data/lib/squib/args/input_file.rb +37 -37
  31. data/lib/squib/args/paint.rb +43 -43
  32. data/lib/squib/args/paragraph.rb +116 -115
  33. data/lib/squib/args/save_batch.rb +63 -60
  34. data/lib/squib/args/scale_box.rb +53 -53
  35. data/lib/squib/args/sheet.rb +72 -72
  36. data/lib/squib/args/showcase_special.rb +38 -38
  37. data/lib/squib/args/svg_special.rb +37 -37
  38. data/lib/squib/args/transform.rb +60 -24
  39. data/lib/squib/args/typographer.rb +117 -117
  40. data/lib/squib/card.rb +66 -67
  41. data/lib/squib/conf.rb +131 -117
  42. data/lib/squib/constants.rb +12 -178
  43. data/lib/squib/deck.rb +113 -113
  44. data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
  45. data/lib/squib/graphics/gradient_regex.rb +46 -46
  46. data/lib/squib/graphics/hand.rb +42 -42
  47. data/lib/squib/graphics/image.rb +103 -76
  48. data/lib/squib/graphics/save_doc.rb +103 -103
  49. data/lib/squib/graphics/save_images.rb +39 -33
  50. data/lib/squib/graphics/shapes.rb +135 -119
  51. data/lib/squib/graphics/showcase.rb +85 -85
  52. data/lib/squib/graphics/text.rb +176 -176
  53. data/lib/squib/layout_parser.rb +91 -91
  54. data/lib/squib/layouts/economy.yml +85 -85
  55. data/lib/squib/layouts/fantasy.yml +101 -101
  56. data/lib/squib/layouts/hand.yml +62 -62
  57. data/lib/squib/layouts/playing-card.yml +35 -35
  58. data/lib/squib/layouts/tuck_box.yml +45 -45
  59. data/lib/squib/project_template/IDEAS.md +22 -0
  60. data/lib/squib/project_template/PLAYTESTING.md +26 -0
  61. data/lib/squib/project_template/RULES.md +21 -0
  62. data/lib/squib/project_template/config.yml +49 -45
  63. data/lib/squib/sample_helpers.rb +34 -0
  64. data/lib/squib/version.rb +10 -10
  65. data/samples/autoscale_font/_autoscale_font.rb +29 -0
  66. data/samples/color_shortcuts.rb +6 -6
  67. data/samples/csv_import.rb +26 -26
  68. data/samples/custom-config.yml +5 -5
  69. data/samples/custom_config.rb +18 -18
  70. data/samples/draw_shapes.rb +48 -45
  71. data/samples/embed_text.rb +88 -88
  72. data/samples/excel.rb +55 -55
  73. data/samples/hand.rb +24 -24
  74. data/samples/images/_images.rb +104 -0
  75. data/samples/intro/01_hello.rb +9 -0
  76. data/samples/intro/02_options.rb +15 -0
  77. data/samples/intro/03_layout.rb +12 -0
  78. data/samples/intro/04_arrays.rb +16 -0
  79. data/samples/intro/05_excel.rb +15 -0
  80. data/samples/layouts.rb +62 -62
  81. data/samples/layouts_builtin.rb +51 -51
  82. data/samples/load_images.rb +99 -78
  83. data/samples/load_images_config.yml +1 -0
  84. data/samples/quantity_explosion.csv +2 -2
  85. data/samples/ranges.rb +64 -64
  86. data/samples/sample.csv +2 -2
  87. data/samples/saves.rb +9 -1
  88. data/samples/sprites.png +0 -0
  89. data/samples/text/_text.rb +46 -0
  90. data/samples/text_options.rb +102 -102
  91. data/spec/api/api_data_spec.rb +117 -117
  92. data/spec/api/api_settings_spec.rb +37 -37
  93. data/spec/args/box_spec.rb +127 -127
  94. data/spec/args/draw_spec.rb +101 -95
  95. data/spec/args/embed_key_spec.rb +13 -13
  96. data/spec/args/input_file_spec.rb +21 -21
  97. data/spec/args/paint_spec.rb +21 -21
  98. data/spec/args/paragraph_spec.rb +152 -152
  99. data/spec/args/range_spec.rb +40 -40
  100. data/spec/args/save_batch_spec.rb +51 -51
  101. data/spec/args/scale_box_spec.rb +71 -71
  102. data/spec/args/sheet_spec.rb +58 -58
  103. data/spec/args/showcase_special_spec.rb +15 -15
  104. data/spec/args/transform_spec.rb +25 -0
  105. data/spec/card_spec.rb +11 -0
  106. data/spec/conf_spec.rb +13 -3
  107. data/spec/data/conf/unrecognized.yml +4 -0
  108. data/spec/data/csv/qty.csv +2 -2
  109. data/spec/data/csv/qty_named.csv +2 -2
  110. data/spec/data/csv/with_spaces.csv +2 -2
  111. data/spec/data/samples/autoscale_font.rb.txt +84 -84
  112. data/spec/data/samples/basic.rb.txt +227 -209
  113. data/spec/data/samples/config_text_markup.rb.txt +72 -72
  114. data/spec/data/samples/csv_import.rb.txt +213 -213
  115. data/spec/data/samples/custom_config.rb.txt +57 -48
  116. data/spec/data/samples/draw_shapes.rb.txt +555 -3
  117. data/spec/data/samples/embed_text.rb.txt +283 -283
  118. data/spec/data/samples/excel.rb.txt +661 -661
  119. data/spec/data/samples/gradients.rb.txt +77 -79
  120. data/spec/data/samples/hand.rb.txt +538 -538
  121. data/spec/data/samples/hello_world.rb.txt +36 -36
  122. data/spec/data/samples/load_images.rb.txt +170 -0
  123. data/spec/data/samples/portrait-landscape.rb.txt +51 -49
  124. data/spec/data/samples/ranges.rb.txt +472 -460
  125. data/spec/data/samples/saves.rb.txt +810 -801
  126. data/spec/data/samples/showcase.rb.txt +5926 -5910
  127. data/spec/data/samples/text_options.rb.txt +1125 -1125
  128. data/spec/data/samples/tgc_proofs.rb.txt +95 -81
  129. data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
  130. data/spec/graphics/graphics_save_doc_spec.rb +67 -67
  131. data/spec/samples/diff-with-css.example.html +39 -0
  132. data/spec/samples/expected/load_images_00.png +0 -0
  133. data/spec/samples/expected/shape_00.png +0 -0
  134. data/spec/samples/run_samples_spec.rb +17 -0
  135. data/spec/samples/samples_regression_spec.rb +72 -82
  136. data/spec/spec_helper.rb +9 -1
  137. data/squib.gemspec +49 -48
  138. data/squib.sublime-project +42 -42
  139. metadata +94 -48
  140. data/spec/graphics/graphics_images_spec.rb +0 -94
@@ -1,55 +1,55 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(cards: 3) do
4
- background color: :white
5
-
6
- # Reads the first sheet by default (sheet 0)
7
- # Outputs a hash of arrays with the header names as keys
8
- data = xlsx file: 'sample.xlsx'
9
-
10
- text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
11
- text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
12
- text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
13
-
14
- save format: :png, prefix: 'sample_excel_' #save to individual pngs
15
- end
16
-
17
- # xlsx is also a Squib-module-level function, so this also works:
18
- data = Squib.xlsx file: 'explode_quantities.xlsx' # 2 rows...
19
- num_cards = data['Name'].size # ...but 4 cards!
20
-
21
- Squib::Deck.new(cards: num_cards) do
22
- background color: :white
23
- rect # card border
24
- text str: data['Name'], font: 'Arial 54'
25
- save_sheet prefix: 'sample_xlsx_qty_', columns: 4
26
- end
27
-
28
-
29
- # Here's another example, a bit more realistic. Here's what's going on:
30
- # * We call xlsx from Squib directly - BEFORE Squib::Deck creation. This
31
- # allows us to infer the number of cards based on the size of the "Name"
32
- # field
33
- # * We make use of quantity explosion. Fields named "Qty" or "Quantity"
34
- # (any capitalization), or any other in the "qty_header" get expanded by the
35
- # number given
36
- # * We also make sure that trailing and leading whitespace is stripped
37
- # from each value. This is the default behavior in Squib, but the options
38
- # are here just to make sure.
39
-
40
- resource_data = Squib.xlsx(file: 'sample.xlsx', sheet: 2, strip: true) do |header, value|
41
- case header
42
- when 'Cost'
43
- "$#{value}k" # e.g. "3" becomes "$3k"
44
- else
45
- value # always return the original value if you didn't do anything to it
46
- end
47
- end
48
-
49
- Squib::Deck.new(cards: resource_data['Name'].size) do
50
- background color: :white
51
- rect width: :deck, height: :deck
52
- text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
53
- text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
54
- save_sheet prefix: 'sample_excel_resources_' #save to a whole sheet
55
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 3) do
4
+ background color: :white
5
+
6
+ # Reads the first sheet by default (sheet 0)
7
+ # Outputs a hash of arrays with the header names as keys
8
+ data = xlsx file: 'sample.xlsx'
9
+
10
+ text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
11
+ text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
12
+ text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
13
+
14
+ save format: :png, prefix: 'sample_excel_' #save to individual pngs
15
+ end
16
+
17
+ # xlsx is also a Squib-module-level function, so this also works:
18
+ data = Squib.xlsx file: 'explode_quantities.xlsx' # 2 rows...
19
+ num_cards = data['Name'].size # ...but 4 cards!
20
+
21
+ Squib::Deck.new(cards: num_cards) do
22
+ background color: :white
23
+ rect # card border
24
+ text str: data['Name'], font: 'Arial 54'
25
+ save_sheet prefix: 'sample_xlsx_qty_', columns: 4
26
+ end
27
+
28
+
29
+ # Here's another example, a bit more realistic. Here's what's going on:
30
+ # * We call xlsx from Squib directly - BEFORE Squib::Deck creation. This
31
+ # allows us to infer the number of cards based on the size of the "Name"
32
+ # field
33
+ # * We make use of quantity explosion. Fields named "Qty" or "Quantity"
34
+ # (any capitalization), or any other in the "qty_header" get expanded by the
35
+ # number given
36
+ # * We also make sure that trailing and leading whitespace is stripped
37
+ # from each value. This is the default behavior in Squib, but the options
38
+ # are here just to make sure.
39
+
40
+ resource_data = Squib.xlsx(file: 'sample.xlsx', sheet: 2, strip: true) do |header, value|
41
+ case header
42
+ when 'Cost'
43
+ "$#{value}k" # e.g. "3" becomes "$3k"
44
+ else
45
+ value # always return the original value if you didn't do anything to it
46
+ end
47
+ end
48
+
49
+ Squib::Deck.new(cards: resource_data['Name'].size) do
50
+ background color: :white
51
+ rect width: :deck, height: :deck
52
+ text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
53
+ text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
54
+ save_sheet prefix: 'sample_excel_resources_' #save to a whole sheet
55
+ 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
+
@@ -0,0 +1,104 @@
1
+ require 'squib'
2
+ require 'squib/sample_helpers'
3
+
4
+ Squib::Deck.new(width: 1000, height: 3000) do
5
+ draw_graph_paper width, height
6
+
7
+ sample "This a PNG.\nNo scaling is done by default." do |x, y|
8
+ png file: 'angler-fish.png', x: x, y: y
9
+ end
10
+
11
+ sample 'PNGs can be upscaled, but they will emit an antialias warning (unless you turn it off in the config.yml)' do |x,y|
12
+ png file: 'angler-fish.png', x: x, y: y, width: 150, height: 150
13
+ end
14
+
15
+ sample 'SVGs can be loaded from a file (left) or from straight XML (right). They can also be scaled to any size.' do |x,y|
16
+ svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100
17
+ svg data: File.read('robot-golem.svg'), width: 100, height: 100,
18
+ x: x + 200, y: y
19
+ end
20
+
21
+ sample 'PNG and SVG can be auto-scaled by one side and setting the other to :scale' do |x,y|
22
+ svg file: 'robot-golem.svg', x: x, y: y, width: 50, height: :scale
23
+ svg file: 'robot-golem.svg', x: x + 50, y: y, width: :scale, height: 50
24
+
25
+ png file: 'angler-fish.png', x: x + 200, y: y, width: 50, height: :scale
26
+ png file: 'angler-fish.png', x: x + 250, y: y, width: :scale, height: 50
27
+ end
28
+
29
+ sample 'PNGs can be cropped. To work from sprite sheets, you can set crop coordinates to PNG images. Rounded corners supported too.' do |x,y|
30
+ png file: 'sprites.png', x: x - 50, y: y - 50 # entire sprite sheet
31
+ rect x: x - 50, y: y - 50, width: 100, height: 100, # draw the crop line
32
+ radius: 15, dash: '3 3', stroke_color: 'red', stroke_width: 3
33
+ text str: '➜', font: 'Sans Bold 36', x: x + 150, y: y - 35
34
+ png file: 'sprites.png', x: x + 200, y: y - 50, # just the robot golem image
35
+ crop_x: 0, crop_y: 0, crop_corner_radius: 15,
36
+ crop_width: 100, crop_height: 100
37
+
38
+ png file: 'sprites.png', x: x - 50, y: y + 50 # entire sprite sheet again
39
+ rect x: x + 14, y: y + 50, width: 65, height: 65, # highlight the crop
40
+ radius: 25, dash: '3 3', stroke_color: 'red', stroke_width: 3
41
+ text str: '➜', font: 'Sans Bold 36', x: x + 150, y: y + 50
42
+ png file: 'sprites.png', x: x + 225, y: y + 50, # just the drakkar ship image, rotated
43
+ crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
44
+ crop_width: 64, crop_height: 64, angle: Math::PI / 6
45
+ end
46
+
47
+ sample 'SVGs can be cropped too.' do |x,y|
48
+ svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100,
49
+ crop_x: 40, crop_y: 0, crop_width: 50, crop_height: 50
50
+ end
51
+
52
+ sample 'Images can be flipped about their center.' do |x,y|
53
+ png file: 'angler-fish.png', x: x, y: y, flip_vertical: true, flip_horizontal: true
54
+ svg file: 'robot-golem.svg', x: x + 200, y: y, width: 100, height: 100,
55
+ flip_horizontal: true
56
+ end
57
+
58
+ sample 'SVG can be limited to rendering to a single object if the SVG ID is set. If you look in this SVG file, the black backdrop has ID #backdrop.' do |x,y|
59
+ svg file: 'robot-golem.svg', id: 'backdrop', x: x, y: y, width: 100, height: 100
60
+ end
61
+
62
+ sample "The SVG force_id option allows use of an ID only when specified, and render nothing if empty. Useful for multiple icons in one SVG file.\nThis should show nothing." do |x,y|
63
+ svg file: 'robot-golem.svg', x: x, y: y,
64
+ force_id: true, id: '' # <-- the important parts
65
+ end
66
+
67
+ sample 'NOTE! If you render a single object in an SVG, its placement is still relative to the SVG document.' do |x,y|
68
+ svg file: 'offset.svg', x: x, y: y
69
+ rect x: x, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
70
+
71
+ svg file: 'offset.svg', id: 'thing', x: x + 200, y: y, width: 100, height: 100
72
+ rect x: x + 200, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
73
+ end
74
+
75
+ sample 'PNGs can be blended onto each other with 15 different blending operators. Alpha transparency supported too. See http://cairographics.org/operators' do |x,y|
76
+ png file: 'ball.png', x: x, y: y
77
+ png file: 'grit.png', x: x + 20, y: y + 20, blend: :color_burn, alpha: 0.75
78
+ end
79
+
80
+ sample 'Rotation is around the upper-left corner of the image. Unit is radians.' do |x,y|
81
+ rect x: x, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
82
+ png x: x, y: y, width: 100, height: 100, angle: Math::PI / 4, file: 'angler-fish.png'
83
+
84
+ rect x: x + 250, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
85
+ svg x: x + 250, y: y, width: 100, height: 100, file: 'robot-golem.svg',
86
+ angle: Math::PI / 2 - 0.2
87
+ end
88
+
89
+ sample 'SVGs and PNGs can be used as masks for colors instead of being directly rendered.' do |x,y|
90
+ svg mask: '#00ff00', file: 'glass-heart.svg', x: x - 50, y: y - 50, width: 200, height: 200
91
+ svg mask: '(0,0)(500,0) #eee@0.0 #111@1.0', file: 'glass-heart.svg', x: x + 150, y: y - 50, width: 200, height: 200
92
+ end
93
+
94
+ sample 'PNG masks are based on the alpha channel. Gradient coordinates are relative to the card.' do |x,y|
95
+ png file: 'with-alpha.png', x: x - 50, y: y
96
+ png file: 'with-alpha.png', mask: :magenta, x: x + 50, y: y
97
+
98
+ mask = "(#{x+150+75}, #{y+75}, 0)(#{x+150+75}, #{y+75}, 100) #f00@0.0 #000@1.0"
99
+ png file: 'with-alpha.png', mask: mask, x: x + 150, y: y, width: 150, height: :scale
100
+ end
101
+
102
+
103
+ save_png prefix: '_images_', dir: '.'
104
+ end
@@ -0,0 +1,9 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1 do
4
+ background color: 'pink'
5
+ rect
6
+ text str: 'Draw two cards.'
7
+ save_png prefix: 'part1_', dir: '.'
8
+ end
9
+
@@ -0,0 +1,15 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1 do
4
+ background color: '#252322'
5
+ rect fill_color: '#0B3736',
6
+ x: 38, y: 38, width: 750, height: 1050, radius: 38
7
+ text str: 'Robot Golem', font: 'True Crimes, Sans 72',
8
+ align: :center, x: 75, width: :deck, color: '#DFDFE1', y: 90
9
+ svg file: 'auto-repair.svg', x: 75, y: 75, width: 100, height: :scale
10
+ svg file: 'robot-golem.svg', x: 75, y: 300, width: 675, height: :scale
11
+ text str: 'Draw two cards', font: 'Serif 36',
12
+ align: :center, width: :deck, color: '#DFDFE1', y: 1000
13
+ save_png prefix: 'part2_', dir: '.'
14
+ end
15
+
@@ -0,0 +1,12 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 1, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ text str: 'Robot Golem', layout: 'title'
7
+ svg layout: 'drone'
8
+ svg file: 'robot-golem.svg', layout: 'art'
9
+ text str: 'Draw two cards.', layout: 'power'
10
+ save_png prefix: 'part3_', dir: '.'
11
+ end
12
+
@@ -0,0 +1,16 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 2, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ text str: ['Robot Golem', 'Ninja'],
7
+ layout: 'title'
8
+ svg layout: ['drone', 'human']
9
+ svg file: ['robot-golem.svg','ninja-mask.svg'],
10
+ layout: 'art'
11
+ text str: ['Draw two cards',
12
+ 'Use the power of another player'],
13
+ layout: 'power'
14
+ save_png prefix: 'part4_', dir: '.'
15
+ end
16
+
@@ -0,0 +1,15 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new cards: 4, layout: 'part3_layout.yml' do
4
+ background color: '#252322'
5
+ rect layout: 'backdrop'
6
+ data = xlsx file: 'data.xlsx'
7
+ text str: data['name'], layout: 'title'
8
+ svg layout: data['class']
9
+ svg file: data['art'], layout: 'art'
10
+ text str: data['power'], layout: 'power'
11
+ save_png prefix: 'part5_', dir: '.'
12
+ hand file: 'part5_hand.png', dir: '.', trim_radius: 38
13
+ showcase file: 'part5_showcase.png', dir: '.'
14
+ end
15
+
@@ -1,62 +1,62 @@
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
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