squib 0.15.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +22 -0
- data/.gitignore +41 -41
- data/CHANGELOG.md +422 -387
- data/CONTRIBUTING.md +40 -40
- data/Dockerfile +27 -25
- data/Gemfile +2 -2
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -22
- data/README.md +139 -121
- data/RELEASE TODO.md +22 -21
- data/Rakefile +51 -48
- data/bin/squib +4 -4
- data/lib/squib.rb +34 -32
- data/lib/squib/api/settings.rb +21 -21
- data/lib/squib/args/arg_loader.rb +129 -126
- data/lib/squib/args/box.rb +59 -55
- data/lib/squib/args/card_range.rb +34 -32
- data/lib/squib/args/color_validator.rb +7 -12
- data/lib/squib/args/coords.rb +49 -35
- data/lib/squib/args/csv_opts.rb +22 -25
- data/lib/squib/args/dir_validator.rb +11 -16
- data/lib/squib/args/draw.rb +93 -92
- data/lib/squib/args/embed_adjust.rb +22 -25
- data/lib/squib/args/embed_key.rb +12 -17
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +67 -40
- data/lib/squib/args/input_file.rb +33 -37
- data/lib/squib/args/paint.rb +43 -44
- data/lib/squib/args/paragraph.rb +118 -116
- data/lib/squib/args/save_batch.rb +65 -63
- data/lib/squib/args/scale_box.rb +57 -53
- data/lib/squib/args/sheet.rb +170 -172
- data/lib/squib/args/showcase_special.rb +41 -41
- data/lib/squib/args/sprue_file.rb +44 -44
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +55 -61
- data/lib/squib/args/typographer.rb +115 -119
- data/lib/squib/args/unit_conversion.rb +27 -29
- data/lib/squib/args/xywh_shorthands.rb +51 -0
- 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 +50 -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 +50 -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 +277 -277
- 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 +138 -116
- data/lib/squib/dsl/background.rb +35 -0
- data/lib/squib/dsl/circle.rb +39 -0
- data/lib/squib/dsl/csv.rb +42 -0
- data/lib/squib/dsl/curve.rb +35 -0
- data/lib/squib/dsl/cut_zone.rb +47 -0
- data/lib/squib/dsl/ellipse.rb +37 -0
- data/lib/squib/dsl/grid.rb +35 -0
- data/lib/squib/{api → dsl}/groups.rb +54 -54
- data/lib/squib/dsl/hand.rb +42 -0
- data/lib/squib/dsl/line.rb +35 -0
- data/lib/squib/dsl/png.rb +56 -0
- data/lib/squib/dsl/polygon.rb +36 -0
- data/lib/squib/dsl/rect.rb +37 -0
- data/lib/squib/dsl/safe_zone.rb +48 -0
- data/lib/squib/dsl/save.rb +21 -0
- data/lib/squib/dsl/save_pdf.rb +50 -0
- data/lib/squib/dsl/save_png.rb +44 -0
- data/lib/squib/dsl/save_sheet.rb +53 -0
- data/lib/squib/dsl/showcase.rb +43 -0
- data/lib/squib/dsl/star.rb +37 -0
- data/lib/squib/dsl/svg.rb +62 -0
- data/lib/squib/dsl/text.rb +54 -0
- data/lib/squib/dsl/text_embed.rb +78 -0
- data/lib/squib/dsl/triangle.rb +35 -0
- data/lib/squib/{api → dsl}/units.rb +37 -27
- data/lib/squib/dsl/xlsx.rb +40 -0
- data/lib/squib/dsl/yaml.rb +40 -0
- data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -0
- 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 +123 -123
- 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 +231 -219
- data/lib/squib/graphics/shapes.rb +143 -143
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +202 -174
- data/lib/squib/import/csv_importer.rb +45 -0
- data/lib/squib/import/data_frame.rb +108 -108
- data/lib/squib/import/quantity_exploder.rb +18 -0
- data/lib/squib/import/xlsx_importer.rb +28 -0
- data/lib/squib/import/yaml_importer.rb +30 -0
- data/lib/squib/layout_parser.rb +155 -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 +208 -206
- data/lib/squib/sprues/sprue_schema.rb +50 -50
- data/lib/squib/version.rb +11 -10
- data/samples/autoscale_font/_autoscale_font.rb +98 -29
- data/samples/backend/_backend.rb +26 -26
- data/samples/basic.rb +19 -19
- data/samples/build_groups/build_groups.rb +36 -36
- data/samples/colors/_colors.rb +44 -44
- data/samples/colors/_gradients.rb +34 -34
- data/samples/colors/_switch_color.rb +33 -33
- 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_filenames.rb +28 -24
- data/samples/saves/_save_pdf.rb +29 -29
- data/samples/saves/_saves.rb +52 -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 +25 -25
- data/samples/sprues/_builtin_sprues.rb +22 -21
- data/samples/sprues/_fold_sheet.rb +30 -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 +52 -47
- data/samples/text/_text_options.rb +103 -102
- data/samples/text/bug134.rb +14 -14
- data/samples/units/_cells.rb +51 -0
- data/samples/units/_shorthands.rb +48 -0
- data/samples/units/_units.rb +39 -32
- data/squib.gemspec +58 -52
- metadata +177 -91
- data/.travis.yml +0 -17
- data/appveyor.yml +0 -25
- data/lib/squib/api/background.rb +0 -15
- data/lib/squib/api/data.rb +0 -137
- data/lib/squib/api/image.rb +0 -49
- data/lib/squib/api/save.rb +0 -83
- data/lib/squib/api/shapes.rb +0 -124
- data/lib/squib/api/text.rb +0 -25
- data/lib/squib/api/text_embed.rb +0 -71
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
# This sample uses a proof overlay from TheGameCrafter.com to check bleed
|
4
|
-
Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
5
|
-
background color: :white
|
6
|
-
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
|
7
|
-
rect x: 75, y: 75, width: 128, height: 128, x_radius: 25, y_radius: 25
|
8
|
-
|
9
|
-
text str: 'Mastermind', x: 220, y: 78, font: 'Arial 18'
|
10
|
-
text str: 3, x: 75, y: 85, width: 128, font: 'Arial 24', align: :center
|
11
|
-
|
12
|
-
# TGC proof overlay (using alpha-transparency)
|
13
|
-
png file: 'pokercard.png', x:0, y:0, alpha: 0.5
|
14
|
-
|
15
|
-
save_png prefix: 'tgc_sample_'
|
16
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# This sample uses a proof overlay from TheGameCrafter.com to check bleed
|
4
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
5
|
+
background color: :white
|
6
|
+
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
|
7
|
+
rect x: 75, y: 75, width: 128, height: 128, x_radius: 25, y_radius: 25
|
8
|
+
|
9
|
+
text str: 'Mastermind', x: 220, y: 78, font: 'Arial 18'
|
10
|
+
text str: 3, x: 75, y: 85, width: 128, font: 'Arial 24', align: :center
|
11
|
+
|
12
|
+
# TGC proof overlay (using alpha-transparency)
|
13
|
+
png file: 'pokercard.png', x:0, y:0, alpha: 0.5
|
14
|
+
|
15
|
+
save_png prefix: 'tgc_sample_'
|
16
|
+
end
|
data/samples/ranges/_ranges.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
|
4
|
-
'type' => ['Thug', 'Thinker', 'Thinker'],
|
5
|
-
'level' => [1, 2, 3] }
|
6
|
-
|
7
|
-
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
8
|
-
# Default range is :all
|
9
|
-
background color: :white
|
10
|
-
text str: data['name'], x: 250, y: 55, font: 'Arial 18'
|
11
|
-
text str: data['level'], x: 65, y: 40, font: 'Arial 24'
|
12
|
-
|
13
|
-
# Could be explicit about using :all, too
|
14
|
-
text range: :all,
|
15
|
-
str: data['type'], x: 40, y: 128, font: 'Arial 6',
|
16
|
-
width: 100, align: :center
|
17
|
-
|
18
|
-
# Ranges are inclusive, zero-based
|
19
|
-
text range: 0..1, str: 'Thief and Grifter only!!', x: 25, y:200
|
20
|
-
|
21
|
-
# Integers are also allowed
|
22
|
-
text range: 0, str: 'Thief only!', x: 25, y: 250
|
23
|
-
|
24
|
-
# Negatives go from the back of the deck
|
25
|
-
text range: -1, str: 'Mastermind only!', x: 25, y: 250
|
26
|
-
text range: -2..-1, str: 'Grifter and Mastermind only!', x: 25, y: 650
|
27
|
-
|
28
|
-
# We can use Arrays too!
|
29
|
-
text range: [0, 2], str: 'Thief and Mastermind only!!', x: 25, y:300
|
30
|
-
|
31
|
-
# Just about everything in Squib can be given an array that
|
32
|
-
# corresponds to the deck's cards. This allows for each card to be styled differently
|
33
|
-
# This renders three cards, with three strings that had three different colors at three different locations.
|
34
|
-
text str: %w(red green blue),
|
35
|
-
color: [:red, :green, :blue],
|
36
|
-
x: [40, 80, 120],
|
37
|
-
y: [700, 750, 800]
|
38
|
-
|
39
|
-
# Useful idiom: construct a hash from card names back to its index (ID),
|
40
|
-
# then use a range. No need to memorize IDs, and you can add cards easily
|
41
|
-
id = {} ; data['name'].each_with_index{ |name, i| id[name] = i}
|
42
|
-
text range: id['Thief']..id['Grifter'],
|
43
|
-
str: 'Thief through Grifter with id lookup!!',
|
44
|
-
x:25, y: 400
|
45
|
-
|
46
|
-
# Useful idiom: generate arrays from a column called 'type'
|
47
|
-
type = {}; data['type'].each_with_index{ |t, i| (type[t] ||= []) << i}
|
48
|
-
text range: type['Thinker'],
|
49
|
-
str: 'Only for Thinkers!',
|
50
|
-
x:25, y: 500
|
51
|
-
|
52
|
-
# Useful idiom: draw a different number of images for different cards
|
53
|
-
hearts = [nil, 1, 2] # i.e. card 0 has no hearts, card 2 has 2 hearts drawn
|
54
|
-
1.upto(2).each do |n|
|
55
|
-
range = hearts.each_index.select { |i| hearts[i] == n}
|
56
|
-
n.times do |i|
|
57
|
-
svg file: 'glass-heart.svg', range: range,
|
58
|
-
x: 150, y: 55 + i * 42, width: 40, height: 40
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
rect
|
63
|
-
save_sheet prefix: 'ranges_', columns: 3
|
64
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
|
4
|
+
'type' => ['Thug', 'Thinker', 'Thinker'],
|
5
|
+
'level' => [1, 2, 3] }
|
6
|
+
|
7
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
8
|
+
# Default range is :all
|
9
|
+
background color: :white
|
10
|
+
text str: data['name'], x: 250, y: 55, font: 'Arial 18'
|
11
|
+
text str: data['level'], x: 65, y: 40, font: 'Arial 24'
|
12
|
+
|
13
|
+
# Could be explicit about using :all, too
|
14
|
+
text range: :all,
|
15
|
+
str: data['type'], x: 40, y: 128, font: 'Arial 6',
|
16
|
+
width: 100, align: :center
|
17
|
+
|
18
|
+
# Ranges are inclusive, zero-based
|
19
|
+
text range: 0..1, str: 'Thief and Grifter only!!', x: 25, y:200
|
20
|
+
|
21
|
+
# Integers are also allowed
|
22
|
+
text range: 0, str: 'Thief only!', x: 25, y: 250
|
23
|
+
|
24
|
+
# Negatives go from the back of the deck
|
25
|
+
text range: -1, str: 'Mastermind only!', x: 25, y: 250
|
26
|
+
text range: -2..-1, str: 'Grifter and Mastermind only!', x: 25, y: 650
|
27
|
+
|
28
|
+
# We can use Arrays too!
|
29
|
+
text range: [0, 2], str: 'Thief and Mastermind only!!', x: 25, y:300
|
30
|
+
|
31
|
+
# Just about everything in Squib can be given an array that
|
32
|
+
# corresponds to the deck's cards. This allows for each card to be styled differently
|
33
|
+
# This renders three cards, with three strings that had three different colors at three different locations.
|
34
|
+
text str: %w(red green blue),
|
35
|
+
color: [:red, :green, :blue],
|
36
|
+
x: [40, 80, 120],
|
37
|
+
y: [700, 750, 800]
|
38
|
+
|
39
|
+
# Useful idiom: construct a hash from card names back to its index (ID),
|
40
|
+
# then use a range. No need to memorize IDs, and you can add cards easily
|
41
|
+
id = {} ; data['name'].each_with_index{ |name, i| id[name] = i}
|
42
|
+
text range: id['Thief']..id['Grifter'],
|
43
|
+
str: 'Thief through Grifter with id lookup!!',
|
44
|
+
x:25, y: 400
|
45
|
+
|
46
|
+
# Useful idiom: generate arrays from a column called 'type'
|
47
|
+
type = {}; data['type'].each_with_index{ |t, i| (type[t] ||= []) << i}
|
48
|
+
text range: type['Thinker'],
|
49
|
+
str: 'Only for Thinkers!',
|
50
|
+
x:25, y: 500
|
51
|
+
|
52
|
+
# Useful idiom: draw a different number of images for different cards
|
53
|
+
hearts = [nil, 1, 2] # i.e. card 0 has no hearts, card 2 has 2 hearts drawn
|
54
|
+
1.upto(2).each do |n|
|
55
|
+
range = hearts.each_index.select { |i| hearts[i] == n}
|
56
|
+
n.times do |i|
|
57
|
+
svg file: 'glass-heart.svg', range: range,
|
58
|
+
x: 150, y: 55 + i * 42, width: 40, height: 40
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
rect stroke_color: 'black' # just a border
|
63
|
+
save_sheet prefix: 'ranges_', columns: 3
|
64
|
+
end
|
data/samples/saves/_hand.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
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 33'
|
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
|
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 33'
|
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
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
# For decks with both landscape and portrait orientations,
|
4
|
-
# we recommend using two separate decks.
|
5
|
-
# For print-on-demand, we can rotate all of the images in the final step.
|
6
|
-
|
7
|
-
# Normal cards
|
8
|
-
Squib::Deck.new(width: 825, height: 1125) do
|
9
|
-
background color: '#aaa'
|
10
|
-
|
11
|
-
text str: 'This is portrait and trimmed'
|
12
|
-
|
13
|
-
save_png prefix: 'portrait_', trim: 10, trim_radius: 15
|
14
|
-
end
|
15
|
-
|
16
|
-
# Money cards are landscape
|
17
|
-
Squib::Deck.new(width: 1125, height: 825) do
|
18
|
-
background color: '#aaa'
|
19
|
-
|
20
|
-
text str: 'This is landscape and trimmed', x: 15, y: 10
|
21
|
-
|
22
|
-
save_png prefix: 'landscape_', rotate: :clockwise, trim: 25, trim_radius: 15
|
23
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# For decks with both landscape and portrait orientations,
|
4
|
+
# we recommend using two separate decks.
|
5
|
+
# For print-on-demand, we can rotate all of the images in the final step.
|
6
|
+
|
7
|
+
# Normal cards
|
8
|
+
Squib::Deck.new(width: 825, height: 1125) do
|
9
|
+
background color: '#aaa'
|
10
|
+
|
11
|
+
text str: 'This is portrait and trimmed'
|
12
|
+
|
13
|
+
save_png prefix: 'portrait_', trim: 10, trim_radius: 15
|
14
|
+
end
|
15
|
+
|
16
|
+
# Money cards are landscape
|
17
|
+
Squib::Deck.new(width: 1125, height: 825) do
|
18
|
+
background color: '#aaa'
|
19
|
+
|
20
|
+
text str: 'This is landscape and trimmed', x: 15, y: 10
|
21
|
+
|
22
|
+
save_png prefix: 'landscape_', rotate: :clockwise, trim: 25, trim_radius: 15
|
23
|
+
end
|
@@ -1,24 +1,28 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
# This demonstrates the many ways you can save file to save_png and the like
|
4
|
-
Squib::Deck.new(width: 50, height: 50, cards: 2) do
|
5
|
-
background color: :white
|
6
|
-
text str: (0..16).to_a, font: 'Arial Bold 12'
|
7
|
-
|
8
|
-
# three digits, e.g. save_three_digits_000.png
|
9
|
-
save_png prefix: 'save_three_digits_', count_format: '%03d'
|
10
|
-
|
11
|
-
# foo_0.png
|
12
|
-
# bar_1.png
|
13
|
-
save_png prefix: ['foo_', 'bar_'], count_format: '%01d'
|
14
|
-
|
15
|
-
# foo.png
|
16
|
-
# bar.png
|
17
|
-
save_png prefix: ['foo', 'bar'], count_format: ''
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# This demonstrates the many ways you can save file to save_png and the like
|
4
|
+
Squib::Deck.new(width: 50, height: 50, cards: 2) do
|
5
|
+
background color: :white
|
6
|
+
text str: (0..16).to_a, font: 'Arial Bold 12'
|
7
|
+
|
8
|
+
# three digits, e.g. save_three_digits_000.png
|
9
|
+
save_png prefix: 'save_three_digits_', count_format: '%03d'
|
10
|
+
|
11
|
+
# foo_0.png
|
12
|
+
# bar_1.png
|
13
|
+
save_png prefix: ['foo_', 'bar_'], count_format: '%01d'
|
14
|
+
|
15
|
+
# foo.png
|
16
|
+
# bar.png
|
17
|
+
save_png prefix: ['foo', 'bar'], count_format: ''
|
18
|
+
|
19
|
+
# foo_00_bar.png
|
20
|
+
# foo_01_bar.png
|
21
|
+
save_png prefix: 'foo_', suffix: '_bar'
|
22
|
+
|
23
|
+
# thief.png
|
24
|
+
# thug.png
|
25
|
+
data = csv data: "filename\nthief\nthug"
|
26
|
+
save_png prefix: data.filename, count_format: ''
|
27
|
+
|
28
|
+
end
|
data/samples/saves/_save_pdf.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
Squib::Deck.new(cards: 8) do
|
4
|
-
background color: :gray
|
5
|
-
rect x: 37.5, y: 37.5, width: 750, height: 1050,
|
6
|
-
x_radius: 37.5, y_radius: 37.5,
|
7
|
-
|
8
|
-
# Tests for crop marks
|
9
|
-
save_pdf file: 'crops-default.pdf', crop_marks: true
|
10
|
-
save_pdf file: 'crops-gapped.pdf', crop_marks: true, trim: 37.5, gap: 20
|
11
|
-
|
12
|
-
# Test crop marks with all the bells and whistles
|
13
|
-
rect x: '0.3in', y: '0.4in', width: '2in', height: '2.5in'
|
14
|
-
save_pdf file: 'crops-custom.pdf', crop_marks: true, trim: 0, gap: 20,
|
15
|
-
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
|
16
|
-
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
|
17
|
-
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
|
18
|
-
|
19
|
-
# Full crop marks
|
20
|
-
save_pdf file: 'crops-full.pdf', crop_marks: :full,
|
21
|
-
trim: 0, gap: 20,
|
22
|
-
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
|
23
|
-
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
|
24
|
-
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
|
25
|
-
|
26
|
-
# Right to left printing for duplex
|
27
|
-
save_pdf file: 'save_pdf-crops-rtl.pdf', crop_marks: true, rtl: true
|
28
|
-
|
29
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new(cards: 8) do
|
4
|
+
background color: :gray
|
5
|
+
rect x: 37.5, y: 37.5, width: 750, height: 1050,
|
6
|
+
x_radius: 37.5, y_radius: 37.5, stroke_width: 2.0, dash: '4 4'
|
7
|
+
|
8
|
+
# Tests for crop marks
|
9
|
+
save_pdf file: 'crops-default.pdf', crop_marks: true
|
10
|
+
save_pdf file: 'crops-gapped.pdf', crop_marks: true, trim: 37.5, gap: 20
|
11
|
+
|
12
|
+
# Test crop marks with all the bells and whistles
|
13
|
+
rect x: '0.3in', y: '0.4in', width: '2in', height: '2.5in'
|
14
|
+
save_pdf file: 'crops-custom.pdf', crop_marks: true, trim: 0, gap: 20,
|
15
|
+
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
|
16
|
+
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
|
17
|
+
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
|
18
|
+
|
19
|
+
# Full crop marks
|
20
|
+
save_pdf file: 'crops-full.pdf', crop_marks: :full,
|
21
|
+
trim: 0, gap: 20,
|
22
|
+
crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
|
23
|
+
crop_margin_left: '0.3in', crop_margin_right: '0.45in',
|
24
|
+
crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
|
25
|
+
|
26
|
+
# Right to left printing for duplex
|
27
|
+
save_pdf file: 'save_pdf-crops-rtl.pdf', crop_marks: true, rtl: true
|
28
|
+
|
29
|
+
end
|
data/samples/saves/_saves.rb
CHANGED
@@ -1,51 +1,52 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
# This sample demonstrates how to use the various save methods
|
4
|
-
|
5
|
-
Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
6
|
-
background color: :gray
|
7
|
-
rect x: 38, y: 38, width: 750, height: 1050,
|
8
|
-
x_radius: 38, y_radius: 38,
|
9
|
-
|
10
|
-
text str: (1..16).to_a, x: 220, y: 78, font: 'Arial 18'
|
11
|
-
|
12
|
-
# Here's what a regular save_png looks like for just the first card
|
13
|
-
save_png range: 0, prefix: 'save_png_'
|
14
|
-
|
15
|
-
# save_png supports trim and trim_radius
|
16
|
-
save_png trim: 30, trim_radius: 38,
|
17
|
-
range: 0, prefix: 'save_png_trimmed_'
|
18
|
-
|
19
|
-
# Place on multiple pages over the PDF, with bleed beeing trimmed off
|
20
|
-
save_pdf file: 'save-pdf.pdf', margin: 75, gap: 5, trim: 37
|
21
|
-
|
22
|
-
# PDFs also support arbitrary paper sizes, in pixels or any other supported units
|
23
|
-
save_pdf file: 'save-pdf-small.pdf',
|
24
|
-
width: '7in', height: '5in',
|
25
|
-
range: 0..1
|
26
|
-
|
27
|
-
# Note that our PNGs still are not trimmed even though the pdf ones were
|
28
|
-
save_png range: 1, prefix: 'saves_notrim_'
|
29
|
-
|
30
|
-
# We can also save our PNGs into a single sheet,
|
31
|
-
# rows are calculated based on cols and number of cards
|
32
|
-
save_sheet prefix: 'save_single_sheet_',
|
33
|
-
columns: 2, margin: 75, gap: 5, trim: 37
|
34
|
-
|
35
|
-
# Or multiple sheets if rows are also specified
|
36
|
-
save_sheet prefix: 'save_sheet_',
|
37
|
-
columns: 4, rows: 2,
|
38
|
-
margin: 75, gap: 5, trim: 37
|
39
|
-
|
40
|
-
# Sheets support ranges too
|
41
|
-
save_sheet prefix: 'save_sheet_range_',
|
42
|
-
range: 0..5,
|
43
|
-
columns: 2, rows: 2,
|
44
|
-
margin: 75, gap: 5, trim: 37
|
45
|
-
|
46
|
-
# Sheets can arrange left-to-right and right-to-left
|
47
|
-
save_sheet prefix: 'save_sheet_rtl_',
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# This sample demonstrates how to use the various save methods
|
4
|
+
|
5
|
+
Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
6
|
+
background color: :gray
|
7
|
+
rect x: 38, y: 38, width: 750, height: 1050,
|
8
|
+
x_radius: 38, y_radius: 38, stroke_width: 2.0, dash: '4 4'
|
9
|
+
|
10
|
+
text str: (1..16).to_a, x: 220, y: 78, font: 'Arial 18'
|
11
|
+
|
12
|
+
# Here's what a regular save_png looks like for just the first card
|
13
|
+
save_png range: 0, prefix: 'save_png_'
|
14
|
+
|
15
|
+
# save_png supports trim and trim_radius
|
16
|
+
save_png trim: 30, trim_radius: 38,
|
17
|
+
range: 0, prefix: 'save_png_trimmed_'
|
18
|
+
|
19
|
+
# Place on multiple pages over the PDF, with bleed beeing trimmed off
|
20
|
+
save_pdf file: 'save-pdf.pdf', margin: 75, gap: 5, trim: 37
|
21
|
+
|
22
|
+
# PDFs also support arbitrary paper sizes, in pixels or any other supported units
|
23
|
+
save_pdf file: 'save-pdf-small.pdf',
|
24
|
+
width: '7in', height: '5in',
|
25
|
+
range: 0..1
|
26
|
+
|
27
|
+
# Note that our PNGs still are not trimmed even though the pdf ones were
|
28
|
+
save_png range: 1, prefix: 'saves_notrim_'
|
29
|
+
|
30
|
+
# We can also save our PNGs into a single sheet,
|
31
|
+
# rows are calculated based on cols and number of cards
|
32
|
+
save_sheet prefix: 'save_single_sheet_',
|
33
|
+
columns: 2, margin: 75, gap: 5, trim: 37
|
34
|
+
|
35
|
+
# Or multiple sheets if rows are also specified
|
36
|
+
save_sheet prefix: 'save_sheet_',
|
37
|
+
columns: 4, rows: 2,
|
38
|
+
margin: 75, gap: 5, trim: 37
|
39
|
+
|
40
|
+
# Sheets support ranges too
|
41
|
+
save_sheet prefix: 'save_sheet_range_',
|
42
|
+
range: 0..5,
|
43
|
+
columns: 2, rows: 2,
|
44
|
+
margin: 75, gap: 5, trim: 37
|
45
|
+
|
46
|
+
# Sheets can arrange left-to-right and right-to-left
|
47
|
+
save_sheet prefix: 'save_sheet_rtl_',
|
48
|
+
suffix: '_with_suffix',
|
49
|
+
range: 0..1, rtl: true,
|
50
|
+
columns: 2, rows: 1,
|
51
|
+
margin: 75, gap: 5, trim: 37
|
52
|
+
end
|