squib 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +14 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +201 -175
- data/Gemfile +2 -4
- data/README.md +650 -645
- data/RELEASE TODO.md +18 -18
- data/Rakefile +106 -99
- data/appveyor.yml +29 -0
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +20 -20
- data/lib/squib/api/data.rb +131 -131
- data/lib/squib/api/image.rb +108 -90
- data/lib/squib/api/save.rb +151 -149
- data/lib/squib/api/settings.rb +35 -35
- data/lib/squib/api/shapes.rb +255 -230
- data/lib/squib/api/text.rb +65 -65
- data/lib/squib/api/text_embed.rb +96 -96
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +54 -54
- data/lib/squib/args/card_range.rb +32 -32
- data/lib/squib/args/color_validator.rb +11 -11
- data/lib/squib/args/coords.rb +32 -32
- 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 +39 -39
- data/lib/squib/args/input_file.rb +37 -37
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +116 -115
- data/lib/squib/args/save_batch.rb +63 -60
- data/lib/squib/args/scale_box.rb +53 -53
- data/lib/squib/args/sheet.rb +72 -72
- data/lib/squib/args/showcase_special.rb +38 -38
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +60 -24
- data/lib/squib/args/typographer.rb +117 -117
- data/lib/squib/card.rb +66 -67
- data/lib/squib/conf.rb +131 -117
- data/lib/squib/constants.rb +12 -178
- data/lib/squib/deck.rb +113 -113
- data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
- data/lib/squib/graphics/gradient_regex.rb +46 -46
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +103 -76
- data/lib/squib/graphics/save_doc.rb +103 -103
- data/lib/squib/graphics/save_images.rb +39 -33
- data/lib/squib/graphics/shapes.rb +135 -119
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +176 -176
- data/lib/squib/layout_parser.rb +91 -91
- data/lib/squib/layouts/economy.yml +85 -85
- data/lib/squib/layouts/fantasy.yml +101 -101
- data/lib/squib/layouts/hand.yml +62 -62
- data/lib/squib/layouts/playing-card.yml +35 -35
- data/lib/squib/layouts/tuck_box.yml +45 -45
- data/lib/squib/project_template/IDEAS.md +22 -0
- data/lib/squib/project_template/PLAYTESTING.md +26 -0
- data/lib/squib/project_template/RULES.md +21 -0
- data/lib/squib/project_template/config.yml +49 -45
- data/lib/squib/sample_helpers.rb +34 -0
- data/lib/squib/version.rb +10 -10
- data/samples/autoscale_font/_autoscale_font.rb +29 -0
- data/samples/color_shortcuts.rb +6 -6
- data/samples/csv_import.rb +26 -26
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/draw_shapes.rb +48 -45
- data/samples/embed_text.rb +88 -88
- data/samples/excel.rb +55 -55
- data/samples/hand.rb +24 -24
- data/samples/images/_images.rb +104 -0
- data/samples/intro/01_hello.rb +9 -0
- data/samples/intro/02_options.rb +15 -0
- data/samples/intro/03_layout.rb +12 -0
- data/samples/intro/04_arrays.rb +16 -0
- data/samples/intro/05_excel.rb +15 -0
- data/samples/layouts.rb +62 -62
- data/samples/layouts_builtin.rb +51 -51
- data/samples/load_images.rb +99 -78
- data/samples/load_images_config.yml +1 -0
- data/samples/quantity_explosion.csv +2 -2
- data/samples/ranges.rb +64 -64
- data/samples/sample.csv +2 -2
- data/samples/saves.rb +9 -1
- data/samples/sprites.png +0 -0
- data/samples/text/_text.rb +46 -0
- data/samples/text_options.rb +102 -102
- data/spec/api/api_data_spec.rb +117 -117
- data/spec/api/api_settings_spec.rb +37 -37
- data/spec/args/box_spec.rb +127 -127
- data/spec/args/draw_spec.rb +101 -95
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +21 -21
- data/spec/args/paint_spec.rb +21 -21
- data/spec/args/paragraph_spec.rb +152 -152
- data/spec/args/range_spec.rb +40 -40
- data/spec/args/save_batch_spec.rb +51 -51
- data/spec/args/scale_box_spec.rb +71 -71
- data/spec/args/sheet_spec.rb +58 -58
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +25 -0
- data/spec/card_spec.rb +11 -0
- data/spec/conf_spec.rb +13 -3
- data/spec/data/conf/unrecognized.yml +4 -0
- data/spec/data/csv/qty.csv +2 -2
- data/spec/data/csv/qty_named.csv +2 -2
- data/spec/data/csv/with_spaces.csv +2 -2
- data/spec/data/samples/autoscale_font.rb.txt +84 -84
- data/spec/data/samples/basic.rb.txt +227 -209
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/csv_import.rb.txt +213 -213
- data/spec/data/samples/custom_config.rb.txt +57 -48
- data/spec/data/samples/draw_shapes.rb.txt +555 -3
- data/spec/data/samples/embed_text.rb.txt +283 -283
- data/spec/data/samples/excel.rb.txt +661 -661
- data/spec/data/samples/gradients.rb.txt +77 -79
- data/spec/data/samples/hand.rb.txt +538 -538
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/load_images.rb.txt +170 -0
- data/spec/data/samples/portrait-landscape.rb.txt +51 -49
- data/spec/data/samples/ranges.rb.txt +472 -460
- data/spec/data/samples/saves.rb.txt +810 -801
- data/spec/data/samples/showcase.rb.txt +5926 -5910
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/data/samples/tgc_proofs.rb.txt +95 -81
- data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
- data/spec/graphics/graphics_save_doc_spec.rb +67 -67
- data/spec/samples/diff-with-css.example.html +39 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/run_samples_spec.rb +17 -0
- data/spec/samples/samples_regression_spec.rb +72 -82
- data/spec/spec_helper.rb +9 -1
- data/squib.gemspec +49 -48
- data/squib.sublime-project +42 -42
- metadata +94 -48
- data/spec/graphics/graphics_images_spec.rb +0 -94
@@ -0,0 +1,34 @@
|
|
1
|
+
module Squib
|
2
|
+
|
3
|
+
# Some helper methods specifically for samples
|
4
|
+
#@api private
|
5
|
+
#:nodoc:
|
6
|
+
class Deck
|
7
|
+
|
8
|
+
# Draw graph paper for samples
|
9
|
+
def draw_graph_paper(width, height)
|
10
|
+
background color: 'white'
|
11
|
+
grid width: 50, height: 50, stroke_color: '#659ae9', stroke_width: 1.5
|
12
|
+
grid width: 200, height: 200, stroke_color: '#659ae9', stroke_width: 3, x: 50, y: 50
|
13
|
+
(50..height).step(200) do |y|
|
14
|
+
text str: "y=#{y}", x: 3, y: y - 18, font: 'Open Sans, Sans 10'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Define a set of samples on some graph paper
|
19
|
+
def sample(str)
|
20
|
+
@sample_x ||= 100
|
21
|
+
@sample_y ||= 100
|
22
|
+
rect x: 460, y: @sample_y - 40, width: 600,
|
23
|
+
height: 180, fill_color: '#FFD655', stroke_color: 'black', radius: 15
|
24
|
+
text str: str, x: 460, y: @sample_y - 40,
|
25
|
+
width: 540, height: 180,
|
26
|
+
valign: 'middle', align: 'center',
|
27
|
+
font: 'Times New Roman,Serif 24'
|
28
|
+
yield @sample_x, @sample_y
|
29
|
+
@sample_y += 200
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/squib/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
module Squib
|
2
|
-
|
3
|
-
# The next version to be released.
|
4
|
-
# Uses semantic versioning: http://semver.org/
|
5
|
-
#
|
6
|
-
# Most of the time this is in the alpha of the next release.
|
7
|
-
# e.g. v0.0.5a is on its way to becoming v0.0.5
|
8
|
-
#
|
9
|
-
VERSION = '0.
|
10
|
-
end
|
1
|
+
module Squib
|
2
|
+
|
3
|
+
# The next version to be released.
|
4
|
+
# Uses semantic versioning: http://semver.org/
|
5
|
+
#
|
6
|
+
# Most of the time this is in the alpha of the next release.
|
7
|
+
# e.g. v0.0.5a is on its way to becoming v0.0.5
|
8
|
+
#
|
9
|
+
VERSION = '0.9.0'
|
10
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# Here's an example of being able to scale a font
|
4
|
+
# based on the length of individual string.
|
5
|
+
# Handy for making minor font scales to fill text boxes.
|
6
|
+
def autoscale(str_array)
|
7
|
+
str_array.map do | str |
|
8
|
+
case str.length
|
9
|
+
when 0..15
|
10
|
+
32
|
11
|
+
when 16..20
|
12
|
+
18
|
13
|
+
else
|
14
|
+
12
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Squib::Deck.new(width: 300, height: 100, cards: 3) do
|
20
|
+
background color: :white
|
21
|
+
rect
|
22
|
+
title = ['Short & Big',
|
23
|
+
'Medium Length & Size',
|
24
|
+
'Super duper long string here, therefore a smaller font.']
|
25
|
+
text str: title, font: 'Arial', font_size: autoscale(title),
|
26
|
+
x: 10, y:10, align: :center, width: 280, ellipsize: false, hint: :red
|
27
|
+
|
28
|
+
save_sheet dir: '.', columns: 3
|
29
|
+
end
|
data/samples/color_shortcuts.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
Squib::Deck.new do
|
4
|
-
circle color: 'black', fill_color: 'black'
|
5
|
-
save_png prefix: 'color_shortcuts_'
|
6
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new do
|
4
|
+
circle color: 'black', fill_color: 'black'
|
5
|
+
save_png prefix: 'color_shortcuts_'
|
6
|
+
end
|
data/samples/csv_import.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
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: 'quantity_explosion.csv' # 2 rows...
|
19
|
-
num_cards = data['Name'].size # ...but 4 cards!
|
20
|
-
|
21
|
-
Squib::Deck.new(cards: num_cards) do
|
22
|
-
background color: :white
|
23
|
-
rect # card border
|
24
|
-
text str: data['Name'], font: 'Arial 54'
|
25
|
-
save_sheet prefix: 'sample_csv_qty_', columns: 4
|
26
|
-
end
|
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: 'quantity_explosion.csv' # 2 rows...
|
19
|
+
num_cards = data['Name'].size # ...but 4 cards!
|
20
|
+
|
21
|
+
Squib::Deck.new(cards: num_cards) do
|
22
|
+
background color: :white
|
23
|
+
rect # card border
|
24
|
+
text str: data['Name'], font: 'Arial 54'
|
25
|
+
save_sheet prefix: 'sample_csv_qty_', columns: 4
|
26
|
+
end
|
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 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
|
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,45 +1,48 @@
|
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new do
|
4
|
+
background color: :white
|
5
|
+
|
6
|
+
grid x: 10, y: 10, width: 50, height: 50, stroke_color: '#0066FF', stroke_width: 1.5
|
7
|
+
grid x: 10, y: 10, width: 200, height: 200, stroke_color: '#0066FF', stroke_width: 3
|
8
|
+
|
9
|
+
rect x: 305, y: 105, width: 200, height: 50, dash: '4 2'
|
10
|
+
|
11
|
+
rect x: 300, y: 300, width: 400, height: 400,
|
12
|
+
fill_color: :blue, stroke_color: :red, stroke_width: 50.0,
|
13
|
+
join: 'bevel'
|
14
|
+
|
15
|
+
circle x: 600, y: 600, radius: 75,
|
16
|
+
fill_color: :gray, stroke_color: :green, stroke_width: 8.0
|
17
|
+
|
18
|
+
triangle x1: 50, y1: 50,
|
19
|
+
x2: 150, y2: 150,
|
20
|
+
x3: 75, y3: 250,
|
21
|
+
fill_color: :gray, stroke_color: :green, stroke_width: 3.0
|
22
|
+
|
23
|
+
line x1: 50, y1: 550,
|
24
|
+
x2: 150, y2: 650,
|
25
|
+
stroke_width: 25.0
|
26
|
+
|
27
|
+
curve x1: 50, y1: 850, cx1: 150, cy1: 700,
|
28
|
+
x2: 625, y2: 900, cx2: 150, cy2: 700,
|
29
|
+
stroke_width: 12.0, stroke_color: :cyan,
|
30
|
+
fill_color: :burgundy, cap: 'round'
|
31
|
+
|
32
|
+
ellipse x: 50, y: 925, width: 200, height: 100,
|
33
|
+
stroke_width: 5.0, stroke_color: :cyan,
|
34
|
+
fill_color: :burgundy
|
35
|
+
|
36
|
+
star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
|
37
|
+
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 5
|
38
|
+
|
39
|
+
#default draw is fill-then-stroke. Can be changed to stroke-then-fill
|
40
|
+
star x: 375, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
|
41
|
+
fill_color: :cyan, stroke_color: :burgundy,
|
42
|
+
stroke_width: 5, stroke_strategy: :stroke_first
|
43
|
+
|
44
|
+
polygon x: 500, y: 1000, n: 5, radius: 25, angle: Math::PI / 2,
|
45
|
+
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 2
|
46
|
+
|
47
|
+
save_png prefix: 'shape_'
|
48
|
+
end
|
data/samples/embed_text.rb
CHANGED
@@ -1,88 +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
|
-
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
|
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
|