squib 0.18.0 → 0.19.0a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -39
- data/.github/ISSUE_TEMPLATE/feature_request.md +22 -22
- data/.github/ISSUE_TEMPLATE/help-wanted.md +13 -13
- data/.github/ISSUE_TEMPLATE/release-todo.md +45 -33
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -13
- data/.github/workflows/tests.yml +22 -22
- data/.gitignore +41 -41
- data/.vscode/settings.json +4 -3
- data/CHANGELOG.md +460 -460
- data/CONTRIBUTING.md +40 -40
- data/Dockerfile +27 -27
- data/Gemfile +2 -2
- data/Guardfile +8 -8
- data/LICENSE.txt +22 -22
- data/README.md +139 -139
- data/Rakefile +51 -51
- data/bin/squib +5 -5
- data/lib/squib/api/settings.rb +21 -21
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +59 -59
- data/lib/squib/args/card_range.rb +34 -34
- data/lib/squib/args/color_validator.rb +7 -7
- data/lib/squib/args/coords.rb +49 -49
- data/lib/squib/args/csv_opts.rb +22 -22
- data/lib/squib/args/dir_validator.rb +11 -11
- data/lib/squib/args/draw.rb +93 -93
- data/lib/squib/args/drop_shadow.rb +39 -39
- data/lib/squib/args/embed_adjust.rb +22 -22
- data/lib/squib/args/embed_key.rb +12 -12
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +67 -67
- data/lib/squib/args/input_file.rb +55 -55
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +118 -118
- data/lib/squib/args/save_batch.rb +65 -65
- data/lib/squib/args/scale_box.rb +57 -57
- data/lib/squib/args/sheet.rb +165 -165
- 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 -55
- data/lib/squib/args/typographer.rb +115 -115
- data/lib/squib/args/unit_conversion.rb +27 -27
- data/lib/squib/args/xywh_shorthands.rb +50 -50
- 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 +49 -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 -50
- 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 +149 -149
- data/lib/squib/constants.rb +17 -17
- data/lib/squib/deck.rb +138 -138
- data/lib/squib/dsl/background.rb +35 -35
- data/lib/squib/dsl/circle.rb +39 -39
- data/lib/squib/dsl/csv.rb +42 -42
- data/lib/squib/dsl/curve.rb +35 -35
- data/lib/squib/dsl/cut_zone.rb +47 -47
- data/lib/squib/dsl/ellipse.rb +37 -37
- data/lib/squib/dsl/grid.rb +35 -35
- data/lib/squib/dsl/groups.rb +54 -54
- data/lib/squib/dsl/hand.rb +42 -42
- data/lib/squib/dsl/line.rb +35 -35
- data/lib/squib/dsl/png.rb +57 -57
- data/lib/squib/dsl/polygon.rb +36 -36
- data/lib/squib/dsl/rect.rb +37 -37
- data/lib/squib/dsl/safe_zone.rb +48 -48
- data/lib/squib/dsl/save.rb +21 -21
- data/lib/squib/dsl/save_pdf.rb +50 -50
- data/lib/squib/dsl/save_png.rb +48 -48
- data/lib/squib/dsl/save_sheet.rb +53 -53
- data/lib/squib/dsl/showcase.rb +43 -43
- data/lib/squib/dsl/star.rb +37 -37
- data/lib/squib/dsl/svg.rb +63 -63
- data/lib/squib/dsl/text.rb +54 -54
- data/lib/squib/dsl/text_embed.rb +79 -79
- data/lib/squib/dsl/triangle.rb +35 -35
- data/lib/squib/dsl/units.rb +37 -37
- data/lib/squib/dsl/xlsx.rb +40 -40
- data/lib/squib/dsl/yaml.rb +40 -40
- data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -14
- data/lib/squib/graphics/background.rb +14 -14
- data/lib/squib/graphics/cairo_context_wrapper.rb +115 -115
- 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 +77 -77
- data/lib/squib/graphics/save_images.rb +91 -91
- data/lib/squib/graphics/save_pdf.rb +90 -90
- data/lib/squib/graphics/save_sprue.rb +231 -231
- data/lib/squib/graphics/shapes.rb +143 -143
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +202 -202
- data/lib/squib/import/csv_importer.rb +45 -45
- data/lib/squib/import/data_frame.rb +108 -108
- data/lib/squib/import/quantity_exploder.rb +17 -17
- data/lib/squib/import/xlsx_importer.rb +28 -28
- data/lib/squib/import/yaml_importer.rb +30 -30
- data/lib/squib/layout_parser.rb +155 -155
- 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 -208
- data/lib/squib/sprues/sprue_schema.rb +51 -51
- data/lib/squib/system_fonts.rb +16 -16
- data/lib/squib/version.rb +11 -11
- data/lib/squib.rb +35 -35
- data/samples/autoscale_font/_autoscale_font.rb +98 -98
- 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/images/_placeholders.rb +48 -48
- 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 -28
- data/samples/saves/_save_pdf.rb +29 -29
- data/samples/saves/_saves.rb +75 -75
- data/samples/saves/_showcase.rb +25 -25
- data/samples/shadows/_shadow.rb +71 -71
- 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 -22
- data/samples/sprues/_fold_sheet.rb +30 -30
- data/samples/sprues/_hex_tiles.rb +15 -15
- data/samples/sprues/_mints.rb +11 -11
- data/samples/sprues/_negative_coords.rb +6 -6
- data/samples/sprues/_sprue_example.rb +11 -11
- data/samples/system_font_debug/_list_fonts.rb +14 -14
- data/samples/text/_embed_text.rb +128 -128
- data/samples/text/_text.rb +52 -52
- data/samples/text/_text_options.rb +103 -103
- data/samples/text/bug134.rb +14 -14
- data/samples/units/_cells.rb +50 -50
- data/samples/units/_shorthands.rb +48 -48
- data/samples/units/_units.rb +39 -39
- data/squib.gemspec +58 -58
- metadata +21 -21
data/samples/layouts/layouts.rb
CHANGED
@@ -1,71 +1,71 @@
|
|
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 33', hint: :red
|
48
|
-
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 33', 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
|
-
save_png prefix: 'layout_builtin_hand_'
|
61
|
-
end
|
62
|
-
|
63
|
-
# Layouts can also be specified in their own DSL method call
|
64
|
-
# Each layout call will progressively be merged with the priors
|
65
|
-
Squib::Deck.new do
|
66
|
-
use_layout file: 'custom-layout.yml'
|
67
|
-
use_layout file: 'custom-layout2.yml'
|
68
|
-
text str: 'The Title', layout: :title # from custom-layout.yml
|
69
|
-
text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
|
70
|
-
save_png prefix: 'layout3_'
|
71
|
-
end
|
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 33', hint: :red
|
48
|
+
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 33', 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
|
+
save_png prefix: 'layout_builtin_hand_'
|
61
|
+
end
|
62
|
+
|
63
|
+
# Layouts can also be specified in their own DSL method call
|
64
|
+
# Each layout call will progressively be merged with the priors
|
65
|
+
Squib::Deck.new do
|
66
|
+
use_layout file: 'custom-layout.yml'
|
67
|
+
use_layout file: 'custom-layout2.yml'
|
68
|
+
text str: 'The Title', layout: :title # from custom-layout.yml
|
69
|
+
text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
|
70
|
+
save_png prefix: 'layout3_'
|
71
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
Squib::Deck.new do
|
4
|
-
background color: :white
|
5
|
-
text str: "Built at #{Time.now}"
|
6
|
-
svg file: 'robot-golem.svg'
|
7
|
-
save_png prefix: 'character_'
|
8
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new do
|
4
|
+
background color: :white
|
5
|
+
text str: "Built at #{Time.now}"
|
6
|
+
svg file: 'robot-golem.svg'
|
7
|
+
save_png prefix: 'character_'
|
8
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
Squib::Deck.new do
|
4
|
-
background color: :white
|
5
|
-
text str: "Built at #{Time.now}"
|
6
|
-
save_png prefix: 'skill_'
|
7
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
Squib::Deck.new do
|
4
|
+
background color: :white
|
5
|
+
text str: "Built at #{Time.now}"
|
6
|
+
save_png prefix: 'skill_'
|
7
|
+
end
|
@@ -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 stroke_color: 'black' # just a border
|
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,28 +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
|
-
# 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
|
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, 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
|
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
|