squib 0.18.0 → 0.19.0a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -39
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +22 -22
  4. data/.github/ISSUE_TEMPLATE/help-wanted.md +13 -13
  5. data/.github/ISSUE_TEMPLATE/release-todo.md +45 -33
  6. data/.github/PULL_REQUEST_TEMPLATE.md +13 -13
  7. data/.github/workflows/tests.yml +22 -22
  8. data/.gitignore +41 -41
  9. data/.vscode/settings.json +4 -3
  10. data/CHANGELOG.md +460 -460
  11. data/CONTRIBUTING.md +40 -40
  12. data/Dockerfile +27 -27
  13. data/Gemfile +2 -2
  14. data/Guardfile +8 -8
  15. data/LICENSE.txt +22 -22
  16. data/README.md +139 -139
  17. data/Rakefile +51 -51
  18. data/bin/squib +5 -5
  19. data/lib/squib/api/settings.rb +21 -21
  20. data/lib/squib/args/arg_loader.rb +138 -138
  21. data/lib/squib/args/box.rb +59 -59
  22. data/lib/squib/args/card_range.rb +34 -34
  23. data/lib/squib/args/color_validator.rb +7 -7
  24. data/lib/squib/args/coords.rb +49 -49
  25. data/lib/squib/args/csv_opts.rb +22 -22
  26. data/lib/squib/args/dir_validator.rb +11 -11
  27. data/lib/squib/args/draw.rb +93 -93
  28. data/lib/squib/args/drop_shadow.rb +39 -39
  29. data/lib/squib/args/embed_adjust.rb +22 -22
  30. data/lib/squib/args/embed_key.rb +12 -12
  31. data/lib/squib/args/hand_special.rb +37 -37
  32. data/lib/squib/args/import.rb +67 -67
  33. data/lib/squib/args/input_file.rb +55 -55
  34. data/lib/squib/args/paint.rb +43 -43
  35. data/lib/squib/args/paragraph.rb +118 -118
  36. data/lib/squib/args/save_batch.rb +65 -65
  37. data/lib/squib/args/scale_box.rb +57 -57
  38. data/lib/squib/args/sheet.rb +165 -165
  39. data/lib/squib/args/showcase_special.rb +41 -41
  40. data/lib/squib/args/sprue_file.rb +44 -44
  41. data/lib/squib/args/svg_special.rb +37 -37
  42. data/lib/squib/args/transform.rb +55 -55
  43. data/lib/squib/args/typographer.rb +115 -115
  44. data/lib/squib/args/unit_conversion.rb +27 -27
  45. data/lib/squib/args/xywh_shorthands.rb +50 -50
  46. data/lib/squib/builtin/layouts/economy.yml +85 -85
  47. data/lib/squib/builtin/layouts/fantasy.yml +101 -101
  48. data/lib/squib/builtin/layouts/hand.yml +62 -62
  49. data/lib/squib/builtin/layouts/party.yml +94 -94
  50. data/lib/squib/builtin/layouts/playing-card.yml +35 -35
  51. data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
  52. data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
  53. data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
  54. data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
  55. data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
  56. data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
  57. data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
  58. data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
  59. data/lib/squib/builtin/projects/advanced/config.yml +49 -49
  60. data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
  61. data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
  62. data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
  63. data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
  64. data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
  65. data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
  66. data/lib/squib/builtin/projects/basic/.gitignore +4 -4
  67. data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
  68. data/lib/squib/builtin/projects/basic/Gemfile +3 -3
  69. data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
  70. data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
  71. data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
  72. data/lib/squib/builtin/projects/basic/RULES.md +21 -21
  73. data/lib/squib/builtin/projects/basic/Rakefile +7 -7
  74. data/lib/squib/builtin/projects/basic/config.yml +50 -50
  75. data/lib/squib/builtin/projects/basic/deck.rb +6 -6
  76. data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
  77. data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
  78. data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
  79. data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
  80. data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
  81. data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
  82. data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
  83. data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
  84. data/lib/squib/card.rb +75 -75
  85. data/lib/squib/commands/cli.rb +39 -39
  86. data/lib/squib/commands/data/template_option.rb +109 -109
  87. data/lib/squib/commands/make_sprue.rb +277 -277
  88. data/lib/squib/commands/new.rb +77 -77
  89. data/lib/squib/conf.rb +149 -149
  90. data/lib/squib/constants.rb +17 -17
  91. data/lib/squib/deck.rb +138 -138
  92. data/lib/squib/dsl/background.rb +35 -35
  93. data/lib/squib/dsl/circle.rb +39 -39
  94. data/lib/squib/dsl/csv.rb +42 -42
  95. data/lib/squib/dsl/curve.rb +35 -35
  96. data/lib/squib/dsl/cut_zone.rb +47 -47
  97. data/lib/squib/dsl/ellipse.rb +37 -37
  98. data/lib/squib/dsl/grid.rb +35 -35
  99. data/lib/squib/dsl/groups.rb +54 -54
  100. data/lib/squib/dsl/hand.rb +42 -42
  101. data/lib/squib/dsl/line.rb +35 -35
  102. data/lib/squib/dsl/png.rb +57 -57
  103. data/lib/squib/dsl/polygon.rb +36 -36
  104. data/lib/squib/dsl/rect.rb +37 -37
  105. data/lib/squib/dsl/safe_zone.rb +48 -48
  106. data/lib/squib/dsl/save.rb +21 -21
  107. data/lib/squib/dsl/save_pdf.rb +50 -50
  108. data/lib/squib/dsl/save_png.rb +48 -48
  109. data/lib/squib/dsl/save_sheet.rb +53 -53
  110. data/lib/squib/dsl/showcase.rb +43 -43
  111. data/lib/squib/dsl/star.rb +37 -37
  112. data/lib/squib/dsl/svg.rb +63 -63
  113. data/lib/squib/dsl/text.rb +54 -54
  114. data/lib/squib/dsl/text_embed.rb +79 -79
  115. data/lib/squib/dsl/triangle.rb +35 -35
  116. data/lib/squib/dsl/units.rb +37 -37
  117. data/lib/squib/dsl/xlsx.rb +40 -40
  118. data/lib/squib/dsl/yaml.rb +40 -40
  119. data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -14
  120. data/lib/squib/graphics/background.rb +14 -14
  121. data/lib/squib/graphics/cairo_context_wrapper.rb +115 -115
  122. data/lib/squib/graphics/embedding_utils.rb +28 -28
  123. data/lib/squib/graphics/gradient_regex.rb +47 -47
  124. data/lib/squib/graphics/hand.rb +42 -42
  125. data/lib/squib/graphics/image.rb +123 -123
  126. data/lib/squib/graphics/save_doc.rb +77 -77
  127. data/lib/squib/graphics/save_images.rb +91 -91
  128. data/lib/squib/graphics/save_pdf.rb +90 -90
  129. data/lib/squib/graphics/save_sprue.rb +231 -231
  130. data/lib/squib/graphics/shapes.rb +143 -143
  131. data/lib/squib/graphics/showcase.rb +85 -85
  132. data/lib/squib/graphics/text.rb +202 -202
  133. data/lib/squib/import/csv_importer.rb +45 -45
  134. data/lib/squib/import/data_frame.rb +108 -108
  135. data/lib/squib/import/quantity_exploder.rb +17 -17
  136. data/lib/squib/import/xlsx_importer.rb +28 -28
  137. data/lib/squib/import/yaml_importer.rb +30 -30
  138. data/lib/squib/layout_parser.rb +155 -155
  139. data/lib/squib/progress.rb +38 -38
  140. data/lib/squib/sample_helpers.rb +34 -34
  141. data/lib/squib/sprues/crop_line.rb +28 -28
  142. data/lib/squib/sprues/crop_line_dash.rb +35 -35
  143. data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
  144. data/lib/squib/sprues/sprue.rb +208 -208
  145. data/lib/squib/sprues/sprue_schema.rb +51 -51
  146. data/lib/squib/system_fonts.rb +16 -16
  147. data/lib/squib/version.rb +11 -11
  148. data/lib/squib.rb +35 -35
  149. data/samples/autoscale_font/_autoscale_font.rb +98 -98
  150. data/samples/backend/_backend.rb +26 -26
  151. data/samples/basic.rb +19 -19
  152. data/samples/build_groups/build_groups.rb +36 -36
  153. data/samples/colors/_colors.rb +44 -44
  154. data/samples/colors/_gradients.rb +34 -34
  155. data/samples/colors/_switch_color.rb +33 -33
  156. data/samples/config/config_text_markup.rb +20 -20
  157. data/samples/config/custom_config.rb +18 -18
  158. data/samples/data/_csv.rb +33 -33
  159. data/samples/data/_excel.rb +55 -55
  160. data/samples/data/_yaml.rb +12 -12
  161. data/samples/hello_world.rb +6 -6
  162. data/samples/images/_cairo_access.rb +39 -39
  163. data/samples/images/_images.rb +104 -104
  164. data/samples/images/_more_load_images.rb +102 -102
  165. data/samples/images/_placeholders.rb +48 -48
  166. data/samples/intro/01_hello.rb +8 -8
  167. data/samples/intro/02_options.rb +14 -14
  168. data/samples/intro/03_layout.rb +11 -11
  169. data/samples/intro/04_arrays.rb +15 -15
  170. data/samples/intro/05_excel.rb +14 -14
  171. data/samples/layouts/builtin_layouts.rb +97 -97
  172. data/samples/layouts/layouts.rb +71 -71
  173. data/samples/project/src/characters.rb +8 -8
  174. data/samples/project/src/skills.rb +7 -7
  175. data/samples/proofs/_tgc_proofs.rb +16 -16
  176. data/samples/ranges/_ranges.rb +64 -64
  177. data/samples/saves/_hand.rb +23 -23
  178. data/samples/saves/_portrait_landscape.rb +23 -23
  179. data/samples/saves/_save_filenames.rb +28 -28
  180. data/samples/saves/_save_pdf.rb +29 -29
  181. data/samples/saves/_saves.rb +75 -75
  182. data/samples/saves/_showcase.rb +25 -25
  183. data/samples/shadows/_shadow.rb +71 -71
  184. data/samples/shapes/_draw_shapes.rb +60 -60
  185. data/samples/shapes/_proofs.rb +22 -22
  186. data/samples/sprues/_advanced_sprues.rb +25 -25
  187. data/samples/sprues/_builtin_sprues.rb +22 -22
  188. data/samples/sprues/_fold_sheet.rb +30 -30
  189. data/samples/sprues/_hex_tiles.rb +15 -15
  190. data/samples/sprues/_mints.rb +11 -11
  191. data/samples/sprues/_negative_coords.rb +6 -6
  192. data/samples/sprues/_sprue_example.rb +11 -11
  193. data/samples/system_font_debug/_list_fonts.rb +14 -14
  194. data/samples/text/_embed_text.rb +128 -128
  195. data/samples/text/_text.rb +52 -52
  196. data/samples/text/_text_options.rb +103 -103
  197. data/samples/text/bug134.rb +14 -14
  198. data/samples/units/_cells.rb +50 -50
  199. data/samples/units/_shorthands.rb +48 -48
  200. data/samples/units/_units.rb +39 -39
  201. data/squib.gemspec +58 -58
  202. metadata +21 -21
@@ -1,98 +1,98 @@
1
- require 'squib'
2
-
3
- # Autoscaling font is handy for a bunch of things:
4
- # * Picture-perfect text fitting for one-off
5
- # * Rapid prototyping where you don't have to think about sizes
6
- #
7
- # We've got three options...
8
- # Option 1. Use your data <--- good for picture-perfect
9
- # Option 2. Use ellipsize: :autoscale <--- good for rapid prototyping
10
- # Option 3. Use map ranges in your code <--- good for picture-perfect
11
- # or other weird cases
12
-
13
- ###########################
14
- # Option 1: Use your data #
15
- ###########################
16
- # If you want to tweak the font size per-card, you can always make font_size
17
- # a column and map it from there. This is tedious but leads to perfectly
18
- # customized results
19
- my_data = Squib.csv data: <<~CSV
20
- "Title","Font Size"
21
- "Short & Big",10
22
- "Medium Length & Size", 5
23
- "Super duper long string here, therefore a smaller font.", 4
24
- CSV
25
-
26
- Squib::Deck.new(width: 300, height: 75, cards: 3) do
27
- background color: :white
28
- rect stroke_color: :black
29
-
30
- text str: my_data.title, font: 'Arial',
31
- font_size: my_data.font_size, # <-- key part
32
- x: 10, y:10, align: :center,
33
- width: 280, # <-- note how height does NOT need to be set
34
- ellipsize: false,
35
- hint: :red
36
- save_sheet columns: 3, prefix: 'autoscale_w_data_'
37
- end
38
-
39
- #######################################
40
- # Option 2: Use ellipsize: :autoscale #
41
- #######################################
42
- # If set the height, you can set "autoscale" and it will incrementally
43
- # downgrade the font size until the text does not ellipsize
44
- #
45
- # Great for rapid prototyping, set-it-and-forget-it
46
- #
47
- # NOTE: You MUST set the height for this to work. Otherwise, the text will
48
- # never ellipsize and Squib doesn't know when to start autoscaling
49
- Squib::Deck.new(width: 300, height: 75, cards: 3) do
50
- background color: :white
51
- rect stroke_color: :black
52
- title = ['Short & Big',
53
- 'Medium Length & Size',
54
- 'Super duper long string here, therefore a smaller font.']
55
-
56
- # Automatically scale the text down from the specified font_size to the largest size that fits
57
- text str: title, font: 'Arial',
58
- font_size: 15, # <-- this is the MAX font size. Scale down from here
59
- ellipsize: :autoscale, # <-- key part
60
- height: 50, # <-- need this to be set to something
61
- width: 280, x: 10, y: 10, align: :center, valign: :middle, hint: :red
62
-
63
- save_sheet columns: 3, prefix: 'autoscale_w_ellipsize_'
64
- end
65
-
66
- ############################################
67
- # Option 3: Mapping to ranges in your code #
68
- ############################################
69
- # Here's an in-between option that allows you to programmatically apply font
70
- # sizes. This allows you a ton of flexibility.Probably more flexibility than
71
- # you need, frankly. But one advantage is that you don't have to set the height
72
- def autoscale(str_array)
73
- str_array.map do | str |
74
- case str.length
75
- when 0..15
76
- 9
77
- when 16..20
78
- 6
79
- else
80
- 4
81
- end
82
- end
83
- end
84
-
85
- Squib::Deck.new(width: 300, height: 75, cards: 3) do
86
- background color: :white
87
- rect stroke_color: :black
88
- title = ['Short & Big',
89
- 'Medium Length & Size',
90
- 'Super duper long string here, therefore a smaller font.']
91
-
92
- # Scale text based on the string length
93
- text str: title, font: 'Arial',
94
- font_size: autoscale(title), # <-- key part
95
- x: 10, y:10, align: :center, width: 280, ellipsize: false, hint: :red
96
-
97
- save_sheet columns: 3, prefix: 'autoscale_w_range_'
98
- end
1
+ require 'squib'
2
+
3
+ # Autoscaling font is handy for a bunch of things:
4
+ # * Picture-perfect text fitting for one-off
5
+ # * Rapid prototyping where you don't have to think about sizes
6
+ #
7
+ # We've got three options...
8
+ # Option 1. Use your data <--- good for picture-perfect
9
+ # Option 2. Use ellipsize: :autoscale <--- good for rapid prototyping
10
+ # Option 3. Use map ranges in your code <--- good for picture-perfect
11
+ # or other weird cases
12
+
13
+ ###########################
14
+ # Option 1: Use your data #
15
+ ###########################
16
+ # If you want to tweak the font size per-card, you can always make font_size
17
+ # a column and map it from there. This is tedious but leads to perfectly
18
+ # customized results
19
+ my_data = Squib.csv data: <<~CSV
20
+ "Title","Font Size"
21
+ "Short & Big",10
22
+ "Medium Length & Size", 5
23
+ "Super duper long string here, therefore a smaller font.", 4
24
+ CSV
25
+
26
+ Squib::Deck.new(width: 300, height: 75, cards: 3) do
27
+ background color: :white
28
+ rect stroke_color: :black
29
+
30
+ text str: my_data.title, font: 'Arial',
31
+ font_size: my_data.font_size, # <-- key part
32
+ x: 10, y:10, align: :center,
33
+ width: 280, # <-- note how height does NOT need to be set
34
+ ellipsize: false,
35
+ hint: :red
36
+ save_sheet columns: 3, prefix: 'autoscale_w_data_'
37
+ end
38
+
39
+ #######################################
40
+ # Option 2: Use ellipsize: :autoscale #
41
+ #######################################
42
+ # If set the height, you can set "autoscale" and it will incrementally
43
+ # downgrade the font size until the text does not ellipsize
44
+ #
45
+ # Great for rapid prototyping, set-it-and-forget-it
46
+ #
47
+ # NOTE: You MUST set the height for this to work. Otherwise, the text will
48
+ # never ellipsize and Squib doesn't know when to start autoscaling
49
+ Squib::Deck.new(width: 300, height: 75, cards: 3) do
50
+ background color: :white
51
+ rect stroke_color: :black
52
+ title = ['Short & Big',
53
+ 'Medium Length & Size',
54
+ 'Super duper long string here, therefore a smaller font.']
55
+
56
+ # Automatically scale the text down from the specified font_size to the largest size that fits
57
+ text str: title, font: 'Arial',
58
+ font_size: 15, # <-- this is the MAX font size. Scale down from here
59
+ ellipsize: :autoscale, # <-- key part
60
+ height: 50, # <-- need this to be set to something
61
+ width: 280, x: 10, y: 10, align: :center, valign: :middle, hint: :red
62
+
63
+ save_sheet columns: 3, prefix: 'autoscale_w_ellipsize_'
64
+ end
65
+
66
+ ############################################
67
+ # Option 3: Mapping to ranges in your code #
68
+ ############################################
69
+ # Here's an in-between option that allows you to programmatically apply font
70
+ # sizes. This allows you a ton of flexibility.Probably more flexibility than
71
+ # you need, frankly. But one advantage is that you don't have to set the height
72
+ def autoscale(str_array)
73
+ str_array.map do | str |
74
+ case str.length
75
+ when 0..15
76
+ 9
77
+ when 16..20
78
+ 6
79
+ else
80
+ 4
81
+ end
82
+ end
83
+ end
84
+
85
+ Squib::Deck.new(width: 300, height: 75, cards: 3) do
86
+ background color: :white
87
+ rect stroke_color: :black
88
+ title = ['Short & Big',
89
+ 'Medium Length & Size',
90
+ 'Super duper long string here, therefore a smaller font.']
91
+
92
+ # Scale text based on the string length
93
+ text str: title, font: 'Arial',
94
+ font_size: autoscale(title), # <-- key part
95
+ x: 10, y:10, align: :center, width: 280, ellipsize: false, hint: :red
96
+
97
+ save_sheet columns: 3, prefix: 'autoscale_w_range_'
98
+ end
@@ -1,26 +1,26 @@
1
- require 'squib'
2
-
3
- # Our SVGs are auto-saved after each step using the configuration parameters
4
- Squib::Deck.new(cards: 2, config: '_backend-config.yml') do
5
-
6
- # These are all supported by the SVG backend
7
- background color: :gray
8
- text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 24', align: :center
9
- rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
10
- circle x: 100, y: 400, radius: 25
11
- triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475
12
- line x1: 100, y1: 620, x2: 720, y2: 620, stroke_width: 15.0
13
- svg file: 'spanner.svg', x: 100, y: 75
14
- png file: 'shiny-purse.png', x: 250, y: 75 # raster can still be used too
15
- png file: 'shiny-purse.png', x: 250, y: 250, mask: :red # still renders as raster
16
- # We can still rasterize whenever we want
17
- save_png prefix: 'backend_'
18
-
19
- showcase file: 'showcase.png', fill_color: 'white'
20
-
21
- # And our PDFs will be vectorized .
22
- save_pdf file: 'backend_vectorized.pdf', gap: 5
23
-
24
- # This one is a known issue. Masking an SVG onto an SVG backend is still buggy.
25
- # svg file: 'glass-heart.svg', x: 100, y: 200, width: 100, height: 100, mask: :sangria
26
- end
1
+ require 'squib'
2
+
3
+ # Our SVGs are auto-saved after each step using the configuration parameters
4
+ Squib::Deck.new(cards: 2, config: '_backend-config.yml') do
5
+
6
+ # These are all supported by the SVG backend
7
+ background color: :gray
8
+ text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 24', align: :center
9
+ rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
10
+ circle x: 100, y: 400, radius: 25
11
+ triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475
12
+ line x1: 100, y1: 620, x2: 720, y2: 620, stroke_width: 15.0
13
+ svg file: 'spanner.svg', x: 100, y: 75
14
+ png file: 'shiny-purse.png', x: 250, y: 75 # raster can still be used too
15
+ png file: 'shiny-purse.png', x: 250, y: 250, mask: :red # still renders as raster
16
+ # We can still rasterize whenever we want
17
+ save_png prefix: 'backend_'
18
+
19
+ showcase file: 'showcase.png', fill_color: 'white'
20
+
21
+ # And our PDFs will be vectorized .
22
+ save_pdf file: 'backend_vectorized.pdf', gap: 5
23
+
24
+ # This one is a known issue. Masking an SVG onto an SVG backend is still buggy.
25
+ # svg file: 'glass-heart.svg', x: 100, y: 200, width: 100, height: 100, mask: :sangria
26
+ end
data/samples/basic.rb CHANGED
@@ -1,19 +1,19 @@
1
- require 'squib'
2
-
3
- data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
4
- 'level' => [1, 2, 3] }
5
-
6
- Squib::Deck.new(width: 825, height: 1125, cards: 3) do
7
- background color: :white
8
- rect x: 38, y: 38, width: 750, height: 1050, radius: 38
9
- rect x: 75, y: 75, width: 128, height: 128, radius: 25
10
-
11
- text str: data['name'], x: 220, y: 78, font: 'Arial 18'
12
- text str: data['level'], x: 75, y: 85, width: 128,
13
- font: 'Arial 24', align: :center
14
-
15
- png range: [0, 2], file: 'shiny-purse.png', x: 620, y: 75
16
- svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
17
-
18
- save prefix: 'basic_', format: :png
19
- end
1
+ require 'squib'
2
+
3
+ data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
4
+ 'level' => [1, 2, 3] }
5
+
6
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
7
+ background color: :white
8
+ rect x: 38, y: 38, width: 750, height: 1050, radius: 38
9
+ rect x: 75, y: 75, width: 128, height: 128, radius: 25
10
+
11
+ text str: data['name'], x: 220, y: 78, font: 'Arial 18'
12
+ text str: data['level'], x: 75, y: 85, width: 128,
13
+ font: 'Arial 24', align: :center
14
+
15
+ png range: [0, 2], file: 'shiny-purse.png', x: 620, y: 75
16
+ svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
17
+
18
+ save prefix: 'basic_', format: :png
19
+ end
@@ -1,36 +1,36 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: 75, height: 75, cards: 2) do
4
- # puts "Groups enabled by environment: #{groups.to_a}"
5
-
6
- text str: ['A', 'B']
7
-
8
- build :print_n_play do
9
- rect
10
- save_sheet prefix: 'build_groups_bw_'
11
- end
12
-
13
- build :color do
14
- rect stroke_color: :red, dash: '5 5'
15
- save_png prefix: 'build_groups_color_'
16
- end
17
-
18
- build :test do
19
- save_png range: 0, prefix: 'build_groups_'
20
- end
21
-
22
- end
23
-
24
- # Here's how you can run this on the command line:
25
- #
26
- # --- OSX/Linux (bash or similar shells) ---
27
- # $ ruby build_groups.rb
28
- # $ SQUIB_BUILD=color ruby build_groups.rb
29
- # $ SQUIB_BUILD=print_n_play,test ruby build_groups.rb
30
- #
31
- # --- Windows CMD ---
32
- # $ ruby build_groups.rb
33
- # $ set SQUIB_BUILD=color && ruby build_groups.rb
34
- # $ set SQUIB_BUILD=print_n_play,test && ruby build_groups.rb
35
- #
36
- # Or, better yet... use a Rakefile like the one provided in this gist!
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 75, height: 75, cards: 2) do
4
+ # puts "Groups enabled by environment: #{groups.to_a}"
5
+
6
+ text str: ['A', 'B']
7
+
8
+ build :print_n_play do
9
+ rect
10
+ save_sheet prefix: 'build_groups_bw_'
11
+ end
12
+
13
+ build :color do
14
+ rect stroke_color: :red, dash: '5 5'
15
+ save_png prefix: 'build_groups_color_'
16
+ end
17
+
18
+ build :test do
19
+ save_png range: 0, prefix: 'build_groups_'
20
+ end
21
+
22
+ end
23
+
24
+ # Here's how you can run this on the command line:
25
+ #
26
+ # --- OSX/Linux (bash or similar shells) ---
27
+ # $ ruby build_groups.rb
28
+ # $ SQUIB_BUILD=color ruby build_groups.rb
29
+ # $ SQUIB_BUILD=print_n_play,test ruby build_groups.rb
30
+ #
31
+ # --- Windows CMD ---
32
+ # $ ruby build_groups.rb
33
+ # $ set SQUIB_BUILD=color && ruby build_groups.rb
34
+ # $ set SQUIB_BUILD=print_n_play,test && ruby build_groups.rb
35
+ #
36
+ # Or, better yet... use a Rakefile like the one provided in this gist!
@@ -1,44 +1,44 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
- background color: :white
5
-
6
- y = 0
7
- text color: '#f00', str: '3-hex', x: 50, y: y += 50
8
- text color: '#f00', str: '3-hex (alpha)', x: 50, y: y += 50
9
- text color: '#ff0000', str: '6-hex', x: 50, y: y += 50
10
- text color: '#ff000099', str: '8-hex(alpha)', x: 50, y: y += 50
11
- text color: '#ffff00000000', str: '12-hex', x: 50, y: y += 50
12
- text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y += 50
13
- text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y += 50
14
- text color: '(0,0)(400,0) blue@0.0 red@1.0', str: 'Linear gradients!', x: 50, y: y += 50
15
- text color: '(200,500,10)(200,500,100) blue@0.0 red@1.0', str: 'Radial gradients!', x: 50, y: y += 50
16
- # see gradients.rb sample for more on gradients
17
-
18
- save_png prefix: 'colors_'
19
- end
20
-
21
- # This script generates a table of the built-in constants
22
- colors = (Cairo::Color.constants - %i(HEX_RE Base RGB CMYK HSV X11))
23
- colors.sort_by! do |c|
24
- hsv = Cairo::Color.parse(c).to_hsv
25
- [(hsv.hue / 16.0).to_i, hsv.value, hsv.saturation]
26
- end
27
- w, h = 300, 50
28
- deck_height = 4000
29
- deck_width = (colors.size / ((deck_height / h) + 1)) * w
30
- Squib::Deck.new(width: deck_width, height: deck_height) do
31
- background color: :white
32
- x, y = 0, 0
33
- colors.each_with_index do |color, i|
34
- rect x: x, y: y, width: w, height: h, fill_color: color
35
- text str: color.to_s, x: x + 5, y: y + 13, font: 'Sans Bold 5',
36
- color: (Cairo::Color.parse(color).to_hsv.v > 0.9) ? '#000' : '#fff'
37
- y += h
38
- if y > deck_height
39
- x += w
40
- y = 0
41
- end
42
- end
43
- save_png prefix: 'color_constants_'
44
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
+ background color: :white
5
+
6
+ y = 0
7
+ text color: '#f00', str: '3-hex', x: 50, y: y += 50
8
+ text color: '#f00', str: '3-hex (alpha)', x: 50, y: y += 50
9
+ text color: '#ff0000', str: '6-hex', x: 50, y: y += 50
10
+ text color: '#ff000099', str: '8-hex(alpha)', x: 50, y: y += 50
11
+ text color: '#ffff00000000', str: '12-hex', x: 50, y: y += 50
12
+ text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y += 50
13
+ text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y += 50
14
+ text color: '(0,0)(400,0) blue@0.0 red@1.0', str: 'Linear gradients!', x: 50, y: y += 50
15
+ text color: '(200,500,10)(200,500,100) blue@0.0 red@1.0', str: 'Radial gradients!', x: 50, y: y += 50
16
+ # see gradients.rb sample for more on gradients
17
+
18
+ save_png prefix: 'colors_'
19
+ end
20
+
21
+ # This script generates a table of the built-in constants
22
+ colors = (Cairo::Color.constants - %i(HEX_RE Base RGB CMYK HSV X11))
23
+ colors.sort_by! do |c|
24
+ hsv = Cairo::Color.parse(c).to_hsv
25
+ [(hsv.hue / 16.0).to_i, hsv.value, hsv.saturation]
26
+ end
27
+ w, h = 300, 50
28
+ deck_height = 4000
29
+ deck_width = (colors.size / ((deck_height / h) + 1)) * w
30
+ Squib::Deck.new(width: deck_width, height: deck_height) do
31
+ background color: :white
32
+ x, y = 0, 0
33
+ colors.each_with_index do |color, i|
34
+ rect x: x, y: y, width: w, height: h, fill_color: color
35
+ text str: color.to_s, x: x + 5, y: y + 13, font: 'Sans Bold 5',
36
+ color: (Cairo::Color.parse(color).to_hsv.v > 0.9) ? '#000' : '#fff'
37
+ y += h
38
+ if y > deck_height
39
+ x += w
40
+ y = 0
41
+ end
42
+ end
43
+ save_png prefix: 'color_constants_'
44
+ end
@@ -1,34 +1,34 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new do
4
- # Just about anywhere Squib takes in a color it can also take in a gradient too
5
- # The x-y coordinates on the card itself,
6
- # and then color stops are defined between 0 and 1
7
- background color: '(0,0)(0,1125) #ccc@0.0 #111@1.0'
8
- line stroke_color: '(0,0)(825,0) #111@1.0 #ccc@0.0',
9
- x1: 0, y1: 600, x2: 825, y2: 600,
10
- stroke_width: 15
11
-
12
- # Radial gradients look like this
13
- circle fill_color: '(425,400,2)(425,400,120) #ccc@0.0 #111@1.0',
14
- x: 415, y: 415, radius: 100, stroke_color: '#0000'
15
- triangle fill_color: '(650,400,2)(650,400,120) #ccc@0.0 #111@1.0',
16
- stroke_color: '#0000',
17
- x1: 650, y1: 360,
18
- x2: 550, y2: 500,
19
- x3: 750, y3: 500
20
-
21
- # Gradients are also good for beveling effects:
22
- rect fill_color: '(0,200)(0,600) #111@0.0 #ccc@1.0',
23
- x: 30, y: 350, width: 150, height: 150,
24
- radius: 15, stroke_color: '#0000'
25
- rect fill_color: '(0,200)(0,600) #111@1.0 #ccc@0.0',
26
- x: 40, y: 360, width: 130, height: 130,
27
- radius: 15, stroke_color: '#0000'
28
-
29
- # Alpha transparency can be used too
30
- text str: 'Hello, world!', x: 75, y: 700, font: 'Sans Bold 24',
31
- color: '(0,0)(825,0) #000f@0.0 #0000@1.0'
32
-
33
- save_png prefix: 'gradient_'
34
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new do
4
+ # Just about anywhere Squib takes in a color it can also take in a gradient too
5
+ # The x-y coordinates on the card itself,
6
+ # and then color stops are defined between 0 and 1
7
+ background color: '(0,0)(0,1125) #ccc@0.0 #111@1.0'
8
+ line stroke_color: '(0,0)(825,0) #111@1.0 #ccc@0.0',
9
+ x1: 0, y1: 600, x2: 825, y2: 600,
10
+ stroke_width: 15
11
+
12
+ # Radial gradients look like this
13
+ circle fill_color: '(425,400,2)(425,400,120) #ccc@0.0 #111@1.0',
14
+ x: 415, y: 415, radius: 100, stroke_color: '#0000'
15
+ triangle fill_color: '(650,400,2)(650,400,120) #ccc@0.0 #111@1.0',
16
+ stroke_color: '#0000',
17
+ x1: 650, y1: 360,
18
+ x2: 550, y2: 500,
19
+ x3: 750, y3: 500
20
+
21
+ # Gradients are also good for beveling effects:
22
+ rect fill_color: '(0,200)(0,600) #111@0.0 #ccc@1.0',
23
+ x: 30, y: 350, width: 150, height: 150,
24
+ radius: 15, stroke_color: '#0000'
25
+ rect fill_color: '(0,200)(0,600) #111@1.0 #ccc@0.0',
26
+ x: 40, y: 360, width: 130, height: 130,
27
+ radius: 15, stroke_color: '#0000'
28
+
29
+ # Alpha transparency can be used too
30
+ text str: 'Hello, world!', x: 75, y: 700, font: 'Sans Bold 24',
31
+ color: '(0,0)(825,0) #000f@0.0 #0000@1.0'
32
+
33
+ save_png prefix: 'gradient_'
34
+ end
@@ -1,33 +1,33 @@
1
- require_relative '../../lib/squib'
2
-
3
- # Choose between black and white color theme for type snake
4
- # * Allow using white snake cards with black text or
5
- # black snake cards with white text
6
- color = 'white'
7
-
8
- cards = Squib.csv file: '_switch_color_data.csv'
9
-
10
- Squib::Deck.new cards: cards['Type'].size do
11
-
12
- background_color = cards['Type'].map do |t|
13
- if color == 'black' && t == "Snake" then
14
- "black"
15
- else
16
- "white"
17
- end
18
- end
19
- background color: background_color
20
-
21
- text_color = cards['Type'].map do |t|
22
- if color == 'black' && t == "Snake" then
23
- "white"
24
- else
25
- "black"
26
- end
27
- end
28
-
29
- text str: cards['Text'], color: text_color
30
-
31
- save_png prefix: '_switch_color_sample_'
32
-
33
- end
1
+ require_relative '../../lib/squib'
2
+
3
+ # Choose between black and white color theme for type snake
4
+ # * Allow using white snake cards with black text or
5
+ # black snake cards with white text
6
+ color = 'white'
7
+
8
+ cards = Squib.csv file: '_switch_color_data.csv'
9
+
10
+ Squib::Deck.new cards: cards['Type'].size do
11
+
12
+ background_color = cards['Type'].map do |t|
13
+ if color == 'black' && t == "Snake" then
14
+ "black"
15
+ else
16
+ "white"
17
+ end
18
+ end
19
+ background color: background_color
20
+
21
+ text_color = cards['Type'].map do |t|
22
+ if color == 'black' && t == "Snake" then
23
+ "white"
24
+ else
25
+ "black"
26
+ end
27
+ end
28
+
29
+ text str: cards['Text'], color: text_color
30
+
31
+ save_png prefix: '_switch_color_sample_'
32
+
33
+ end
@@ -1,20 +1,20 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(config: 'config_text_markup.yml') do
4
- background color: :white
5
- text str: %{"'Yaml ain't markup', he says"},
6
- x: 10, y: 10, width: 300, height: 200, font: 'Serif 7',
7
- markup: true, hint: :cyan
8
-
9
- text str: 'Notice also the antialiasing method.',
10
- x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 7'
11
-
12
- save_png prefix: 'config_text_'
13
- end
14
-
15
- Squib::Deck.new(config: 'config_disable_quotes.yml') do
16
- text str: %{This has typographic sugar --- and ``explicit'' quotes --- but the quotes are "dumb"},
17
- x: 10, y: 10, width: 300, height: 200, font: 'Serif 7',
18
- markup: true, hint: :cyan
19
- save_png prefix: 'config_disable_text_'
20
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(config: 'config_text_markup.yml') do
4
+ background color: :white
5
+ text str: %{"'Yaml ain't markup', he says"},
6
+ x: 10, y: 10, width: 300, height: 200, font: 'Serif 7',
7
+ markup: true, hint: :cyan
8
+
9
+ text str: 'Notice also the antialiasing method.',
10
+ x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 7'
11
+
12
+ save_png prefix: 'config_text_'
13
+ end
14
+
15
+ Squib::Deck.new(config: 'config_disable_quotes.yml') do
16
+ text str: %{This has typographic sugar --- and ``explicit'' quotes --- but the quotes are "dumb"},
17
+ x: 10, y: 10, width: 300, height: 200, font: 'Serif 7',
18
+ markup: true, hint: :cyan
19
+ save_png prefix: 'config_disable_text_'
20
+ end