squib 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.gitmodules +22 -0
  4. data/.travis.yml +4 -5
  5. data/CHANGELOG.md +23 -0
  6. data/CONTRIBUTING.md +40 -0
  7. data/README.md +25 -553
  8. data/RELEASE TODO.md +2 -2
  9. data/Rakefile +6 -64
  10. data/appveyor.yml +0 -4
  11. data/benchmarks/antialias_best.rb +2 -2
  12. data/benchmarks/antialias_fast.rb +2 -2
  13. data/benchmarks/{backend-memory.rb → backend_memory.rb} +2 -2
  14. data/benchmarks/{backend-svg.rb → backend_svg.rb} +2 -2
  15. data/benchmarks/tons_of_png.rb +1 -1
  16. data/benchmarks/tons_of_svg.rb +1 -1
  17. data/benchmarks/tons_of_text.rb +1 -1
  18. data/docs/Makefile +216 -0
  19. data/docs/_static/css/squibdocs.css +18 -0
  20. data/docs/args/draw.rst +36 -0
  21. data/docs/args/expansion.rst +3 -0
  22. data/docs/args/layout.rst +6 -0
  23. data/docs/args/output_dir.rst +6 -0
  24. data/docs/args/range.rst +6 -0
  25. data/docs/args/transform.rst +51 -0
  26. data/docs/args/trim.rst +11 -0
  27. data/docs/args/wh.rst +12 -0
  28. data/docs/args/xy.rst +12 -0
  29. data/docs/arrays.rst +77 -0
  30. data/docs/backends.rst +20 -0
  31. data/docs/bleed.rst +13 -0
  32. data/docs/build_groups.rst +47 -0
  33. data/docs/colors.rst +64 -0
  34. data/docs/conf.py +287 -0
  35. data/docs/config.rst +117 -0
  36. data/docs/data.rst +22 -0
  37. data/docs/dsl/background.rst +20 -0
  38. data/docs/dsl/build.rst +32 -0
  39. data/docs/dsl/build_groups.rst +23 -0
  40. data/docs/dsl/circle.rst +27 -0
  41. data/docs/dsl/cm.rst +19 -0
  42. data/docs/dsl/csv.rst +62 -0
  43. data/docs/dsl/curve.rst +63 -0
  44. data/docs/dsl/deck.rst +45 -0
  45. data/docs/dsl/disable_build.rst +28 -0
  46. data/docs/dsl/ellipse.rst +17 -0
  47. data/docs/dsl/enable_build.rst +25 -0
  48. data/docs/dsl/grid.rst +31 -0
  49. data/docs/dsl/hand.rst +40 -0
  50. data/docs/dsl/hint.rst +15 -0
  51. data/docs/dsl/inches.rst +19 -0
  52. data/docs/dsl/index.rst +9 -0
  53. data/docs/dsl/line.rst +52 -0
  54. data/docs/dsl/png.rst +49 -0
  55. data/docs/dsl/polygon.rst +28 -0
  56. data/docs/dsl/rect.rst +18 -0
  57. data/docs/dsl/save.rst +23 -0
  58. data/docs/dsl/save_pdf.rst +48 -0
  59. data/docs/dsl/save_png.rst +46 -0
  60. data/docs/dsl/save_sheet.rst +55 -0
  61. data/docs/dsl/showcase.rst +65 -0
  62. data/docs/dsl/star.rst +35 -0
  63. data/docs/dsl/svg.rst +119 -0
  64. data/docs/dsl/text.rst +294 -0
  65. data/docs/dsl/triangle.rst +38 -0
  66. data/docs/dsl/use_layout.rst +16 -0
  67. data/docs/dsl/xlsx.rst +50 -0
  68. data/docs/guides/game_icons.rst +2 -0
  69. data/docs/guides/getting-started/index.rst +5 -0
  70. data/docs/guides/getting-started/part_0_learning_ruby.rst +145 -0
  71. data/docs/guides/getting-started/part_1_zero_to_game.rst +216 -0
  72. data/docs/guides/getting-started/part_2_iconography.rst +152 -0
  73. data/docs/guides/getting-started/part_3_workflows.rst +4 -0
  74. data/docs/guides/git.rst +13 -0
  75. data/docs/guides/hello_world.rst +6 -0
  76. data/docs/help.rst +157 -0
  77. data/docs/index.rst +35 -0
  78. data/docs/install.rst +66 -0
  79. data/docs/layouts.rst +235 -0
  80. data/docs/learning.rst +10 -0
  81. data/docs/make.bat +263 -0
  82. data/docs/parameters.rst +26 -0
  83. data/docs/server.bat +1 -0
  84. data/docs/text_feature.rst +86 -0
  85. data/docs/units.rst +6 -0
  86. data/lib/squib.rb +4 -4
  87. data/lib/squib/api/background.rb +5 -10
  88. data/lib/squib/api/data.rb +30 -54
  89. data/lib/squib/api/groups.rb +47 -0
  90. data/lib/squib/api/image.rb +8 -67
  91. data/lib/squib/api/save.rb +15 -105
  92. data/lib/squib/api/settings.rb +8 -22
  93. data/lib/squib/api/shapes.rb +15 -185
  94. data/lib/squib/api/text.rb +9 -49
  95. data/lib/squib/api/text_embed.rb +12 -12
  96. data/lib/squib/api/units.rb +3 -17
  97. data/lib/squib/args/arg_loader.rb +6 -6
  98. data/lib/squib/args/box.rb +2 -2
  99. data/lib/squib/args/card_range.rb +1 -1
  100. data/lib/squib/args/color_validator.rb +2 -2
  101. data/lib/squib/args/coords.rb +2 -2
  102. data/lib/squib/args/csv_opts.rb +25 -0
  103. data/lib/squib/args/dir_validator.rb +1 -1
  104. data/lib/squib/args/draw.rb +2 -2
  105. data/lib/squib/args/embed_adjust.rb +1 -1
  106. data/lib/squib/args/embed_key.rb +1 -1
  107. data/lib/squib/args/hand_special.rb +37 -37
  108. data/lib/squib/args/import.rb +2 -2
  109. data/lib/squib/args/input_file.rb +1 -1
  110. data/lib/squib/args/paint.rb +3 -3
  111. data/lib/squib/args/paragraph.rb +2 -2
  112. data/lib/squib/args/save_batch.rb +2 -2
  113. data/lib/squib/args/scale_box.rb +1 -1
  114. data/lib/squib/args/sheet.rb +3 -3
  115. data/lib/squib/args/showcase_special.rb +2 -2
  116. data/lib/squib/args/svg_special.rb +1 -1
  117. data/lib/squib/args/transform.rb +2 -2
  118. data/lib/squib/args/typographer.rb +5 -4
  119. data/lib/squib/args/unit_conversion.rb +4 -4
  120. data/lib/squib/card.rb +8 -8
  121. data/lib/squib/conf.rb +5 -5
  122. data/lib/squib/deck.rb +20 -18
  123. data/lib/squib/graphics/cairo_context_wrapper.rb +3 -3
  124. data/lib/squib/graphics/gradient_regex.rb +1 -1
  125. data/lib/squib/graphics/hand.rb +2 -2
  126. data/lib/squib/graphics/save_doc.rb +9 -8
  127. data/lib/squib/graphics/save_images.rb +24 -11
  128. data/lib/squib/graphics/shapes.rb +16 -17
  129. data/lib/squib/graphics/showcase.rb +9 -9
  130. data/lib/squib/graphics/text.rb +21 -21
  131. data/lib/squib/layout_parser.rb +9 -9
  132. data/lib/squib/layouts/economy.yml +85 -85
  133. data/lib/squib/layouts/fantasy.yml +101 -101
  134. data/lib/squib/layouts/hand.yml +62 -62
  135. data/lib/squib/layouts/playing-card.yml +35 -35
  136. data/lib/squib/layouts/tuck_box.yml +45 -45
  137. data/lib/squib/sample_helpers.rb +1 -1
  138. data/lib/squib/version.rb +1 -1
  139. data/samples/{backend.rb → backend/_backend.rb} +2 -2
  140. data/samples/basic.rb +3 -3
  141. data/samples/bug134.rb +14 -0
  142. data/samples/build_groups/build_groups.rb +36 -0
  143. data/samples/cairo_access.rb +12 -1
  144. data/samples/{colors.rb → colors/_colors.rb} +12 -12
  145. data/samples/{gradients.rb → colors/_gradients.rb} +1 -1
  146. data/samples/config_text_markup.rb +2 -2
  147. data/samples/custom-config.yml +5 -5
  148. data/samples/custom_config.rb +18 -18
  149. data/samples/{csv_import.rb → data/_csv.rb} +8 -1
  150. data/samples/{excel.rb → data/_excel.rb} +3 -3
  151. data/samples/embed_text.rb +21 -0
  152. data/samples/hello_world.rb +1 -1
  153. data/samples/{load_images.rb → images/_more_load_images.rb} +2 -2
  154. data/samples/layouts.rb +11 -1
  155. data/samples/layouts_builtin.rb +51 -51
  156. data/samples/offset.svg +71 -71
  157. data/samples/ranges.rb +7 -7
  158. data/samples/{hand.rb → saves/_hand.rb} +1 -2
  159. data/samples/{portrait-landscape.rb → saves/_portrait_landscape.rb} +4 -4
  160. data/samples/{saves.rb → saves/_saves.rb} +0 -0
  161. data/samples/{showcase.rb → saves/_showcase.rb} +2 -2
  162. data/samples/{draw_shapes.rb → shapes/_draw_shapes.rb} +1 -1
  163. data/samples/text/_text.rb +4 -3
  164. data/samples/text_options.rb +6 -6
  165. data/samples/unicode.rb +1 -1
  166. data/spec/api/api_data_spec.rb +59 -4
  167. data/spec/api/api_settings_spec.rb +1 -1
  168. data/spec/args/box_spec.rb +7 -7
  169. data/spec/args/draw_spec.rb +19 -19
  170. data/spec/args/embed_key_spec.rb +13 -13
  171. data/spec/args/input_file_spec.rb +2 -2
  172. data/spec/args/paint_spec.rb +5 -5
  173. data/spec/args/paragraph_spec.rb +28 -28
  174. data/spec/args/range_spec.rb +1 -1
  175. data/spec/args/save_batch_spec.rb +10 -10
  176. data/spec/args/scale_box_spec.rb +9 -9
  177. data/spec/args/sheet_spec.rb +8 -8
  178. data/spec/args/showcase_special_spec.rb +15 -15
  179. data/spec/args/transform_spec.rb +4 -4
  180. data/spec/args/typographer_spec.rb +11 -11
  181. data/spec/args/unit_conversion_spec.rb +2 -2
  182. data/spec/card_spec.rb +1 -1
  183. data/spec/commands/new_spec.rb +1 -1
  184. data/spec/data/csv/custom_opts.csv +2 -0
  185. data/spec/data/csv/newline.csv +3 -0
  186. data/spec/data/csv/qty.csv +2 -2
  187. data/spec/data/csv/qty_named.csv +2 -2
  188. data/spec/data/csv/with_spaces.csv +2 -2
  189. data/spec/data/csv/yield.csv +3 -0
  190. data/spec/data/samples/{autoscale_font.rb.txt → autoscale_font/_autoscale_font.rb.txt} +55 -18
  191. data/spec/data/samples/cairo_access.rb.txt +24 -0
  192. data/spec/data/samples/{gradients.rb.txt → colors/_gradients.rb.txt} +0 -0
  193. data/spec/data/samples/config_text_markup.rb.txt +72 -72
  194. data/spec/data/samples/custom_config.rb.txt +1 -0
  195. data/spec/data/samples/{csv_import.rb.txt → data/_csv.rb.txt} +0 -0
  196. data/spec/data/samples/{excel.rb.txt → data/_excel.rb.txt} +0 -0
  197. data/spec/data/samples/embed_text.rb.txt +79 -0
  198. data/spec/data/samples/hello_world.rb.txt +36 -36
  199. data/spec/data/samples/{load_images.rb.txt → images/_more_load_images.rb.txt} +4 -4
  200. data/spec/data/samples/{hand.rb.txt → saves/_hand.rb.txt} +0 -0
  201. data/spec/data/samples/{portrait-landscape.rb.txt → saves/_portrait_landscape.rb.txt} +11 -7
  202. data/spec/data/samples/{save_pdf.rb.txt → saves/_save_pdf.rb.txt} +0 -0
  203. data/spec/data/samples/{saves.rb.txt → saves/_saves.rb.txt} +3 -4
  204. data/spec/data/samples/{showcase.rb.txt → saves/_showcase.rb.txt} +0 -0
  205. data/spec/data/samples/{draw_shapes.rb.txt → shapes/_draw_shapes.rb.txt} +0 -0
  206. data/spec/data/samples/text_options.rb.txt +1125 -1125
  207. data/spec/graphics/cairo_context_wrapper_spec.rb +10 -10
  208. data/spec/graphics/graphics_save_doc_spec.rb +11 -5
  209. data/spec/layout_parser_spec.rb +21 -9
  210. data/spec/logger_spec.rb +2 -2
  211. data/spec/samples/run_samples_spec.rb +1 -1
  212. data/spec/samples/samples_regression_spec.rb +16 -18
  213. data/spec/samples/sanity.rb +9 -9
  214. data/spec/sanity/.gitignore +1 -0
  215. data/spec/sanity/sanity.html.erb +42 -0
  216. data/spec/sanity/sanity_test.rb +42 -0
  217. data/spec/sanity/tests.yml +12 -0
  218. data/spec/spec_helper.rb +22 -20
  219. data/squib.gemspec +3 -4
  220. metadata +143 -81
  221. data/.rspec +0 -1
  222. data/.yardopts +0 -10
  223. data/samples/autoscale_font.rb +0 -27
  224. data/samples/backend-config.yml +0 -5
  225. data/samples/color_shortcuts.rb +0 -6
  226. data/samples/explode_quantities.xlsx +0 -0
  227. data/samples/quantity_explosion.csv +0 -3
  228. data/samples/sample.csv +0 -3
  229. data/samples/sample.xlsx +0 -0
  230. data/squib.sublime-project +0 -42
@@ -0,0 +1,55 @@
1
+ save_sheet
2
+ ==========
3
+
4
+ Lays out the cards in range and renders a stitched PNG sheet
5
+
6
+ Options
7
+ -------
8
+
9
+ range
10
+ default: ``:all``
11
+
12
+ the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
13
+
14
+ columns
15
+ default: ``5``
16
+
17
+ the number of columns in the grid. Must be an integer
18
+
19
+ rows
20
+ default: ``:infinite``
21
+
22
+ the number of rows in the grid. When set to :infinite, the sheet scales to the rows needed. If there are more cards than rows*columns, new sheets are started.
23
+
24
+ prefix
25
+ default: ``card_``
26
+
27
+ the prefix of the file name(s)
28
+
29
+ count_format
30
+ default: ``'%02d'``
31
+
32
+ the format string used for formatting the card count (e.g. padding zeros). Uses a Ruby format string (see the Ruby doc for ``Kernel::sprintf`` for specifics)
33
+
34
+ dir
35
+ default: ``'_output'``
36
+
37
+ the directory to save to. Created if it doesn't exist.
38
+
39
+ margin
40
+ default: ``0``
41
+
42
+ the margin around the outside of the sheet. Supports :doc:`/units`.
43
+
44
+ gap
45
+ default ``0``
46
+
47
+ the space in pixels between the cards. Supports :doc:`/units`.
48
+
49
+ trim
50
+ default ``0``
51
+
52
+ the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports :doc:`/units`.
53
+
54
+ Examples
55
+ --------
@@ -0,0 +1,65 @@
1
+ showcase
2
+ ========
3
+
4
+ Renders a range of cards in a showcase as if they are sitting in 3D on a reflective surface.
5
+
6
+ Options
7
+ -------
8
+
9
+ .. include:: /args/trim.rst
10
+
11
+ scale
12
+ default: ``0.8``
13
+
14
+ Percentage of original width of each (trimmed) card to scale to. Must be between 0.0 and 1.0, but starts looking bad around 0.6.
15
+
16
+ offset
17
+ default: ``1.1``
18
+
19
+ Percentage of the scaled width of each card to shift each offset. e.g. 1.1 is a 10% shift, and 0.95 is overlapping by 5%
20
+
21
+ fill_color
22
+ default: ``:white``
23
+
24
+ Backdrop color. Usually black or white. See :doc:`/colors`.
25
+
26
+ reflect_offset
27
+ default: ``15``
28
+
29
+ The number of pixels between the bottom of the card and the reflection. See :doc:`/units`
30
+
31
+ reflect_strength
32
+ default: ``0.2``
33
+
34
+ The starting alpha transparency of the reflection (at the top of the card). Percentage between 0 and 1. Looks more realistic at low values since even shiny surfaces lose a lot of light.
35
+
36
+ reflect_percent
37
+ default: ``0.25``
38
+
39
+ The length of the reflection in percentage of the card. Larger values tend to make the reflection draw just as much attention as the card, which is not good.
40
+
41
+ face
42
+ default: ``:left``
43
+
44
+ which direction the cards face. Anything but ``:right`` will face left
45
+
46
+ margin
47
+ default: ``75``
48
+
49
+ the margin around the entire image. Supports :doc:`/units`
50
+
51
+ fill_color
52
+ default: ``:white``
53
+
54
+ Backdrop color. Supports :doc:`/colors`.
55
+
56
+ file
57
+ default: ``'showcase.png'``
58
+
59
+ The file to save relative to the current directory. Will overwrite without warning.
60
+
61
+ .. include:: /args/output_dir.rst
62
+ .. include:: /args/range.rst
63
+
64
+ Examples
65
+ --------
data/docs/dsl/star.rst ADDED
@@ -0,0 +1,35 @@
1
+ star
2
+ ----
3
+
4
+ Draw an n-pointed star, centered at x,y.
5
+
6
+ Options
7
+ ^^^^^^^
8
+ .. include:: /args/expansion.rst
9
+
10
+ .. include:: /args/xy.rst
11
+
12
+ inner_radius
13
+ default: 0
14
+
15
+ the distance from the center of the star to the inner circle of its points. Supports :doc:`/units`.
16
+
17
+
18
+ outer_radius
19
+ default: 0
20
+
21
+ the distance from the center of the star to the outer circle of its points. Supports :doc:`/units`.
22
+
23
+
24
+ angle
25
+ default: 0
26
+
27
+ the angle at which to rotate the star
28
+
29
+
30
+ .. include:: /args/draw.rst
31
+ .. include:: /args/range.rst
32
+ .. include:: /args/layout.rst
33
+
34
+ Examples
35
+ ^^^^^^^^
data/docs/dsl/svg.rst ADDED
@@ -0,0 +1,119 @@
1
+ svg
2
+ ===
3
+
4
+ Renders an entire svg file at the given location. Uses the SVG-specified units and DPI to determine the pixel width and height. If neither data nor file are specified for a given card, this method does nothing.
5
+
6
+ .. note::
7
+
8
+ Note: if alpha transparency is desired, set that in the SVG.
9
+
10
+
11
+ Options
12
+ -------
13
+ .. include:: /args/expansion.rst
14
+
15
+ file
16
+ default: ``''`` (empty string)
17
+
18
+ file(s) to read in. As in :doc:`/arrays`, if this a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done for that card.
19
+
20
+ .. include:: /args/xy.rst
21
+
22
+ range
23
+ default: ``all``
24
+
25
+ the range of cards over which this will be rendered. See :doc:`/arrays`
26
+
27
+ data
28
+ default: ``nil``
29
+
30
+ render from an SVG XML string. Overrides ``file`` if both are specified (a warning is shown).
31
+
32
+ id
33
+ default: ``nil``
34
+
35
+ if set, then only render the SVG element with the given id. Prefix '#' is optional. Note: the x-y coordinates are still relative to the SVG document's page.
36
+
37
+ force_id
38
+ default: ``false``
39
+
40
+ if set to ``true``, then this svg will not be rendered at all if the id is empty or nil. If not set, the entire SVG is rendered. Useful for putting multple icons in a single SVG file.
41
+
42
+ width
43
+ default: ``native``
44
+
45
+ the pixel width that the image should scale to. Setting this to ``:deck`` will scale to the deck height. ``:scale`` will use the width to scale and keep native the aspect ratio. SVG scaling is done with vectors, so the scaling should be smooth. When set to ``:native``, uses the DPI and units of the loaded SVG document.
46
+
47
+ height
48
+ default: ``:native``
49
+
50
+ the pixel width that the image should scale to. ``:deck`` will scale to the deck height. ``:scale`` will use the width to scale and keep native the aspect ratio. SVG scaling is done with vectors, so the scaling should be smooth. When set to ``:native``, uses the DPI and units of the loaded SVG document.
51
+
52
+ blend
53
+ default: ``:none``
54
+
55
+ the composite blend operator used when applying this image. See Blend Modes at http://cairographics.org/operators.
56
+ The possibilties include :none, :multiply, :screen, :overlay, :darken, :lighten, :color_dodge, :color_burn, :hard_light, :soft_light, :difference, :exclusion, :hsl_hue, :hsl_saturation, :hsl_color, :hsl_luminosity. String versions of these options are accepted too.
57
+
58
+
59
+ angle
60
+ default: ``0``
61
+
62
+ rotation of the image in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky.
63
+
64
+ mask
65
+ default: ``nil``
66
+
67
+ if specified, the image will be used as a mask for the given color/gradient. Transparent pixels are ignored, opaque pixels are the given color. Note: the origin for gradient coordinates is at the given x,y, not at 0,0 as it is most other places.
68
+
69
+ crop_x
70
+ default: ``0``
71
+
72
+ rop the loaded image at this x coordinate. Supports :doc:`/units`
73
+
74
+ crop_y
75
+ default: ``0``
76
+
77
+ rop the loaded image at this y coordinate. Supports :doc:`/units`
78
+
79
+ crop_corner_radius
80
+ default: ``0``
81
+
82
+ Radius for rounded corners, both x and y. When set, overrides crop_corner_x_radius and crop_corner_y_radius. Supports :doc:`/units`
83
+
84
+ crop_corner_x_radius
85
+ default: ``0``
86
+
87
+ x radius for rounded corners of cropped image. Supports :doc:`/units`
88
+
89
+ crop_corner_y_radius
90
+ default: ``0``
91
+
92
+ y radius for rounded corners of cropped image. Supports :doc:`/units`
93
+
94
+ crop_width
95
+ default: ``0``
96
+
97
+ width of the cropped image. Supports :doc:`/units`
98
+
99
+ crop_height
100
+ default: ``0``
101
+
102
+ ive): Height of the cropped image. Supports :doc:`/units`
103
+
104
+ flip_horiztonal
105
+ default: ``false``
106
+
107
+ Flip this image about its center horizontally (i.e. left becomes right and vice versa).
108
+
109
+ flip_vertical
110
+ default: ``false``
111
+
112
+ Flip this image about its center verticall (i.e. top becomes bottom and vice versa).
113
+
114
+ .. include:: /args/range.rst
115
+ .. include:: /args/layout.rst
116
+
117
+
118
+ Examples
119
+ --------
data/docs/dsl/text.rst ADDED
@@ -0,0 +1,294 @@
1
+ text
2
+ ====
3
+
4
+ Renders a string at a given location, width, alignment, font, etc.
5
+
6
+ Unix newlines are interpreted even on Windows (i.e. ``"\n"``).
7
+
8
+
9
+ Options
10
+ -------
11
+ .. include:: /args/expansion.rst
12
+
13
+ str
14
+ default: ``''``
15
+
16
+ the string to be rendered. Must support ``#to_s``.
17
+
18
+ font
19
+ default: ``'Arial 36'``
20
+
21
+ the Font description string, including family, styles, and size. (e.g. ``'Arial bold italic 12'``). For the official documentation, see the `Pango docs <http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3AFontDescription#style>)`_. This `description <http://www.pygtk.org/pygtk2reference/class-pangofontdescription.html>`_ is also quite good.
22
+
23
+ font_size
24
+ default: ``nil``
25
+
26
+ an override of font string description (i.e. ``font``).
27
+
28
+ .. include:: /args/xy.rst
29
+
30
+ markup:
31
+ default: ``false``
32
+
33
+ When set to true, various extra styles are allowed. See :ref:`Markup <text-markup>`.
34
+
35
+ width
36
+ default: ``:auto``
37
+
38
+ the width of the box the string will be placed in. Stretches to the content by default.. Supports :doc:`/units`.
39
+
40
+ height
41
+ default: ``:auto``
42
+
43
+ the height of the box the string will be placed in. Stretches to the content by default. Supports :doc:`/units`.
44
+
45
+ wrap
46
+ default: ``:word_char``
47
+
48
+ when ``width`` is set, determines the behavior of how the string wraps. The ``:word_char`` option will break at words, but then fall back to characters when the word cannot fit. Options are ``:none``, ``:word``, ``:char``, ``:word_char``. Also: ``true`` is the same as ``:word_char``, ``false`` is the same as ``:none``.
49
+
50
+ spacing
51
+ default: ``0``
52
+
53
+ Adjust the spacing when the text is multiple lines. No effect when the text does not wrap.
54
+
55
+ align
56
+ default: ``:left``
57
+
58
+ The alignment of the text. [:left, right, :center]
59
+
60
+ justify
61
+ default: ``false``
62
+
63
+ toggles whether or not the text is justified or not.
64
+
65
+ valign
66
+ default: ``:top``
67
+
68
+ When width and height are set, align text vertically according to the ink extents of the text. [:top, :middle, :bottom]
69
+
70
+ ellipsize
71
+ default: ``:end``
72
+
73
+ When width and height are set, determines the behavior of overflowing text. Also: `true` maps to `:end` and `false` maps to `:none`. Default `:end` [:none, :start, :middle, :end, true, false]. Also, as mentioned in :doc:`/config`, if text is ellipsized a warning is thrown.
74
+
75
+ angle
76
+ default: ``0``
77
+
78
+ Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
79
+
80
+ stroke_width
81
+ default: ``0.0``
82
+
83
+ the width of the outside stroke. Supports :doc:`/units`, see {file:README.md#Units Units}.
84
+
85
+ stroke_color
86
+ default: ``:black``
87
+
88
+ the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
89
+
90
+ stroke_strategy
91
+ default: ``:fill_first``
92
+
93
+ specify whether the stroke is done before (thinner) or after (thicker) filling the shape. [:fill_first, :stroke_first]
94
+
95
+ dash
96
+ default: ``''``
97
+
98
+ define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports :doc:`/units` (e.g. ``'0.02in 0.02in'``).
99
+
100
+ hint
101
+ default: ``:nil`` (i.e. no hint)
102
+
103
+ draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
104
+
105
+ color
106
+ default: [String] (:black) the color the font will render to. Gradients supported. See {file:README.md#Specifying_Colors___Gradients Specifying Colors}
107
+
108
+ .. include:: /args/draw.rst
109
+ .. include:: /args/range.rst
110
+ .. include:: /args/layout.rst
111
+
112
+ .. _text-markup:
113
+
114
+ Markup
115
+ ------
116
+
117
+ If you want to do specialized formatting within a given string, Squib has lots of options. By setting ``markup: true``, you enable tons of text processing. This includes:
118
+
119
+ * Pango Markup. This is an HTML-like formatting language that specifies formatting inside your string. Pango Markup essentially supports any formatting option, but on a letter-by-letter basis. Such as: font options, letter spacing, gravity, color, etc. See the `Pango docs <https://developer.gnome.org/pango/stable/PangoMarkupFormat.html>`_ for details.
120
+ * Quotes are converted to their curly counterparts where appropriate.
121
+ * Apostraphes are converted to curly as well.
122
+ * LaTeX-style quotes are explicitly converted (````like this''``)
123
+ * Em-dash and en-dash are converted with triple and double-dashes respectively (``--`` is an en-dash, and ``---`` becomes an em-dash.)
124
+ * Ellipses can be specified with ``...`` (three periods). Note that this is entirely different from the ``ellipsize`` option (which determines what to do with overflowing text).
125
+
126
+ A few notes:
127
+ * Smart quoting assumes the UTF-8 character set by default. If you are in a different character set and want to change how it behaves
128
+ * Pango markup uses an XML/HTML-ish processor. Some characters require HTML-entity escaping (e.g. ``&amp;`` for ``&``)
129
+
130
+
131
+ You can also disable the auto-quoting mechanism by setting ``smart_quotes: false`` in your config. Explicit replacements will still be performed. See :doc:`/config`
132
+
133
+ Embedded Icons
134
+ --------------
135
+
136
+ The ``text`` method will also respond to a block. The object that gets passed to this block allows for embedding images into the flow of your text. The following methods are supported::
137
+
138
+ text(str: 'Take 1 :tool: and gain 2 :health:') do |embed|
139
+ embed.svg key: ':tool:', file: 'tool.svg'
140
+ embed.png key: ':health:', file: 'health.png'
141
+ end
142
+
143
+ embed.svg
144
+ ^^^^^^^^^
145
+ .. include:: /args/expansion.rst
146
+
147
+
148
+ key
149
+ default: ``'*'``
150
+
151
+ the string to replace with the graphic. Can be multiple letters, e.g. ``':tool:'``
152
+
153
+
154
+ file
155
+ default: ``''``
156
+
157
+ file(s) to read in, relative to the root directory or ``img_dir`` if set in the config.
158
+
159
+ id
160
+ default: ``nil``
161
+
162
+ if set, then only render the SVG element with the given id. Prefix '#' is optional. Note: the x-y coordinates are still relative to the SVG document's page.
163
+
164
+
165
+ force_id
166
+ default: ``false``
167
+
168
+ if set, then this svg will not be rendered at all if the id is empty or nil. If not set, the entire SVG is rendered.
169
+
170
+ layout
171
+ default: ``nil``
172
+
173
+ entry in the layout to use as defaults for this command. See :doc:`/layouts`
174
+
175
+ width
176
+ default: ``:native``
177
+
178
+ the width of the image rendered.
179
+
180
+ height
181
+ default: ``:native``
182
+
183
+ the height the height of the image rendered.
184
+
185
+ dx
186
+ default: ``0``
187
+
188
+ "delta x", or adjust the icon horizontally by x pixels
189
+
190
+ dy
191
+ default: ``0``
192
+
193
+ "delta y", or adjust the icon vertically by y pixels
194
+
195
+ flip_horiztonal
196
+ default: ``false``
197
+
198
+ Flip this image about its center horizontally (i.e. left becomes right and vice versa).
199
+
200
+ flip_vertical
201
+ default: ``false``
202
+
203
+ Flip this image about its center verticall (i.e. top becomes bottom and vice versa).
204
+
205
+ alpha
206
+ default: ``1.0``
207
+
208
+ the alpha-transparency percentage used to blend this image.
209
+
210
+ angle
211
+ default: ``0``
212
+
213
+ rotation of the in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky.
214
+
215
+ embed.png
216
+ ^^^^^^^^^
217
+
218
+ .. include:: /args/expansion.rst
219
+
220
+ key
221
+ default: ``'*'``
222
+
223
+ the string to replace with the graphic. Can be multiple letters, e.g. ``':tool:'``
224
+
225
+ file
226
+ default: ``''``
227
+
228
+ file(s) to read in, relative to the root directory or ``img_dir`` if set in the config.
229
+
230
+ layout
231
+ default: ``nil``
232
+
233
+ entry in the layout to use as defaults for this command. See :doc:`/layouts`
234
+
235
+ width
236
+ default: ``:native``
237
+
238
+ the width of the image rendered.
239
+
240
+ height
241
+ default: ``:native``
242
+
243
+ the height the height of the image rendered.
244
+
245
+ dx
246
+ default: ``0``
247
+
248
+ "delta x", or adjust the icon horizontally by x pixels
249
+
250
+ dy
251
+ default: ``0``
252
+
253
+ "delta y", or adjust the icon vertically by y pixels
254
+
255
+ flip_horiztonal
256
+ default: ``false``
257
+
258
+ Flip this image about its center horizontally (i.e. left becomes right and vice versa).
259
+
260
+ flip_vertical
261
+ default: ``false``
262
+
263
+ Flip this image about its center verticall (i.e. top becomes bottom and vice versa).
264
+
265
+ alpha
266
+ default: ``1.0``
267
+
268
+ the alpha-transparency percentage used to blend this image.
269
+
270
+ blend
271
+ default: ``:none``
272
+
273
+ the composite blend operator used when applying this image. See Blend Modes at http://cairographics.org/operators.
274
+ The possibilties include :none, :multiply, :screen, :overlay, :darken, :lighten, :color_dodge, :color_burn, :hard_light, :soft_light, :difference, :exclusion, :hsl_hue, :hsl_saturation, :hsl_color, :hsl_luminosity. String versions of these options are accepted too.
275
+
276
+
277
+ mask
278
+ default: ``nil``
279
+
280
+ Accepts a color (see :doc:`/colors`). If specified, the image will be used as a mask for the given color/gradient. Transparent pixels are ignored, opaque pixels are the given color. Note: the origin for gradient coordinates is at the given x,y, not at 0,0 as it is most other places.
281
+
282
+ angle
283
+ default: ``0``
284
+
285
+ rotation of the in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky.
286
+
287
+
288
+
289
+ Examples
290
+ --------
291
+
292
+ .. raw:: html
293
+
294
+ <script src="https://gist.github.com/andymeneely/52d7b8e332194946bc69.js"></script>