squib 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.gitmodules +22 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +40 -0
- data/README.md +25 -553
- data/RELEASE TODO.md +2 -2
- data/Rakefile +6 -64
- data/appveyor.yml +0 -4
- data/benchmarks/antialias_best.rb +2 -2
- data/benchmarks/antialias_fast.rb +2 -2
- data/benchmarks/{backend-memory.rb → backend_memory.rb} +2 -2
- data/benchmarks/{backend-svg.rb → backend_svg.rb} +2 -2
- data/benchmarks/tons_of_png.rb +1 -1
- data/benchmarks/tons_of_svg.rb +1 -1
- data/benchmarks/tons_of_text.rb +1 -1
- data/docs/Makefile +216 -0
- data/docs/_static/css/squibdocs.css +18 -0
- data/docs/args/draw.rst +36 -0
- data/docs/args/expansion.rst +3 -0
- data/docs/args/layout.rst +6 -0
- data/docs/args/output_dir.rst +6 -0
- data/docs/args/range.rst +6 -0
- data/docs/args/transform.rst +51 -0
- data/docs/args/trim.rst +11 -0
- data/docs/args/wh.rst +12 -0
- data/docs/args/xy.rst +12 -0
- data/docs/arrays.rst +77 -0
- data/docs/backends.rst +20 -0
- data/docs/bleed.rst +13 -0
- data/docs/build_groups.rst +47 -0
- data/docs/colors.rst +64 -0
- data/docs/conf.py +287 -0
- data/docs/config.rst +117 -0
- data/docs/data.rst +22 -0
- data/docs/dsl/background.rst +20 -0
- data/docs/dsl/build.rst +32 -0
- data/docs/dsl/build_groups.rst +23 -0
- data/docs/dsl/circle.rst +27 -0
- data/docs/dsl/cm.rst +19 -0
- data/docs/dsl/csv.rst +62 -0
- data/docs/dsl/curve.rst +63 -0
- data/docs/dsl/deck.rst +45 -0
- data/docs/dsl/disable_build.rst +28 -0
- data/docs/dsl/ellipse.rst +17 -0
- data/docs/dsl/enable_build.rst +25 -0
- data/docs/dsl/grid.rst +31 -0
- data/docs/dsl/hand.rst +40 -0
- data/docs/dsl/hint.rst +15 -0
- data/docs/dsl/inches.rst +19 -0
- data/docs/dsl/index.rst +9 -0
- data/docs/dsl/line.rst +52 -0
- data/docs/dsl/png.rst +49 -0
- data/docs/dsl/polygon.rst +28 -0
- data/docs/dsl/rect.rst +18 -0
- data/docs/dsl/save.rst +23 -0
- data/docs/dsl/save_pdf.rst +48 -0
- data/docs/dsl/save_png.rst +46 -0
- data/docs/dsl/save_sheet.rst +55 -0
- data/docs/dsl/showcase.rst +65 -0
- data/docs/dsl/star.rst +35 -0
- data/docs/dsl/svg.rst +119 -0
- data/docs/dsl/text.rst +294 -0
- data/docs/dsl/triangle.rst +38 -0
- data/docs/dsl/use_layout.rst +16 -0
- data/docs/dsl/xlsx.rst +50 -0
- data/docs/guides/game_icons.rst +2 -0
- data/docs/guides/getting-started/index.rst +5 -0
- data/docs/guides/getting-started/part_0_learning_ruby.rst +145 -0
- data/docs/guides/getting-started/part_1_zero_to_game.rst +216 -0
- data/docs/guides/getting-started/part_2_iconography.rst +152 -0
- data/docs/guides/getting-started/part_3_workflows.rst +4 -0
- data/docs/guides/git.rst +13 -0
- data/docs/guides/hello_world.rst +6 -0
- data/docs/help.rst +157 -0
- data/docs/index.rst +35 -0
- data/docs/install.rst +66 -0
- data/docs/layouts.rst +235 -0
- data/docs/learning.rst +10 -0
- data/docs/make.bat +263 -0
- data/docs/parameters.rst +26 -0
- data/docs/server.bat +1 -0
- data/docs/text_feature.rst +86 -0
- data/docs/units.rst +6 -0
- data/lib/squib.rb +4 -4
- data/lib/squib/api/background.rb +5 -10
- data/lib/squib/api/data.rb +30 -54
- data/lib/squib/api/groups.rb +47 -0
- data/lib/squib/api/image.rb +8 -67
- data/lib/squib/api/save.rb +15 -105
- data/lib/squib/api/settings.rb +8 -22
- data/lib/squib/api/shapes.rb +15 -185
- data/lib/squib/api/text.rb +9 -49
- data/lib/squib/api/text_embed.rb +12 -12
- data/lib/squib/api/units.rb +3 -17
- data/lib/squib/args/arg_loader.rb +6 -6
- data/lib/squib/args/box.rb +2 -2
- data/lib/squib/args/card_range.rb +1 -1
- data/lib/squib/args/color_validator.rb +2 -2
- data/lib/squib/args/coords.rb +2 -2
- data/lib/squib/args/csv_opts.rb +25 -0
- data/lib/squib/args/dir_validator.rb +1 -1
- data/lib/squib/args/draw.rb +2 -2
- data/lib/squib/args/embed_adjust.rb +1 -1
- data/lib/squib/args/embed_key.rb +1 -1
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +2 -2
- data/lib/squib/args/input_file.rb +1 -1
- data/lib/squib/args/paint.rb +3 -3
- data/lib/squib/args/paragraph.rb +2 -2
- data/lib/squib/args/save_batch.rb +2 -2
- data/lib/squib/args/scale_box.rb +1 -1
- data/lib/squib/args/sheet.rb +3 -3
- data/lib/squib/args/showcase_special.rb +2 -2
- data/lib/squib/args/svg_special.rb +1 -1
- data/lib/squib/args/transform.rb +2 -2
- data/lib/squib/args/typographer.rb +5 -4
- data/lib/squib/args/unit_conversion.rb +4 -4
- data/lib/squib/card.rb +8 -8
- data/lib/squib/conf.rb +5 -5
- data/lib/squib/deck.rb +20 -18
- data/lib/squib/graphics/cairo_context_wrapper.rb +3 -3
- data/lib/squib/graphics/gradient_regex.rb +1 -1
- data/lib/squib/graphics/hand.rb +2 -2
- data/lib/squib/graphics/save_doc.rb +9 -8
- data/lib/squib/graphics/save_images.rb +24 -11
- data/lib/squib/graphics/shapes.rb +16 -17
- data/lib/squib/graphics/showcase.rb +9 -9
- data/lib/squib/graphics/text.rb +21 -21
- data/lib/squib/layout_parser.rb +9 -9
- 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/sample_helpers.rb +1 -1
- data/lib/squib/version.rb +1 -1
- data/samples/{backend.rb → backend/_backend.rb} +2 -2
- data/samples/basic.rb +3 -3
- data/samples/bug134.rb +14 -0
- data/samples/build_groups/build_groups.rb +36 -0
- data/samples/cairo_access.rb +12 -1
- data/samples/{colors.rb → colors/_colors.rb} +12 -12
- data/samples/{gradients.rb → colors/_gradients.rb} +1 -1
- data/samples/config_text_markup.rb +2 -2
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/{csv_import.rb → data/_csv.rb} +8 -1
- data/samples/{excel.rb → data/_excel.rb} +3 -3
- data/samples/embed_text.rb +21 -0
- data/samples/hello_world.rb +1 -1
- data/samples/{load_images.rb → images/_more_load_images.rb} +2 -2
- data/samples/layouts.rb +11 -1
- data/samples/layouts_builtin.rb +51 -51
- data/samples/offset.svg +71 -71
- data/samples/ranges.rb +7 -7
- data/samples/{hand.rb → saves/_hand.rb} +1 -2
- data/samples/{portrait-landscape.rb → saves/_portrait_landscape.rb} +4 -4
- data/samples/{saves.rb → saves/_saves.rb} +0 -0
- data/samples/{showcase.rb → saves/_showcase.rb} +2 -2
- data/samples/{draw_shapes.rb → shapes/_draw_shapes.rb} +1 -1
- data/samples/text/_text.rb +4 -3
- data/samples/text_options.rb +6 -6
- data/samples/unicode.rb +1 -1
- data/spec/api/api_data_spec.rb +59 -4
- data/spec/api/api_settings_spec.rb +1 -1
- data/spec/args/box_spec.rb +7 -7
- data/spec/args/draw_spec.rb +19 -19
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +2 -2
- data/spec/args/paint_spec.rb +5 -5
- data/spec/args/paragraph_spec.rb +28 -28
- data/spec/args/range_spec.rb +1 -1
- data/spec/args/save_batch_spec.rb +10 -10
- data/spec/args/scale_box_spec.rb +9 -9
- data/spec/args/sheet_spec.rb +8 -8
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +4 -4
- data/spec/args/typographer_spec.rb +11 -11
- data/spec/args/unit_conversion_spec.rb +2 -2
- data/spec/card_spec.rb +1 -1
- data/spec/commands/new_spec.rb +1 -1
- data/spec/data/csv/custom_opts.csv +2 -0
- data/spec/data/csv/newline.csv +3 -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/csv/yield.csv +3 -0
- data/spec/data/samples/{autoscale_font.rb.txt → autoscale_font/_autoscale_font.rb.txt} +55 -18
- data/spec/data/samples/cairo_access.rb.txt +24 -0
- data/spec/data/samples/{gradients.rb.txt → colors/_gradients.rb.txt} +0 -0
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/custom_config.rb.txt +1 -0
- data/spec/data/samples/{csv_import.rb.txt → data/_csv.rb.txt} +0 -0
- data/spec/data/samples/{excel.rb.txt → data/_excel.rb.txt} +0 -0
- data/spec/data/samples/embed_text.rb.txt +79 -0
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/{load_images.rb.txt → images/_more_load_images.rb.txt} +4 -4
- data/spec/data/samples/{hand.rb.txt → saves/_hand.rb.txt} +0 -0
- data/spec/data/samples/{portrait-landscape.rb.txt → saves/_portrait_landscape.rb.txt} +11 -7
- data/spec/data/samples/{save_pdf.rb.txt → saves/_save_pdf.rb.txt} +0 -0
- data/spec/data/samples/{saves.rb.txt → saves/_saves.rb.txt} +3 -4
- data/spec/data/samples/{showcase.rb.txt → saves/_showcase.rb.txt} +0 -0
- data/spec/data/samples/{draw_shapes.rb.txt → shapes/_draw_shapes.rb.txt} +0 -0
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/graphics/cairo_context_wrapper_spec.rb +10 -10
- data/spec/graphics/graphics_save_doc_spec.rb +11 -5
- data/spec/layout_parser_spec.rb +21 -9
- data/spec/logger_spec.rb +2 -2
- data/spec/samples/run_samples_spec.rb +1 -1
- data/spec/samples/samples_regression_spec.rb +16 -18
- data/spec/samples/sanity.rb +9 -9
- data/spec/sanity/.gitignore +1 -0
- data/spec/sanity/sanity.html.erb +42 -0
- data/spec/sanity/sanity_test.rb +42 -0
- data/spec/sanity/tests.yml +12 -0
- data/spec/spec_helper.rb +22 -20
- data/squib.gemspec +3 -4
- metadata +143 -81
- data/.rspec +0 -1
- data/.yardopts +0 -10
- data/samples/autoscale_font.rb +0 -27
- data/samples/backend-config.yml +0 -5
- data/samples/color_shortcuts.rb +0 -6
- data/samples/explode_quantities.xlsx +0 -0
- data/samples/quantity_explosion.csv +0 -3
- data/samples/sample.csv +0 -3
- data/samples/sample.xlsx +0 -0
- data/squib.sublime-project +0 -42
@@ -6,7 +6,7 @@ Squib::Deck.new(config: 'config_text_markup.yml') do
|
|
6
6
|
x: 10, y: 10, width: 300, height: 200, font: 'Serif 20',
|
7
7
|
markup: true, hint: :cyan
|
8
8
|
|
9
|
-
text str:
|
9
|
+
text str: 'Notice also the antialiasing method.',
|
10
10
|
x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 20'
|
11
11
|
|
12
12
|
save_png prefix: 'config_text_'
|
@@ -17,4 +17,4 @@ Squib::Deck.new(config: 'config_disable_quotes.yml') do
|
|
17
17
|
x: 10, y: 10, width: 300, height: 200, font: 'Serif 20',
|
18
18
|
markup: true, hint: :cyan
|
19
19
|
save_png prefix: 'config_disable_text_'
|
20
|
-
end
|
20
|
+
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
|
@@ -22,5 +22,12 @@ Squib::Deck.new(cards: num_cards) do
|
|
22
22
|
background color: :white
|
23
23
|
rect # card border
|
24
24
|
text str: data['Name'], font: 'Arial 54'
|
25
|
-
save_sheet
|
25
|
+
save_sheet prefix: 'sample_csv_qty_', columns: 4
|
26
26
|
end
|
27
|
+
|
28
|
+
# Additionally, CSV supports inline data specifically
|
29
|
+
data = Squib.csv data: <<-EOCSV
|
30
|
+
Name,Cost
|
31
|
+
Knight,3
|
32
|
+
Orc,1
|
33
|
+
EOCSV
|
@@ -11,7 +11,7 @@ Squib::Deck.new(cards: 3) do
|
|
11
11
|
text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
|
12
12
|
text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
|
13
13
|
|
14
|
-
save format: :png, prefix: 'sample_excel_' #save to individual pngs
|
14
|
+
save format: :png, prefix: 'sample_excel_' # save to individual pngs
|
15
15
|
end
|
16
16
|
|
17
17
|
# xlsx is also a Squib-module-level function, so this also works:
|
@@ -22,7 +22,7 @@ Squib::Deck.new(cards: num_cards) do
|
|
22
22
|
background color: :white
|
23
23
|
rect # card border
|
24
24
|
text str: data['Name'], font: 'Arial 54'
|
25
|
-
save_sheet
|
25
|
+
save_sheet prefix: 'sample_xlsx_qty_', columns: 4
|
26
26
|
end
|
27
27
|
|
28
28
|
|
@@ -51,5 +51,5 @@ Squib::Deck.new(cards: resource_data['Name'].size) do
|
|
51
51
|
rect width: :deck, height: :deck
|
52
52
|
text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
|
53
53
|
text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
|
54
|
-
save_sheet prefix: 'sample_excel_resources_' #save to a whole sheet
|
54
|
+
save_sheet prefix: 'sample_excel_resources_' # save to a whole sheet
|
55
55
|
end
|
data/samples/embed_text.rb
CHANGED
@@ -73,6 +73,27 @@ Squib::Deck.new do
|
|
73
73
|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
74
74
|
end
|
75
75
|
|
76
|
+
embed_text = ':tool:' # JUST the icon
|
77
|
+
text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
|
78
|
+
font: 'Arial 21', align: :center, valign: :middle, hint: :red) do |embed|
|
79
|
+
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
80
|
+
end
|
81
|
+
|
82
|
+
embed_text = ':purse:' # JUST the icon
|
83
|
+
text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
|
84
|
+
font: 'Arial 21', align: :center, valign: :middle, hint: :red) do |embed|
|
85
|
+
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
86
|
+
end
|
87
|
+
|
88
|
+
embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
|
89
|
+
text(str: embed_text, font: 'Sans Bold 24', stroke_width: 2,
|
90
|
+
color: :red, stroke_color: :blue, dash: '3 3', align: :center,
|
91
|
+
valign: :middle, x: 0, y: 700, width: 380, height: 150,
|
92
|
+
hint: :magenta) do |embed|
|
93
|
+
embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
|
94
|
+
embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
|
95
|
+
end
|
96
|
+
|
76
97
|
save_png prefix: 'embed_'
|
77
98
|
end
|
78
99
|
|
data/samples/hello_world.rb
CHANGED
@@ -10,7 +10,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.
|
|
10
10
|
# Can be scaled if width and height are set
|
11
11
|
svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
|
12
12
|
png file: 'shiny-purse.png', x: 305, y: 50, width: 250, height: 250
|
13
|
-
|
13
|
+
# ...but PNGs will warn if it's an upscale, unless you disable them in config.yml
|
14
14
|
|
15
15
|
# Can be scaled using just width or height, if one of them is set to :scale
|
16
16
|
svg file: 'spanner.svg', x: 200, y: 350, width: 35, height: :scale
|
@@ -60,7 +60,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.
|
|
60
60
|
|
61
61
|
# WARNING! If you choose to use the SVG ID, the x-y coordinates are still
|
62
62
|
# relative to the SVG page. See this example in an SVG editor
|
63
|
-
svg file: 'offset.svg', id: 'thing',
|
63
|
+
svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600
|
64
64
|
|
65
65
|
# Over 15 different blending operators are supported.
|
66
66
|
# See http://cairographics.org/operators
|
data/samples/layouts.rb
CHANGED
@@ -46,7 +46,7 @@ end
|
|
46
46
|
Squib::Deck.new(layout: 'playing-card.yml') do
|
47
47
|
text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
|
48
48
|
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
|
49
|
-
text str:
|
49
|
+
text str: 'artwork here', layout: :art, hint: :red
|
50
50
|
save_png prefix: 'layout_builtin_playing_card_'
|
51
51
|
end
|
52
52
|
|
@@ -60,3 +60,13 @@ Squib::Deck.new(layout: 'hand.yml') do
|
|
60
60
|
png file: 'pokercard.png', alpha: 0.5
|
61
61
|
save_png prefix: 'layout_builtin_hand_'
|
62
62
|
end
|
63
|
+
|
64
|
+
# Layouts can also be specified in their own DSL method call
|
65
|
+
# Each layout call will progressively be merged with the priors
|
66
|
+
Squib::Deck.new do
|
67
|
+
use_layout file: 'custom-layout.yml'
|
68
|
+
use_layout file: 'custom-layout2.yml'
|
69
|
+
text str: 'The Title', layout: :title # from custom-layout.yml
|
70
|
+
text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
|
71
|
+
save_png prefix: 'layout3_'
|
72
|
+
end
|
data/samples/layouts_builtin.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
require 'squib'
|
2
|
-
|
3
|
-
# This sample demonstrates the built-in layouts for Squib.
|
4
|
-
# Each card demonstrates a different built-in layout.
|
5
|
-
Squib::Deck.new(layout: 'fantasy.yml') do
|
6
|
-
background color: 'white'
|
7
|
-
|
8
|
-
set font: 'Times New Roman,Serif 32'
|
9
|
-
hint text: '#333' # show extents of text boxes to demo the layout
|
10
|
-
|
11
|
-
text str: 'fantasy.yml', layout: :title
|
12
|
-
text str: 'ur', layout: :upper_right
|
13
|
-
text str: 'art', layout: :art
|
14
|
-
text str: 'type', layout: :type
|
15
|
-
text str: 'tr', layout: :type_right
|
16
|
-
text str: 'description', layout: :description
|
17
|
-
text str: 'lr', layout: :lower_right
|
18
|
-
text str: 'll', layout: :lower_left
|
19
|
-
text str: 'credits', layout: :copy
|
20
|
-
|
21
|
-
rect layout: :safe
|
22
|
-
rect layout: :cut
|
23
|
-
save_png prefix: 'layouts_builtin_fantasy_'
|
24
|
-
end
|
25
|
-
|
26
|
-
Squib::Deck.new(layout: 'economy.yml') do
|
27
|
-
background color: 'white'
|
28
|
-
|
29
|
-
set font: 'Times New Roman,Serif 32'
|
30
|
-
hint text: '#333' # show extents of text boxes to demo the layout
|
31
|
-
|
32
|
-
text str: 'economy.yml', layout: :title
|
33
|
-
text str: 'art', layout: :art
|
34
|
-
text str: 'description', layout: :description
|
35
|
-
text str: 'type', layout: :type
|
36
|
-
text str: 'lr', layout: :lower_right
|
37
|
-
text str: 'll', layout: :lower_left
|
38
|
-
text str: 'credits', layout: :copy
|
39
|
-
|
40
|
-
rect layout: :safe
|
41
|
-
rect layout: :cut
|
42
|
-
save_png prefix: 'layouts_builtin_economy_'
|
43
|
-
end
|
44
|
-
|
45
|
-
# Stitch together a deck of all the above examples
|
46
|
-
Squib::Deck.new(cards: 2) do
|
47
|
-
Dir.glob('_output/layouts_builtin_*.png').each.with_index do |file, i|
|
48
|
-
png file: file, range: i
|
49
|
-
end
|
50
|
-
save_sheet prefix: 'layouts_builtinsheet_'
|
51
|
-
end
|
1
|
+
require 'squib'
|
2
|
+
|
3
|
+
# This sample demonstrates the built-in layouts for Squib.
|
4
|
+
# Each card demonstrates a different built-in layout.
|
5
|
+
Squib::Deck.new(layout: 'fantasy.yml') do
|
6
|
+
background color: 'white'
|
7
|
+
|
8
|
+
set font: 'Times New Roman,Serif 32'
|
9
|
+
hint text: '#333' # show extents of text boxes to demo the layout
|
10
|
+
|
11
|
+
text str: 'fantasy.yml', layout: :title
|
12
|
+
text str: 'ur', layout: :upper_right
|
13
|
+
text str: 'art', layout: :art
|
14
|
+
text str: 'type', layout: :type
|
15
|
+
text str: 'tr', layout: :type_right
|
16
|
+
text str: 'description', layout: :description
|
17
|
+
text str: 'lr', layout: :lower_right
|
18
|
+
text str: 'll', layout: :lower_left
|
19
|
+
text str: 'credits', layout: :copy
|
20
|
+
|
21
|
+
rect layout: :safe
|
22
|
+
rect layout: :cut
|
23
|
+
save_png prefix: 'layouts_builtin_fantasy_'
|
24
|
+
end
|
25
|
+
|
26
|
+
Squib::Deck.new(layout: 'economy.yml') do
|
27
|
+
background color: 'white'
|
28
|
+
|
29
|
+
set font: 'Times New Roman,Serif 32'
|
30
|
+
hint text: '#333' # show extents of text boxes to demo the layout
|
31
|
+
|
32
|
+
text str: 'economy.yml', layout: :title
|
33
|
+
text str: 'art', layout: :art
|
34
|
+
text str: 'description', layout: :description
|
35
|
+
text str: 'type', layout: :type
|
36
|
+
text str: 'lr', layout: :lower_right
|
37
|
+
text str: 'll', layout: :lower_left
|
38
|
+
text str: 'credits', layout: :copy
|
39
|
+
|
40
|
+
rect layout: :safe
|
41
|
+
rect layout: :cut
|
42
|
+
save_png prefix: 'layouts_builtin_economy_'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Stitch together a deck of all the above examples
|
46
|
+
Squib::Deck.new(cards: 2) do
|
47
|
+
Dir.glob('_output/layouts_builtin_*.png').each.with_index do |file, i|
|
48
|
+
png file: file, range: i
|
49
|
+
end
|
50
|
+
save_sheet prefix: 'layouts_builtinsheet_'
|
51
|
+
end
|
data/samples/offset.svg
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
-
|
4
|
-
<svg
|
5
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
-
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
-
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
10
|
-
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
-
width="747.59235"
|
13
|
-
height="747.39734"
|
14
|
-
id="svg2"
|
15
|
-
version="1.1"
|
16
|
-
inkscape:version="0.48.5 r10040"
|
17
|
-
sodipodi:docname="offset.svg">
|
18
|
-
<defs
|
19
|
-
id="defs4" />
|
20
|
-
<sodipodi:namedview
|
21
|
-
id="base"
|
22
|
-
pagecolor="#ffffff"
|
23
|
-
bordercolor="#666666"
|
24
|
-
borderopacity="1.0"
|
25
|
-
inkscape:pageopacity="0.0"
|
26
|
-
inkscape:pageshadow="2"
|
27
|
-
inkscape:zoom="0.76264655"
|
28
|
-
inkscape:cx="373.79617"
|
29
|
-
inkscape:cy="373.69867"
|
30
|
-
inkscape:document-units="px"
|
31
|
-
inkscape:current-layer="layer1"
|
32
|
-
showgrid="false"
|
33
|
-
inkscape:window-width="1440"
|
34
|
-
inkscape:window-height="776"
|
35
|
-
inkscape:window-x="0"
|
36
|
-
inkscape:window-y="0"
|
37
|
-
inkscape:window-maximized="1"
|
38
|
-
fit-margin-top="0"
|
39
|
-
fit-margin-left="0"
|
40
|
-
fit-margin-right="0"
|
41
|
-
fit-margin-bottom="0" />
|
42
|
-
<metadata
|
43
|
-
id="metadata7">
|
44
|
-
<rdf:RDF>
|
45
|
-
<cc:Work
|
46
|
-
rdf:about="">
|
47
|
-
<dc:format>image/svg+xml</dc:format>
|
48
|
-
<dc:type
|
49
|
-
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
50
|
-
<dc:title />
|
51
|
-
</cc:Work>
|
52
|
-
</rdf:RDF>
|
53
|
-
</metadata>
|
54
|
-
<g
|
55
|
-
inkscape:label="Layer 1"
|
56
|
-
inkscape:groupmode="layer"
|
57
|
-
id="layer1"
|
58
|
-
transform="translate(5.1573995,-302.70286)">
|
59
|
-
<path
|
60
|
-
sodipodi:type="arc"
|
61
|
-
style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
62
|
-
id="thing"
|
63
|
-
sodipodi:cx="159.99248"
|
64
|
-
sodipodi:cy="152.67546"
|
65
|
-
sodipodi:rx="59.401001"
|
66
|
-
sodipodi:ry="59.401001"
|
67
|
-
d="m 219.39348,152.67546 c 0,32.80627 -26.59474,59.401 -59.401,59.401 -32.80627,0 -59.401,-26.59473 -59.401,-59.401 0,-32.80627 26.59473,-59.401 59.401,-59.401 32.80626,0 59.401,26.59473 59.401,59.401 z"
|
68
|
-
transform="matrix(0.95784259,0,0,0.95784259,531.73189,844.72627)"
|
69
|
-
inkscape:label="thing" />
|
70
|
-
</g>
|
71
|
-
</svg>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="747.59235"
|
13
|
+
height="747.39734"
|
14
|
+
id="svg2"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.48.5 r10040"
|
17
|
+
sodipodi:docname="offset.svg">
|
18
|
+
<defs
|
19
|
+
id="defs4" />
|
20
|
+
<sodipodi:namedview
|
21
|
+
id="base"
|
22
|
+
pagecolor="#ffffff"
|
23
|
+
bordercolor="#666666"
|
24
|
+
borderopacity="1.0"
|
25
|
+
inkscape:pageopacity="0.0"
|
26
|
+
inkscape:pageshadow="2"
|
27
|
+
inkscape:zoom="0.76264655"
|
28
|
+
inkscape:cx="373.79617"
|
29
|
+
inkscape:cy="373.69867"
|
30
|
+
inkscape:document-units="px"
|
31
|
+
inkscape:current-layer="layer1"
|
32
|
+
showgrid="false"
|
33
|
+
inkscape:window-width="1440"
|
34
|
+
inkscape:window-height="776"
|
35
|
+
inkscape:window-x="0"
|
36
|
+
inkscape:window-y="0"
|
37
|
+
inkscape:window-maximized="1"
|
38
|
+
fit-margin-top="0"
|
39
|
+
fit-margin-left="0"
|
40
|
+
fit-margin-right="0"
|
41
|
+
fit-margin-bottom="0" />
|
42
|
+
<metadata
|
43
|
+
id="metadata7">
|
44
|
+
<rdf:RDF>
|
45
|
+
<cc:Work
|
46
|
+
rdf:about="">
|
47
|
+
<dc:format>image/svg+xml</dc:format>
|
48
|
+
<dc:type
|
49
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
50
|
+
<dc:title />
|
51
|
+
</cc:Work>
|
52
|
+
</rdf:RDF>
|
53
|
+
</metadata>
|
54
|
+
<g
|
55
|
+
inkscape:label="Layer 1"
|
56
|
+
inkscape:groupmode="layer"
|
57
|
+
id="layer1"
|
58
|
+
transform="translate(5.1573995,-302.70286)">
|
59
|
+
<path
|
60
|
+
sodipodi:type="arc"
|
61
|
+
style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
62
|
+
id="thing"
|
63
|
+
sodipodi:cx="159.99248"
|
64
|
+
sodipodi:cy="152.67546"
|
65
|
+
sodipodi:rx="59.401001"
|
66
|
+
sodipodi:ry="59.401001"
|
67
|
+
d="m 219.39348,152.67546 c 0,32.80627 -26.59474,59.401 -59.401,59.401 -32.80627,0 -59.401,-26.59473 -59.401,-59.401 0,-32.80627 26.59473,-59.401 59.401,-59.401 32.80626,0 59.401,26.59473 59.401,59.401 z"
|
68
|
+
transform="matrix(0.95784259,0,0,0.95784259,531.73189,844.72627)"
|
69
|
+
inkscape:label="thing" />
|
70
|
+
</g>
|
71
|
+
</svg>
|
data/samples/ranges.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'squib'
|
2
2
|
|
3
|
-
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
|
3
|
+
data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
|
4
4
|
'type' => ['Thug', 'Thinker', 'Thinker'],
|
5
|
-
'level' => [1,2,3]}
|
5
|
+
'level' => [1, 2, 3] }
|
6
6
|
|
7
7
|
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
8
8
|
# Default range is :all
|
@@ -26,7 +26,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
|
26
26
|
text range: -2..-1, str: 'Grifter and Mastermind only!', x: 25, y: 650
|
27
27
|
|
28
28
|
# We can use Arrays too!
|
29
|
-
text range: [0,2], str: 'Thief and Mastermind only!!', x: 25, y:300
|
29
|
+
text range: [0, 2], str: 'Thief and Mastermind only!!', x: 25, y:300
|
30
30
|
|
31
31
|
# Just about everything in Squib can be given an array that
|
32
32
|
# corresponds to the deck's cards. This allows for each card to be styled differently
|
@@ -38,24 +38,24 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
|
38
38
|
|
39
39
|
# Useful idiom: construct a hash from card names back to its index (ID),
|
40
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}
|
41
|
+
id = {} ; data['name'].each_with_index{ |name, i| id[name] = i}
|
42
42
|
text range: id['Thief']..id['Grifter'],
|
43
43
|
str: 'Thief through Grifter with id lookup!!',
|
44
44
|
x:25, y: 400
|
45
45
|
|
46
46
|
# Useful idiom: generate arrays from a column called 'type'
|
47
|
-
type = {}; data['type'].each_with_index{ |t,i| (type[t] ||= []) << i}
|
47
|
+
type = {}; data['type'].each_with_index{ |t, i| (type[t] ||= []) << i}
|
48
48
|
text range: type['Thinker'],
|
49
49
|
str: 'Only for Thinkers!',
|
50
50
|
x:25, y: 500
|
51
51
|
|
52
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
|
53
|
+
hearts = [nil, 1, 2] # i.e. card 0 has no hearts, card 2 has 2 hearts drawn
|
54
54
|
1.upto(2).each do |n|
|
55
55
|
range = hearts.each_index.select { |i| hearts[i] == n}
|
56
56
|
n.times do |i|
|
57
57
|
svg file: 'glass-heart.svg', range: range,
|
58
|
-
x: 150, y: 55 + i*42, width: 40, height: 40
|
58
|
+
x: 150, y: 55 + i * 42, width: 40, height: 40
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|