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