squib 0.14.2 → 0.14.3.pre1
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.
- checksums.yaml +4 -4
- data/.gitignore +41 -41
- data/.travis.yml +19 -19
- data/CHANGELOG.md +366 -357
- data/CONTRIBUTING.md +40 -40
- data/Gemfile +2 -2
- data/LICENSE.txt +22 -22
- data/README.md +121 -121
- data/RELEASE TODO.md +21 -21
- data/Rakefile +48 -48
- data/appveyor.yml +24 -24
- data/bin/squib +4 -4
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +15 -15
- data/lib/squib/api/data.rb +137 -137
- data/lib/squib/api/groups.rb +54 -54
- data/lib/squib/api/image.rb +49 -49
- data/lib/squib/api/save.rb +83 -83
- data/lib/squib/api/settings.rb +21 -21
- data/lib/squib/api/shapes.rb +124 -124
- data/lib/squib/api/text.rb +25 -25
- data/lib/squib/api/text_embed.rb +71 -71
- data/lib/squib/api/units.rb +27 -27
- data/lib/squib/args/arg_loader.rb +126 -126
- data/lib/squib/args/box.rb +55 -55
- data/lib/squib/args/card_range.rb +32 -32
- data/lib/squib/args/color_validator.rb +12 -12
- data/lib/squib/args/coords.rb +35 -35
- data/lib/squib/args/csv_opts.rb +25 -25
- data/lib/squib/args/dir_validator.rb +16 -16
- data/lib/squib/args/draw.rb +92 -92
- data/lib/squib/args/embed_adjust.rb +25 -25
- data/lib/squib/args/embed_key.rb +17 -17
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +40 -40
- data/lib/squib/args/input_file.rb +37 -37
- data/lib/squib/args/paint.rb +44 -44
- data/lib/squib/args/paragraph.rb +116 -116
- data/lib/squib/args/save_batch.rb +63 -63
- data/lib/squib/args/scale_box.rb +53 -53
- data/lib/squib/args/sheet.rb +172 -172
- data/lib/squib/args/showcase_special.rb +38 -38
- data/lib/squib/args/sprue_file.rb +44 -44
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +61 -61
- data/lib/squib/args/typographer.rb +119 -119
- data/lib/squib/args/unit_conversion.rb +29 -29
- data/lib/squib/builtin/layouts/economy.yml +85 -85
- data/lib/squib/builtin/layouts/fantasy.yml +101 -101
- data/lib/squib/builtin/layouts/hand.yml +62 -62
- data/lib/squib/builtin/layouts/party.yml +94 -94
- data/lib/squib/builtin/layouts/playing-card.yml +35 -35
- data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
- data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
- data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
- data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
- data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
- data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
- data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
- data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
- data/lib/squib/builtin/projects/advanced/config.yml +53 -49
- data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
- data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
- data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
- data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
- data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
- data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
- data/lib/squib/builtin/projects/basic/.gitignore +4 -4
- data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
- data/lib/squib/builtin/projects/basic/Gemfile +3 -3
- data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
- data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
- data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
- data/lib/squib/builtin/projects/basic/RULES.md +21 -21
- data/lib/squib/builtin/projects/basic/Rakefile +7 -7
- data/lib/squib/builtin/projects/basic/config.yml +53 -49
- data/lib/squib/builtin/projects/basic/deck.rb +6 -6
- data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
- data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
- data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
- data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
- data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
- data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
- data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
- data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
- data/lib/squib/card.rb +75 -75
- data/lib/squib/commands/cli.rb +39 -39
- data/lib/squib/commands/data/template_option.rb +109 -109
- data/lib/squib/commands/make_sprue.rb +275 -275
- data/lib/squib/commands/new.rb +77 -77
- data/lib/squib/conf.rb +144 -139
- data/lib/squib/constants.rb +17 -17
- data/lib/squib/deck.rb +116 -116
- data/lib/squib/graphics/background.rb +14 -14
- data/lib/squib/graphics/cairo_context_wrapper.rb +113 -113
- data/lib/squib/graphics/embedding_utils.rb +28 -28
- data/lib/squib/graphics/gradient_regex.rb +47 -47
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +129 -108
- data/lib/squib/graphics/save_doc.rb +61 -61
- data/lib/squib/graphics/save_images.rb +52 -52
- data/lib/squib/graphics/save_pdf.rb +90 -90
- data/lib/squib/graphics/save_sprue.rb +204 -204
- data/lib/squib/graphics/shapes.rb +143 -143
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +174 -174
- data/lib/squib/import/data_frame.rb +108 -108
- data/lib/squib/layout_parser.rb +138 -138
- data/lib/squib/progress.rb +38 -38
- data/lib/squib/sample_helpers.rb +34 -34
- data/lib/squib/sprues/crop_line.rb +28 -28
- data/lib/squib/sprues/crop_line_dash.rb +35 -35
- data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
- data/lib/squib/sprues/sprue.rb +203 -203
- data/lib/squib/sprues/sprue_schema.rb +48 -48
- data/lib/squib/version.rb +10 -10
- data/samples/autoscale_font/_autoscale_font.rb +29 -29
- data/samples/backend/_backend.rb +26 -26
- data/samples/basic.rb +19 -19
- data/samples/bug256/_bug256.rb +13 -0
- data/samples/build_groups/build_groups.rb +36 -36
- data/samples/colors/_colors.rb +38 -38
- data/samples/colors/_gradients.rb +34 -34
- data/samples/config/config_text_markup.rb +20 -20
- data/samples/config/custom_config.rb +18 -18
- data/samples/data/_csv.rb +33 -33
- data/samples/data/_excel.rb +55 -55
- data/samples/data/_yaml.rb +12 -12
- data/samples/hello_world.rb +6 -6
- data/samples/images/_cairo_access.rb +39 -39
- data/samples/images/_images.rb +104 -104
- data/samples/images/_more_load_images.rb +102 -102
- data/samples/intro/01_hello.rb +8 -8
- data/samples/intro/02_options.rb +14 -14
- data/samples/intro/03_layout.rb +11 -11
- data/samples/intro/04_arrays.rb +15 -15
- data/samples/intro/05_excel.rb +14 -14
- data/samples/layouts/builtin_layouts.rb +97 -97
- data/samples/layouts/layouts.rb +71 -71
- data/samples/project/src/characters.rb +8 -8
- data/samples/project/src/skills.rb +7 -7
- data/samples/proofs/_tgc_proofs.rb +16 -16
- data/samples/ranges/_ranges.rb +64 -64
- data/samples/saves/_hand.rb +23 -23
- data/samples/saves/_portrait_landscape.rb +23 -23
- data/samples/saves/_save_pdf.rb +29 -29
- data/samples/saves/_saves.rb +51 -51
- data/samples/saves/_showcase.rb +25 -25
- data/samples/shapes/_draw_shapes.rb +60 -60
- data/samples/shapes/_proofs.rb +22 -22
- data/samples/sprues/_advanced_sprues.rb +24 -24
- data/samples/sprues/_builtin_sprues.rb +21 -21
- data/samples/sprues/_fold_sheet.rb +27 -27
- data/samples/sprues/_hex_tiles.rb +15 -15
- data/samples/sprues/_mints.rb +11 -11
- data/samples/sprues/_sprue_example.rb +11 -11
- data/samples/text/_embed_text.rb +128 -128
- data/samples/text/_text.rb +47 -47
- data/samples/text/_text_options.rb +102 -102
- data/samples/text/bug134.rb +14 -14
- data/samples/units/_units.rb +32 -32
- data/squib.gemspec +52 -52
- metadata +51 -48
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new(width: '65.8mm', height: '76mm', cards: 9) do
|
|
4
|
-
polygon(
|
|
5
|
-
x: '32.9mm', y: '38mm', n: 6, radius: '38mm', angle: 1.571,
|
|
6
|
-
stroke_color: :black, stroke_width: '0.014in', fill_color: :pink
|
|
7
|
-
)
|
|
8
|
-
text(
|
|
9
|
-
str: %w[One Two Three Four Five Six Seven Eight Nine],
|
|
10
|
-
x: '22mm', y: '35mm', width: '21.8mm', height: '6mm',
|
|
11
|
-
align: :center, valign: :middle
|
|
12
|
-
)
|
|
13
|
-
save_pdf file: 'hex_tiles.pdf',
|
|
14
|
-
sprue: 'my_sprues/hex_tiles.yml'
|
|
15
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new(width: '65.8mm', height: '76mm', cards: 9) do
|
|
4
|
+
polygon(
|
|
5
|
+
x: '32.9mm', y: '38mm', n: 6, radius: '38mm', angle: 1.571,
|
|
6
|
+
stroke_color: :black, stroke_width: '0.014in', fill_color: :pink
|
|
7
|
+
)
|
|
8
|
+
text(
|
|
9
|
+
str: %w[One Two Three Four Five Six Seven Eight Nine],
|
|
10
|
+
x: '22mm', y: '35mm', width: '21.8mm', height: '6mm',
|
|
11
|
+
align: :center, valign: :middle
|
|
12
|
+
)
|
|
13
|
+
save_pdf file: 'hex_tiles.pdf',
|
|
14
|
+
sprue: 'my_sprues/hex_tiles.yml'
|
|
15
|
+
end
|
data/samples/sprues/_mints.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
# An example deck that uses "mint" sized cards (e.g. Altoids).
|
|
4
|
-
# These cards are pretty small but comfortably fit in a mint tin
|
|
5
|
-
|
|
6
|
-
Squib::Deck.new(cards: 21, width: '54.0mm', height: '68.0mm') do
|
|
7
|
-
background color: :gray
|
|
8
|
-
rect
|
|
9
|
-
text str: (1..21).to_a
|
|
10
|
-
save_pdf sprue: 'my_sprues/us_letter_mints.yml'
|
|
11
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
# An example deck that uses "mint" sized cards (e.g. Altoids).
|
|
4
|
+
# These cards are pretty small but comfortably fit in a mint tin
|
|
5
|
+
|
|
6
|
+
Squib::Deck.new(cards: 21, width: '54.0mm', height: '68.0mm') do
|
|
7
|
+
background color: :gray
|
|
8
|
+
rect
|
|
9
|
+
text str: (1..21).to_a
|
|
10
|
+
save_pdf sprue: 'my_sprues/us_letter_mints.yml'
|
|
11
|
+
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new(cards: 9) do
|
|
4
|
-
background color: :white
|
|
5
|
-
rect stroke_width: 5, stroke_color: :red
|
|
6
|
-
text str: (0..9).map{ |i| "Card #{i}\n2.5x3.5in" },
|
|
7
|
-
font: 'Sans 32', align: :center, valign: :middle,
|
|
8
|
-
height: :deck, width: :deck
|
|
9
|
-
save_sheet sprue: 'letter_poker_card_9up.yml',
|
|
10
|
-
prefix: "sprue_example_"
|
|
11
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new(cards: 9) do
|
|
4
|
+
background color: :white
|
|
5
|
+
rect stroke_width: 5, stroke_color: :red
|
|
6
|
+
text str: (0..9).map{ |i| "Card #{i}\n2.5x3.5in" },
|
|
7
|
+
font: 'Sans 32', align: :center, valign: :middle,
|
|
8
|
+
height: :deck, width: :deck
|
|
9
|
+
save_sheet sprue: 'letter_poker_card_9up.yml',
|
|
10
|
+
prefix: "sprue_example_"
|
|
11
|
+
end
|
data/samples/text/_embed_text.rb
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new do
|
|
4
|
-
background color: :white
|
|
5
|
-
rect x: 0, y: 0, width: 825, height: 1125, stroke_width: 2.0
|
|
6
|
-
|
|
7
|
-
embed_text = 'Take 11 :tool: and gain 2 :health:. Take <b>2</b> :tool: <i>and gain 3 :purse: if level 2.</i>'
|
|
8
|
-
text(str: embed_text, font: 'Sans 7',
|
|
9
|
-
x: 0, y: 0, width: 180, hint: :red,
|
|
10
|
-
align: :left, ellipsize: false, justify: false) do |embed|
|
|
11
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
12
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
13
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
|
|
17
|
-
text(str: embed_text, font: 'Sans 7',
|
|
18
|
-
x: 200, y: 0, width: 180, height: 300, valign: :middle,
|
|
19
|
-
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
20
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
21
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
22
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
embed_text = 'This :tool: aligns on the bottom properly. :purse:'
|
|
26
|
-
text(str: embed_text, font: 'Sans 7',
|
|
27
|
-
x: 400, y: 0, width: 180, height: 300, valign: :bottom,
|
|
28
|
-
align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
|
|
29
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
30
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
31
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
embed_text = 'Yes, this wraps strangely. We are trying to determine the cause. These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
|
|
35
|
-
text(str: embed_text, font: 'Sans 6',
|
|
36
|
-
x: 600, y: 0, width: 180, height: 300, wrap: :word_char,
|
|
37
|
-
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
38
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
|
|
42
|
-
text(str: embed_text, font: 'Sans 7',
|
|
43
|
-
x: 0, y: 320, width: 180, height: 300, valign: :bottom,
|
|
44
|
-
align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
|
|
45
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
46
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
47
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
embed_text = 'Right-aligned works :tool: with :health: and :purse:'
|
|
51
|
-
text(str: embed_text, font: 'Sans 7',
|
|
52
|
-
x: 200, y: 320, width: 180, height: 300, valign: :bottom,
|
|
53
|
-
align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
|
|
54
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
55
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
56
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
|
|
60
|
-
text(str: embed_text, font: 'Sans 7',
|
|
61
|
-
x: 400, y: 320, width: 180, height: 300,
|
|
62
|
-
align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
|
|
63
|
-
embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
|
|
64
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
65
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
|
|
69
|
-
text(str: embed_text, font: 'Serif 6', markup: true,
|
|
70
|
-
x: 600, y: 320, width: 180, height: 300,
|
|
71
|
-
align: :center, hint: :magenta) do |embed|
|
|
72
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
embed_text = ':tool:' # JUST the icon
|
|
76
|
-
text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
|
|
77
|
-
font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
|
|
78
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
embed_text = ':purse:' # JUST the icon
|
|
82
|
-
text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
|
|
83
|
-
font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
|
|
84
|
-
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
|
|
88
|
-
text(str: embed_text, font: 'Sans Bold 8', stroke_width: 2,
|
|
89
|
-
color: :red, stroke_color: :blue, dash: '3 3', align: :left,
|
|
90
|
-
valign: :middle, x: 0, y: 700, width: 380, height: 150,
|
|
91
|
-
hint: :magenta) do |embed|
|
|
92
|
-
embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
|
|
93
|
-
embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
embed_text = 'You can adjust the icon with dx and dy. Normal: :tool: Adjusted: :heart:'
|
|
97
|
-
text(str: embed_text, font: 'Sans 6', x: 400, y: 640, width: 180,
|
|
98
|
-
height: 300, hint: :magenta) do |embed|
|
|
99
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
100
|
-
embed.svg key: ':heart:', width: 28, height: 28, dx: 10, dy: 10,
|
|
101
|
-
file: 'glass-heart.svg'
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
embed_text = "Native sizes work too\n:tool:\n\n\n\n\n\n:shiny-purse:\n\n\n\n\n\n:tool2:"
|
|
105
|
-
text(str: embed_text, font: 'Sans 6', x: 600, y: 640, width: 180,
|
|
106
|
-
height: 475, hint: :magenta) do |embed|
|
|
107
|
-
embed.svg key: ':tool:', width: :native, height: :native,
|
|
108
|
-
file: 'spanner.svg'
|
|
109
|
-
embed.svg key: ':tool2:', width: :native, height: :native,
|
|
110
|
-
data: File.open('spanner.svg','r').read
|
|
111
|
-
embed.png key: ':shiny-purse:', width: :native, height: :native,
|
|
112
|
-
file: 'shiny-purse.png'
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
save_png prefix: 'embed_'
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
Squib::Deck.new(cards: 3) do
|
|
119
|
-
background color: :white
|
|
120
|
-
str = 'Take 1 :tool: and gain 2 :health:.'
|
|
121
|
-
text(str: str, font: 'Sans', font_size: [6, 8.5, 11.5],
|
|
122
|
-
x: 0, y: 0, width: 180, height: 300, valign: :bottom,
|
|
123
|
-
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
124
|
-
embed.svg key: ':tool:', width: [28, 42, 56], height: [28, 42, 56], file: 'spanner.svg'
|
|
125
|
-
embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'glass-heart.svg'
|
|
126
|
-
end
|
|
127
|
-
save_sheet prefix: 'embed_multisheet_', columns: 3
|
|
128
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new do
|
|
4
|
+
background color: :white
|
|
5
|
+
rect x: 0, y: 0, width: 825, height: 1125, stroke_width: 2.0
|
|
6
|
+
|
|
7
|
+
embed_text = 'Take 11 :tool: and gain 2 :health:. Take <b>2</b> :tool: <i>and gain 3 :purse: if level 2.</i>'
|
|
8
|
+
text(str: embed_text, font: 'Sans 7',
|
|
9
|
+
x: 0, y: 0, width: 180, hint: :red,
|
|
10
|
+
align: :left, ellipsize: false, justify: false) do |embed|
|
|
11
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
12
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
13
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
embed_text = 'Middle align: Take 1 :tool: and gain 2 :health:. Take 2 :tool: and gain 3 :purse:'
|
|
17
|
+
text(str: embed_text, font: 'Sans 7',
|
|
18
|
+
x: 200, y: 0, width: 180, height: 300, valign: :middle,
|
|
19
|
+
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
20
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
21
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
22
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
embed_text = 'This :tool: aligns on the bottom properly. :purse:'
|
|
26
|
+
text(str: embed_text, font: 'Sans 7',
|
|
27
|
+
x: 400, y: 0, width: 180, height: 300, valign: :bottom,
|
|
28
|
+
align: :left, ellipsize: false, justify: false, hint: :green) do |embed|
|
|
29
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
30
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
31
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
embed_text = 'Yes, this wraps strangely. We are trying to determine the cause. These are 1 :tool::tool::tool: and these are multiple :tool::tool: :tool::tool:'
|
|
35
|
+
text(str: embed_text, font: 'Sans 6',
|
|
36
|
+
x: 600, y: 0, width: 180, height: 300, wrap: :word_char,
|
|
37
|
+
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
38
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
embed_text = ':tool:Justify will :tool: work too, and :purse: with more words just for fun'
|
|
42
|
+
text(str: embed_text, font: 'Sans 7',
|
|
43
|
+
x: 0, y: 320, width: 180, height: 300, valign: :bottom,
|
|
44
|
+
align: :left, ellipsize: false, justify: true, hint: :magenta) do |embed|
|
|
45
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
46
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
47
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
embed_text = 'Right-aligned works :tool: with :health: and :purse:'
|
|
51
|
+
text(str: embed_text, font: 'Sans 7',
|
|
52
|
+
x: 200, y: 320, width: 180, height: 300, valign: :bottom,
|
|
53
|
+
align: :right, ellipsize: false, justify: false, hint: :magenta) do |embed|
|
|
54
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
55
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
56
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
embed_text = ':tool:Center-aligned works :tool: with :health: and :purse:'
|
|
60
|
+
text(str: embed_text, font: 'Sans 7',
|
|
61
|
+
x: 400, y: 320, width: 180, height: 300,
|
|
62
|
+
align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
|
|
63
|
+
embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
|
|
64
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
65
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
embed_text = 'Markup --- and typography replacements --- with ":tool:" icons <i>won\'t</i> fail'
|
|
69
|
+
text(str: embed_text, font: 'Serif 6', markup: true,
|
|
70
|
+
x: 600, y: 320, width: 180, height: 300,
|
|
71
|
+
align: :center, hint: :magenta) do |embed|
|
|
72
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
embed_text = ':tool:' # JUST the icon
|
|
76
|
+
text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
|
|
77
|
+
font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
|
|
78
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
embed_text = ':purse:' # JUST the icon
|
|
82
|
+
text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
|
|
83
|
+
font: 'Arial 7', align: :center, valign: :middle, hint: :red) do |embed|
|
|
84
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
|
|
88
|
+
text(str: embed_text, font: 'Sans Bold 8', stroke_width: 2,
|
|
89
|
+
color: :red, stroke_color: :blue, dash: '3 3', align: :left,
|
|
90
|
+
valign: :middle, x: 0, y: 700, width: 380, height: 150,
|
|
91
|
+
hint: :magenta) do |embed|
|
|
92
|
+
embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
|
|
93
|
+
embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
embed_text = 'You can adjust the icon with dx and dy. Normal: :tool: Adjusted: :heart:'
|
|
97
|
+
text(str: embed_text, font: 'Sans 6', x: 400, y: 640, width: 180,
|
|
98
|
+
height: 300, hint: :magenta) do |embed|
|
|
99
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
100
|
+
embed.svg key: ':heart:', width: 28, height: 28, dx: 10, dy: 10,
|
|
101
|
+
file: 'glass-heart.svg'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
embed_text = "Native sizes work too\n:tool:\n\n\n\n\n\n:shiny-purse:\n\n\n\n\n\n:tool2:"
|
|
105
|
+
text(str: embed_text, font: 'Sans 6', x: 600, y: 640, width: 180,
|
|
106
|
+
height: 475, hint: :magenta) do |embed|
|
|
107
|
+
embed.svg key: ':tool:', width: :native, height: :native,
|
|
108
|
+
file: 'spanner.svg'
|
|
109
|
+
embed.svg key: ':tool2:', width: :native, height: :native,
|
|
110
|
+
data: File.open('spanner.svg','r').read
|
|
111
|
+
embed.png key: ':shiny-purse:', width: :native, height: :native,
|
|
112
|
+
file: 'shiny-purse.png'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
save_png prefix: 'embed_'
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
Squib::Deck.new(cards: 3) do
|
|
119
|
+
background color: :white
|
|
120
|
+
str = 'Take 1 :tool: and gain 2 :health:.'
|
|
121
|
+
text(str: str, font: 'Sans', font_size: [6, 8.5, 11.5],
|
|
122
|
+
x: 0, y: 0, width: 180, height: 300, valign: :bottom,
|
|
123
|
+
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
|
|
124
|
+
embed.svg key: ':tool:', width: [28, 42, 56], height: [28, 42, 56], file: 'spanner.svg'
|
|
125
|
+
embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'glass-heart.svg'
|
|
126
|
+
end
|
|
127
|
+
save_sheet prefix: 'embed_multisheet_', columns: 3
|
|
128
|
+
end
|
data/samples/text/_text.rb
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
require 'squib/sample_helpers'
|
|
3
|
-
|
|
4
|
-
Squib::Deck.new(width: 1000, height: 1250) do
|
|
5
|
-
draw_graph_paper width, height
|
|
6
|
-
|
|
7
|
-
sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
|
|
8
|
-
text font: 'Arial bold italic 11', str: 'Bold and italic!', x: x, y: y - 50
|
|
9
|
-
text font: 'Arial weight=300 11', str: 'Light bold!', x: x, y: y
|
|
10
|
-
text font: 'Times New Roman, 11', str: 'Times New Roman', x: x, y: y + 50
|
|
11
|
-
text font: 'NoSuchFont,Arial 11', str: 'Arial Backup', x: x, y: y + 100
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
sample 'Specify width and height to see a text box. Also: set "hint" to see the extents of your text box' do |x, y|
|
|
15
|
-
text str: 'This has fixed width and height.', x: x, y: y,
|
|
16
|
-
hint: :red, width: 300, height: 100, font: 'Serif bold 8'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
sample 'If you specify the width only, the text will ellipsize.' do |x, y|
|
|
20
|
-
text str: 'The meaning of life is 42', x: x - 50, y: y,
|
|
21
|
-
hint: :red, width: 350, font: 'Serif bold 7'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
sample 'If you specify the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
|
|
25
|
-
text str: 'This has fixed width, but not fixed height.', x: x, y: y,
|
|
26
|
-
hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
sample 'The text method returns the ink extents of each card\'s rendered text. So you can custom-fit a shape around it.' do |x, y|
|
|
30
|
-
['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
|
|
31
|
-
text_y = y + i * 50
|
|
32
|
-
extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
|
|
33
|
-
|
|
34
|
-
# Extents come back as an array of hashes, which can get split out like this
|
|
35
|
-
text_width = extents[0][:width]
|
|
36
|
-
text_height = extents[0][:height]
|
|
37
|
-
rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
|
|
38
|
-
stroke_color: :purple, stroke_width: 3
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
|
|
43
|
-
text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
save_png prefix: '_text_'
|
|
47
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
require 'squib/sample_helpers'
|
|
3
|
+
|
|
4
|
+
Squib::Deck.new(width: 1000, height: 1250) do
|
|
5
|
+
draw_graph_paper width, height
|
|
6
|
+
|
|
7
|
+
sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
|
|
8
|
+
text font: 'Arial bold italic 11', str: 'Bold and italic!', x: x, y: y - 50
|
|
9
|
+
text font: 'Arial weight=300 11', str: 'Light bold!', x: x, y: y
|
|
10
|
+
text font: 'Times New Roman, 11', str: 'Times New Roman', x: x, y: y + 50
|
|
11
|
+
text font: 'NoSuchFont,Arial 11', str: 'Arial Backup', x: x, y: y + 100
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
sample 'Specify width and height to see a text box. Also: set "hint" to see the extents of your text box' do |x, y|
|
|
15
|
+
text str: 'This has fixed width and height.', x: x, y: y,
|
|
16
|
+
hint: :red, width: 300, height: 100, font: 'Serif bold 8'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
sample 'If you specify the width only, the text will ellipsize.' do |x, y|
|
|
20
|
+
text str: 'The meaning of life is 42', x: x - 50, y: y,
|
|
21
|
+
hint: :red, width: 350, font: 'Serif bold 7'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
sample 'If you specify the width only, and turn off ellipsize, the height will auto-stretch.' do |x, y|
|
|
25
|
+
text str: 'This has fixed width, but not fixed height.', x: x, y: y,
|
|
26
|
+
hint: :red, width: 300, ellipsize: false, font: 'Serif bold 8'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sample 'The text method returns the ink extents of each card\'s rendered text. So you can custom-fit a shape around it.' do |x, y|
|
|
30
|
+
['Auto fit!', 'Auto fit!!!!' ].each.with_index do |str, i|
|
|
31
|
+
text_y = y + i * 50
|
|
32
|
+
extents = text str: str, x: x, y: text_y, font: 'Sans Bold 8'
|
|
33
|
+
|
|
34
|
+
# Extents come back as an array of hashes, which can get split out like this
|
|
35
|
+
text_width = extents[0][:width]
|
|
36
|
+
text_height = extents[0][:height]
|
|
37
|
+
rect x: x, y: text_y, width: text_width, height: text_height, radius: 10,
|
|
38
|
+
stroke_color: :purple, stroke_width: 3
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
sample 'Text can be rotated about the upper-left corner of the text box. Unit is in radians.' do |x, y|
|
|
43
|
+
text str: 'Rotated', hint: :red, x: x, y: y, angle: Math::PI / 6
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
save_png prefix: '_text_'
|
|
47
|
+
end
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
require 'squib'
|
|
3
|
-
|
|
4
|
-
data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
|
|
5
|
-
'level' => [1, 2, 3] }
|
|
6
|
-
longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
|
|
7
|
-
|
|
8
|
-
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
|
9
|
-
background color: :white
|
|
10
|
-
rect x: 15, y: 15, width: 795, height: 1095, x_radius: 50, y_radius: 50
|
|
11
|
-
rect x: 30, y: 30, width: 128, height: 128, x_radius: 25, y_radius: 25
|
|
12
|
-
|
|
13
|
-
# Arrays are rendered over each card
|
|
14
|
-
text str: data['name'], x: 250, y: 55, font: 'Arial weight=900 18'
|
|
15
|
-
text str: data['level'], x: 65, y: 40, font: 'Arial 24', color: :burnt_orange
|
|
16
|
-
|
|
17
|
-
text str: 'Font strings are expressive!', x:65, y: 200,
|
|
18
|
-
font: 'Impact bold italic 12'
|
|
19
|
-
|
|
20
|
-
text str: 'Font strings are expressive!', x:65, y: 300,
|
|
21
|
-
font: 'Arial,Verdana weight=900 style=oblique 12'
|
|
22
|
-
|
|
23
|
-
text str: 'Font string sizes can be overridden per card.', x: 65, y: 350,
|
|
24
|
-
font: 'Impact 12', font_size: [5, 7, 8]
|
|
25
|
-
|
|
26
|
-
text str: 'This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint',
|
|
27
|
-
hint: :red,
|
|
28
|
-
x: 65, y: 400,
|
|
29
|
-
width: 300, height: 125,
|
|
30
|
-
align: :center, valign: 'MIDDLE', # these can be specified with case-insenstive strings too
|
|
31
|
-
font: 'Serif 5'
|
|
32
|
-
|
|
33
|
-
extents = text str: 'Ink extent return value',
|
|
34
|
-
x: 65, y: 550,
|
|
35
|
-
font: 'Sans Bold', font_size: [5, 7, 8]
|
|
36
|
-
margin = 10
|
|
37
|
-
# Extents come back as an array of hashes, which can get split out like this
|
|
38
|
-
ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
|
|
39
|
-
hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
|
|
40
|
-
rect x: 65 - margin / 2, y: 550 - margin / 2,
|
|
41
|
-
width: ws, height: hs,
|
|
42
|
-
radius: 10, stroke_color: :black
|
|
43
|
-
|
|
44
|
-
# If width & height are defined and the text will overflow the box, we can ellipsize.
|
|
45
|
-
text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42",
|
|
46
|
-
hint: :green, font: 'Arial 7',
|
|
47
|
-
x: 450, y: 400,
|
|
48
|
-
width: 280, height: 180,
|
|
49
|
-
ellipsize: true
|
|
50
|
-
|
|
51
|
-
# Text hints are guides for showing you how your text boxes are laid out exactly
|
|
52
|
-
hint text: :cyan
|
|
53
|
-
set font: 'Serif 7' # Impacts all future text calls (unless they specify differently)
|
|
54
|
-
text str: 'Text hints & fonts are globally togglable!', x: 65, y: 625
|
|
55
|
-
set font: :default # back to Squib-wide default
|
|
56
|
-
hint text: :off
|
|
57
|
-
text str: 'See? No hint here.',
|
|
58
|
-
x: 565, y: 625,
|
|
59
|
-
font: 'Arial 7'
|
|
60
|
-
|
|
61
|
-
# Text can be rotated, in radians, about the upper-left corner of the text box.
|
|
62
|
-
text str: 'Rotated',
|
|
63
|
-
x: 565, y: 675, angle: 0.2,
|
|
64
|
-
font: 'Arial 6', hint: :red
|
|
65
|
-
|
|
66
|
-
# Text can be justified, and have newlines
|
|
67
|
-
text str: longtext, font: 'Arial 5',
|
|
68
|
-
x: 65, y: 700,
|
|
69
|
-
width: '1.5in', height: inches(1),
|
|
70
|
-
justify: true, spacing: -6
|
|
71
|
-
|
|
72
|
-
# Here's how you embed images into text.
|
|
73
|
-
# Pass a block to the method call and use the given context
|
|
74
|
-
embed_text = 'Embedded icons! Take 1 :tool: and gain 2:health:. If Level 2, take 2 :tool:'
|
|
75
|
-
text(str: embed_text, font: 'Sans 6',
|
|
76
|
-
x: '1.8in', y: '2.5in', width: '0.85in',
|
|
77
|
-
align: :left, ellipsize: false) do |embed|
|
|
78
|
-
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
79
|
-
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
|
|
83
|
-
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
|
84
|
-
x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
85
|
-
|
|
86
|
-
text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
|
|
87
|
-
color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
|
|
88
|
-
x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
89
|
-
|
|
90
|
-
text str: 'Dotted',
|
|
91
|
-
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
|
92
|
-
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
93
|
-
#
|
|
94
|
-
text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
|
|
95
|
-
markup: true,
|
|
96
|
-
x: 50, y: 1000,
|
|
97
|
-
width: 750, height: 100,
|
|
98
|
-
valign: :bottom,
|
|
99
|
-
font: 'Serif 6', hint: :cyan
|
|
100
|
-
|
|
101
|
-
save prefix: 'text_options_', format: :png
|
|
102
|
-
end
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'squib'
|
|
3
|
+
|
|
4
|
+
data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
|
|
5
|
+
'level' => [1, 2, 3] }
|
|
6
|
+
longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
|
|
7
|
+
|
|
8
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
|
9
|
+
background color: :white
|
|
10
|
+
rect x: 15, y: 15, width: 795, height: 1095, x_radius: 50, y_radius: 50
|
|
11
|
+
rect x: 30, y: 30, width: 128, height: 128, x_radius: 25, y_radius: 25
|
|
12
|
+
|
|
13
|
+
# Arrays are rendered over each card
|
|
14
|
+
text str: data['name'], x: 250, y: 55, font: 'Arial weight=900 18'
|
|
15
|
+
text str: data['level'], x: 65, y: 40, font: 'Arial 24', color: :burnt_orange
|
|
16
|
+
|
|
17
|
+
text str: 'Font strings are expressive!', x:65, y: 200,
|
|
18
|
+
font: 'Impact bold italic 12'
|
|
19
|
+
|
|
20
|
+
text str: 'Font strings are expressive!', x:65, y: 300,
|
|
21
|
+
font: 'Arial,Verdana weight=900 style=oblique 12'
|
|
22
|
+
|
|
23
|
+
text str: 'Font string sizes can be overridden per card.', x: 65, y: 350,
|
|
24
|
+
font: 'Impact 12', font_size: [5, 7, 8]
|
|
25
|
+
|
|
26
|
+
text str: 'This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint',
|
|
27
|
+
hint: :red,
|
|
28
|
+
x: 65, y: 400,
|
|
29
|
+
width: 300, height: 125,
|
|
30
|
+
align: :center, valign: 'MIDDLE', # these can be specified with case-insenstive strings too
|
|
31
|
+
font: 'Serif 5'
|
|
32
|
+
|
|
33
|
+
extents = text str: 'Ink extent return value',
|
|
34
|
+
x: 65, y: 550,
|
|
35
|
+
font: 'Sans Bold', font_size: [5, 7, 8]
|
|
36
|
+
margin = 10
|
|
37
|
+
# Extents come back as an array of hashes, which can get split out like this
|
|
38
|
+
ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
|
|
39
|
+
hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
|
|
40
|
+
rect x: 65 - margin / 2, y: 550 - margin / 2,
|
|
41
|
+
width: ws, height: hs,
|
|
42
|
+
radius: 10, stroke_color: :black
|
|
43
|
+
|
|
44
|
+
# If width & height are defined and the text will overflow the box, we can ellipsize.
|
|
45
|
+
text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42",
|
|
46
|
+
hint: :green, font: 'Arial 7',
|
|
47
|
+
x: 450, y: 400,
|
|
48
|
+
width: 280, height: 180,
|
|
49
|
+
ellipsize: true
|
|
50
|
+
|
|
51
|
+
# Text hints are guides for showing you how your text boxes are laid out exactly
|
|
52
|
+
hint text: :cyan
|
|
53
|
+
set font: 'Serif 7' # Impacts all future text calls (unless they specify differently)
|
|
54
|
+
text str: 'Text hints & fonts are globally togglable!', x: 65, y: 625
|
|
55
|
+
set font: :default # back to Squib-wide default
|
|
56
|
+
hint text: :off
|
|
57
|
+
text str: 'See? No hint here.',
|
|
58
|
+
x: 565, y: 625,
|
|
59
|
+
font: 'Arial 7'
|
|
60
|
+
|
|
61
|
+
# Text can be rotated, in radians, about the upper-left corner of the text box.
|
|
62
|
+
text str: 'Rotated',
|
|
63
|
+
x: 565, y: 675, angle: 0.2,
|
|
64
|
+
font: 'Arial 6', hint: :red
|
|
65
|
+
|
|
66
|
+
# Text can be justified, and have newlines
|
|
67
|
+
text str: longtext, font: 'Arial 5',
|
|
68
|
+
x: 65, y: 700,
|
|
69
|
+
width: '1.5in', height: inches(1),
|
|
70
|
+
justify: true, spacing: -6
|
|
71
|
+
|
|
72
|
+
# Here's how you embed images into text.
|
|
73
|
+
# Pass a block to the method call and use the given context
|
|
74
|
+
embed_text = 'Embedded icons! Take 1 :tool: and gain 2:health:. If Level 2, take 2 :tool:'
|
|
75
|
+
text(str: embed_text, font: 'Sans 6',
|
|
76
|
+
x: '1.8in', y: '2.5in', width: '0.85in',
|
|
77
|
+
align: :left, ellipsize: false) do |embed|
|
|
78
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
|
79
|
+
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
|
|
83
|
+
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
|
84
|
+
x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
85
|
+
|
|
86
|
+
text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
|
|
87
|
+
color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
|
|
88
|
+
x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
89
|
+
|
|
90
|
+
text str: 'Dotted',
|
|
91
|
+
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
|
92
|
+
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 9', markup: true
|
|
93
|
+
#
|
|
94
|
+
text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
|
|
95
|
+
markup: true,
|
|
96
|
+
x: 50, y: 1000,
|
|
97
|
+
width: 750, height: 100,
|
|
98
|
+
valign: :bottom,
|
|
99
|
+
font: 'Serif 6', hint: :cyan
|
|
100
|
+
|
|
101
|
+
save prefix: 'text_options_', format: :png
|
|
102
|
+
end
|