squib 0.18.0 → 0.19.0a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -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 24', 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 24', 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/data/_csv.rb
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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 18'
|
|
9
|
-
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
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 18'
|
|
25
|
-
save_sheet prefix: 'sample_csv_qty_', columns: 4
|
|
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
|
|
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 18'
|
|
9
|
+
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
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 18'
|
|
25
|
+
save_sheet prefix: 'sample_csv_qty_', columns: 4
|
|
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
|
data/samples/data/_excel.rb
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new(cards: 3) do
|
|
4
|
-
background color: :white
|
|
5
|
-
|
|
6
|
-
# Reads the first sheet by default (sheet 0)
|
|
7
|
-
# Outputs a hash of arrays with the header names as keys
|
|
8
|
-
data = xlsx file: 'sample.xlsx'
|
|
9
|
-
|
|
10
|
-
text str: data['Name'], x: 250, y: 55, font: 'Arial 18'
|
|
11
|
-
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
12
|
-
text str: data['Description'], x: 65, y: 600, font: 'Arial 12'
|
|
13
|
-
|
|
14
|
-
save format: :png, prefix: 'sample_excel_' # save to individual pngs
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# xlsx is also a Squib-module-level function, so this also works:
|
|
18
|
-
data = Squib.xlsx file: 'explode_quantities.xlsx' # 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 18'
|
|
25
|
-
save_sheet prefix: 'sample_xlsx_qty_', columns: 4
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# Here's another example, a bit more realistic. Here's what's going on:
|
|
30
|
-
# * We call xlsx from Squib directly - BEFORE Squib::Deck creation. This
|
|
31
|
-
# allows us to infer the number of cards based on the size of the "Name"
|
|
32
|
-
# field
|
|
33
|
-
# * We make use of quantity explosion. Fields named "Qty" or "Quantity"
|
|
34
|
-
# (any capitalization), or any other in the "qty_header" get expanded by the
|
|
35
|
-
# number given
|
|
36
|
-
# * We also make sure that trailing and leading whitespace is stripped
|
|
37
|
-
# from each value. This is the default behavior in Squib, but the options
|
|
38
|
-
# are here just to make sure.
|
|
39
|
-
|
|
40
|
-
resource_data = Squib.xlsx(file: 'sample.xlsx', explode: 'Qty', sheet: 2, strip: true) do |header, value|
|
|
41
|
-
case header
|
|
42
|
-
when 'Cost'
|
|
43
|
-
"$#{value}k" # e.g. "3" becomes "$3k"
|
|
44
|
-
else
|
|
45
|
-
value # always return the original value if you didn't do anything to it
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
Squib::Deck.new(cards: resource_data['Name'].size) do
|
|
50
|
-
background color: :white
|
|
51
|
-
rect width: :deck, height: :deck
|
|
52
|
-
text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
|
|
53
|
-
text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
|
|
54
|
-
save_sheet prefix: 'sample_excel_resources_', columns: 3
|
|
55
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new(cards: 3) do
|
|
4
|
+
background color: :white
|
|
5
|
+
|
|
6
|
+
# Reads the first sheet by default (sheet 0)
|
|
7
|
+
# Outputs a hash of arrays with the header names as keys
|
|
8
|
+
data = xlsx file: 'sample.xlsx'
|
|
9
|
+
|
|
10
|
+
text str: data['Name'], x: 250, y: 55, font: 'Arial 18'
|
|
11
|
+
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
12
|
+
text str: data['Description'], x: 65, y: 600, font: 'Arial 12'
|
|
13
|
+
|
|
14
|
+
save format: :png, prefix: 'sample_excel_' # save to individual pngs
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# xlsx is also a Squib-module-level function, so this also works:
|
|
18
|
+
data = Squib.xlsx file: 'explode_quantities.xlsx' # 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 18'
|
|
25
|
+
save_sheet prefix: 'sample_xlsx_qty_', columns: 4
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Here's another example, a bit more realistic. Here's what's going on:
|
|
30
|
+
# * We call xlsx from Squib directly - BEFORE Squib::Deck creation. This
|
|
31
|
+
# allows us to infer the number of cards based on the size of the "Name"
|
|
32
|
+
# field
|
|
33
|
+
# * We make use of quantity explosion. Fields named "Qty" or "Quantity"
|
|
34
|
+
# (any capitalization), or any other in the "qty_header" get expanded by the
|
|
35
|
+
# number given
|
|
36
|
+
# * We also make sure that trailing and leading whitespace is stripped
|
|
37
|
+
# from each value. This is the default behavior in Squib, but the options
|
|
38
|
+
# are here just to make sure.
|
|
39
|
+
|
|
40
|
+
resource_data = Squib.xlsx(file: 'sample.xlsx', explode: 'Qty', sheet: 2, strip: true) do |header, value|
|
|
41
|
+
case header
|
|
42
|
+
when 'Cost'
|
|
43
|
+
"$#{value}k" # e.g. "3" becomes "$3k"
|
|
44
|
+
else
|
|
45
|
+
value # always return the original value if you didn't do anything to it
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Squib::Deck.new(cards: resource_data['Name'].size) do
|
|
50
|
+
background color: :white
|
|
51
|
+
rect width: :deck, height: :deck
|
|
52
|
+
text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
|
|
53
|
+
text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
|
|
54
|
+
save_sheet prefix: 'sample_excel_resources_', columns: 3
|
|
55
|
+
end
|
data/samples/data/_yaml.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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 = yaml file: 'sample.yaml'
|
|
8
|
-
text str: data['Type'], x: 250, y: 55, font: 'Arial 18'
|
|
9
|
-
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
10
|
-
|
|
11
|
-
save format: :png, prefix: 'sample_yaml_'
|
|
12
|
-
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 = yaml file: 'sample.yaml'
|
|
8
|
+
text str: data['Type'], x: 250, y: 55, font: 'Arial 18'
|
|
9
|
+
text str: data['Level'], x: 65, y: 65, font: 'Arial 24'
|
|
10
|
+
|
|
11
|
+
save format: :png, prefix: 'sample_yaml_'
|
|
12
|
+
end
|
data/samples/hello_world.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new(cards: 2) do
|
|
4
|
-
text str: %w(Hello World!)
|
|
5
|
-
save_png
|
|
6
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new(cards: 2) do
|
|
4
|
+
text str: %w(Hello World!)
|
|
5
|
+
save_png
|
|
6
|
+
end
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
|
|
3
|
-
Squib::Deck.new(cards: 2) do
|
|
4
|
-
background color: :white
|
|
5
|
-
# If you really need something custom-made, the underlying cairo context
|
|
6
|
-
# can be accessed directly via each Squib::Card
|
|
7
|
-
#
|
|
8
|
-
# WARNING! Input validation is not done on Squib::Cards. Proceed at your own risk.
|
|
9
|
-
|
|
10
|
-
# The recommended approach is to use Deck's Enumerable, which iterates over Squib::Cards
|
|
11
|
-
# I also recommend wrapping it in a Cairo save/restore, which Squib calls "use_cairo"
|
|
12
|
-
each do |card|
|
|
13
|
-
card.use_cairo do |cairo_context|
|
|
14
|
-
cairo_context.set_source_color(:blue)
|
|
15
|
-
cairo_context.circle(150, 150, 150)
|
|
16
|
-
cairo_context.fill
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Or the square bracket accessors []
|
|
21
|
-
self[1].use_cairo do |cairo_context|
|
|
22
|
-
cairo_context.circle(50, 50, 50)
|
|
23
|
-
cairo_context.set_source_color(:red)
|
|
24
|
-
cairo_context.fill
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Or modify the coordinate system for all (most?) future calls
|
|
28
|
-
# Could be handy for a dynamic bleed
|
|
29
|
-
each do |card|
|
|
30
|
-
# note how this does NOT use save/restore.
|
|
31
|
-
# again... this "feature" lives in the Land of Undefined Behavior
|
|
32
|
-
card.cairo_context.translate(500, 500)
|
|
33
|
-
end
|
|
34
|
-
rect x: 0, y: 0, # actually 500, 500
|
|
35
|
-
width: 50, height: 50, fill_color: :red
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
save_png prefix: 'cairo_access_'
|
|
39
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
|
|
3
|
+
Squib::Deck.new(cards: 2) do
|
|
4
|
+
background color: :white
|
|
5
|
+
# If you really need something custom-made, the underlying cairo context
|
|
6
|
+
# can be accessed directly via each Squib::Card
|
|
7
|
+
#
|
|
8
|
+
# WARNING! Input validation is not done on Squib::Cards. Proceed at your own risk.
|
|
9
|
+
|
|
10
|
+
# The recommended approach is to use Deck's Enumerable, which iterates over Squib::Cards
|
|
11
|
+
# I also recommend wrapping it in a Cairo save/restore, which Squib calls "use_cairo"
|
|
12
|
+
each do |card|
|
|
13
|
+
card.use_cairo do |cairo_context|
|
|
14
|
+
cairo_context.set_source_color(:blue)
|
|
15
|
+
cairo_context.circle(150, 150, 150)
|
|
16
|
+
cairo_context.fill
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Or the square bracket accessors []
|
|
21
|
+
self[1].use_cairo do |cairo_context|
|
|
22
|
+
cairo_context.circle(50, 50, 50)
|
|
23
|
+
cairo_context.set_source_color(:red)
|
|
24
|
+
cairo_context.fill
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Or modify the coordinate system for all (most?) future calls
|
|
28
|
+
# Could be handy for a dynamic bleed
|
|
29
|
+
each do |card|
|
|
30
|
+
# note how this does NOT use save/restore.
|
|
31
|
+
# again... this "feature" lives in the Land of Undefined Behavior
|
|
32
|
+
card.cairo_context.translate(500, 500)
|
|
33
|
+
end
|
|
34
|
+
rect x: 0, y: 0, # actually 500, 500
|
|
35
|
+
width: 50, height: 50, fill_color: :red
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
save_png prefix: 'cairo_access_'
|
|
39
|
+
end
|
data/samples/images/_images.rb
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
require 'squib'
|
|
2
|
-
require 'squib/sample_helpers'
|
|
3
|
-
|
|
4
|
-
Squib::Deck.new(width: 1000, height: 3000) do
|
|
5
|
-
draw_graph_paper width, height
|
|
6
|
-
|
|
7
|
-
sample "This a PNG.\nNo scaling is done by default." do |x, y|
|
|
8
|
-
png file: 'angler-fish.png', x: x, y: y
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
sample 'PNGs can be upscaled, but they will emit an antialias warning (unless you turn it off in the config.yml)' do |x,y|
|
|
12
|
-
png file: 'angler-fish.png', x: x, y: y, width: 150, height: 150
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
sample 'SVGs can be loaded from a file (left) or from straight XML (right). They can also be scaled to any size.' do |x,y|
|
|
16
|
-
svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100
|
|
17
|
-
svg data: File.read('robot-golem.svg'), width: 100, height: 100,
|
|
18
|
-
x: x + 200, y: y
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
sample 'PNG and SVG can be auto-scaled by one side and setting the other to :scale' do |x,y|
|
|
22
|
-
svg file: 'robot-golem.svg', x: x, y: y, width: 50, height: :scale
|
|
23
|
-
svg file: 'robot-golem.svg', x: x + 50, y: y, width: :scale, height: 50
|
|
24
|
-
|
|
25
|
-
png file: 'angler-fish.png', x: x + 200, y: y, width: 50, height: :scale
|
|
26
|
-
png file: 'angler-fish.png', x: x + 250, y: y, width: :scale, height: 50
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
sample 'PNGs can be cropped. To work from sprite sheets, you can set crop coordinates to PNG images. Rounded corners supported too.' do |x,y|
|
|
30
|
-
png file: 'sprites.png', x: x - 50, y: y - 50 # entire sprite sheet
|
|
31
|
-
rect x: x - 50, y: y - 50, width: 100, height: 100, # draw the crop line
|
|
32
|
-
radius: 15, dash: '3 3', stroke_color: 'red', stroke_width: 3
|
|
33
|
-
text str: '➜', font: 'Sans Bold 12', x: x + 150, y: y - 35
|
|
34
|
-
png file: 'sprites.png', x: x + 200, y: y - 50, # just the robot golem image
|
|
35
|
-
crop_x: 0, crop_y: 0, crop_corner_radius: 15,
|
|
36
|
-
crop_width: 100, crop_height: 100
|
|
37
|
-
|
|
38
|
-
png file: 'sprites.png', x: x - 50, y: y + 50 # entire sprite sheet again
|
|
39
|
-
rect x: x + 14, y: y + 50, width: 65, height: 65, # highlight the crop
|
|
40
|
-
radius: 25, dash: '3 3', stroke_color: 'red', stroke_width: 3
|
|
41
|
-
text str: '➜', font: 'Sans Bold 12', x: x + 150, y: y + 50
|
|
42
|
-
png file: 'sprites.png', x: x + 225, y: y + 50, # just the drakkar ship image, rotated
|
|
43
|
-
crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
|
|
44
|
-
crop_width: 64, crop_height: 64, angle: Math::PI / 6
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
sample 'SVGs can be cropped too.' do |x,y|
|
|
48
|
-
svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100,
|
|
49
|
-
crop_x: 40, crop_y: 0, crop_width: 50, crop_height: 50
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
sample 'Images can be flipped about their center.' do |x,y|
|
|
53
|
-
png file: 'angler-fish.png', x: x, y: y, flip_vertical: true, flip_horizontal: true
|
|
54
|
-
svg file: 'robot-golem.svg', x: x + 200, y: y, width: 100, height: 100,
|
|
55
|
-
flip_horizontal: true
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
sample 'SVG can be limited to rendering to a single object if the SVG ID is set. If you look in this SVG file, the black backdrop has ID #backdrop.' do |x,y|
|
|
59
|
-
svg file: 'robot-golem.svg', id: 'backdrop', x: x, y: y, width: 100, height: 100
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
sample "The SVG force_id option allows use of an ID only when specified, and render nothing if empty. Useful for multiple icons in one SVG file.\nThis should show nothing." do |x,y|
|
|
63
|
-
svg file: 'robot-golem.svg', x: x, y: y,
|
|
64
|
-
force_id: true, id: '' # <-- the important parts
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
sample 'NOTE! If you render a single object in an SVG, its placement is still relative to the SVG document.' do |x,y|
|
|
68
|
-
svg file: 'offset.svg', x: x, y: y
|
|
69
|
-
rect x: x, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
|
|
70
|
-
|
|
71
|
-
svg file: 'offset.svg', id: 'thing', x: x + 200, y: y, width: 100, height: 100
|
|
72
|
-
rect x: x + 200, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
sample 'PNGs can be blended onto each other with 15 different blending operators. Alpha transparency supported too. See http://cairographics.org/operators' do |x,y|
|
|
76
|
-
png file: 'ball.png', x: x, y: y
|
|
77
|
-
png file: 'grit.png', x: x + 20, y: y + 20, blend: :color_burn, alpha: 0.75
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
sample 'Rotation is around the upper-left corner of the image. Unit is radians.' do |x,y|
|
|
81
|
-
rect x: x, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
|
|
82
|
-
png x: x, y: y, width: 100, height: 100, angle: Math::PI / 4, file: 'angler-fish.png'
|
|
83
|
-
|
|
84
|
-
rect x: x + 250, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
|
|
85
|
-
svg x: x + 250, y: y, width: 100, height: 100, file: 'robot-golem.svg',
|
|
86
|
-
angle: Math::PI / 2 - 0.2
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
sample 'SVGs and PNGs can be used as masks for colors instead of being directly rendered.' do |x,y|
|
|
90
|
-
svg mask: '#00ff00', file: 'glass-heart.svg', x: x - 50, y: y - 50, width: 200, height: 200
|
|
91
|
-
svg mask: '(0,0)(500,0) #eee@0.0 #111@1.0', file: 'glass-heart.svg', x: x + 150, y: y - 50, width: 200, height: 200
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
sample 'PNG masks are based on the alpha channel. Gradient coordinates are relative to the card.' do |x,y|
|
|
95
|
-
png file: 'with-alpha.png', x: x - 50, y: y
|
|
96
|
-
png file: 'with-alpha.png', mask: :magenta, x: x + 50, y: y
|
|
97
|
-
|
|
98
|
-
mask = "(#{x+150+75}, #{y+75}, 0)(#{x+150+75}, #{y+75}, 100) #f00@0.0 #000@1.0"
|
|
99
|
-
png file: 'with-alpha.png', mask: mask, x: x + 150, y: y, width: 150, height: :scale
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
save_png prefix: '_images_'
|
|
104
|
-
end
|
|
1
|
+
require 'squib'
|
|
2
|
+
require 'squib/sample_helpers'
|
|
3
|
+
|
|
4
|
+
Squib::Deck.new(width: 1000, height: 3000) do
|
|
5
|
+
draw_graph_paper width, height
|
|
6
|
+
|
|
7
|
+
sample "This a PNG.\nNo scaling is done by default." do |x, y|
|
|
8
|
+
png file: 'angler-fish.png', x: x, y: y
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
sample 'PNGs can be upscaled, but they will emit an antialias warning (unless you turn it off in the config.yml)' do |x,y|
|
|
12
|
+
png file: 'angler-fish.png', x: x, y: y, width: 150, height: 150
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
sample 'SVGs can be loaded from a file (left) or from straight XML (right). They can also be scaled to any size.' do |x,y|
|
|
16
|
+
svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100
|
|
17
|
+
svg data: File.read('robot-golem.svg'), width: 100, height: 100,
|
|
18
|
+
x: x + 200, y: y
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
sample 'PNG and SVG can be auto-scaled by one side and setting the other to :scale' do |x,y|
|
|
22
|
+
svg file: 'robot-golem.svg', x: x, y: y, width: 50, height: :scale
|
|
23
|
+
svg file: 'robot-golem.svg', x: x + 50, y: y, width: :scale, height: 50
|
|
24
|
+
|
|
25
|
+
png file: 'angler-fish.png', x: x + 200, y: y, width: 50, height: :scale
|
|
26
|
+
png file: 'angler-fish.png', x: x + 250, y: y, width: :scale, height: 50
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sample 'PNGs can be cropped. To work from sprite sheets, you can set crop coordinates to PNG images. Rounded corners supported too.' do |x,y|
|
|
30
|
+
png file: 'sprites.png', x: x - 50, y: y - 50 # entire sprite sheet
|
|
31
|
+
rect x: x - 50, y: y - 50, width: 100, height: 100, # draw the crop line
|
|
32
|
+
radius: 15, dash: '3 3', stroke_color: 'red', stroke_width: 3
|
|
33
|
+
text str: '➜', font: 'Sans Bold 12', x: x + 150, y: y - 35
|
|
34
|
+
png file: 'sprites.png', x: x + 200, y: y - 50, # just the robot golem image
|
|
35
|
+
crop_x: 0, crop_y: 0, crop_corner_radius: 15,
|
|
36
|
+
crop_width: 100, crop_height: 100
|
|
37
|
+
|
|
38
|
+
png file: 'sprites.png', x: x - 50, y: y + 50 # entire sprite sheet again
|
|
39
|
+
rect x: x + 14, y: y + 50, width: 65, height: 65, # highlight the crop
|
|
40
|
+
radius: 25, dash: '3 3', stroke_color: 'red', stroke_width: 3
|
|
41
|
+
text str: '➜', font: 'Sans Bold 12', x: x + 150, y: y + 50
|
|
42
|
+
png file: 'sprites.png', x: x + 225, y: y + 50, # just the drakkar ship image, rotated
|
|
43
|
+
crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
|
|
44
|
+
crop_width: 64, crop_height: 64, angle: Math::PI / 6
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
sample 'SVGs can be cropped too.' do |x,y|
|
|
48
|
+
svg file: 'robot-golem.svg', x: x, y: y, width: 100, height: 100,
|
|
49
|
+
crop_x: 40, crop_y: 0, crop_width: 50, crop_height: 50
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
sample 'Images can be flipped about their center.' do |x,y|
|
|
53
|
+
png file: 'angler-fish.png', x: x, y: y, flip_vertical: true, flip_horizontal: true
|
|
54
|
+
svg file: 'robot-golem.svg', x: x + 200, y: y, width: 100, height: 100,
|
|
55
|
+
flip_horizontal: true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
sample 'SVG can be limited to rendering to a single object if the SVG ID is set. If you look in this SVG file, the black backdrop has ID #backdrop.' do |x,y|
|
|
59
|
+
svg file: 'robot-golem.svg', id: 'backdrop', x: x, y: y, width: 100, height: 100
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
sample "The SVG force_id option allows use of an ID only when specified, and render nothing if empty. Useful for multiple icons in one SVG file.\nThis should show nothing." do |x,y|
|
|
63
|
+
svg file: 'robot-golem.svg', x: x, y: y,
|
|
64
|
+
force_id: true, id: '' # <-- the important parts
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
sample 'NOTE! If you render a single object in an SVG, its placement is still relative to the SVG document.' do |x,y|
|
|
68
|
+
svg file: 'offset.svg', x: x, y: y
|
|
69
|
+
rect x: x, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
|
|
70
|
+
|
|
71
|
+
svg file: 'offset.svg', id: 'thing', x: x + 200, y: y, width: 100, height: 100
|
|
72
|
+
rect x: x + 200, y: y, width: 100, height: 100, dash: '3 1', stroke_color: 'red', stroke_width: 3
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
sample 'PNGs can be blended onto each other with 15 different blending operators. Alpha transparency supported too. See http://cairographics.org/operators' do |x,y|
|
|
76
|
+
png file: 'ball.png', x: x, y: y
|
|
77
|
+
png file: 'grit.png', x: x + 20, y: y + 20, blend: :color_burn, alpha: 0.75
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
sample 'Rotation is around the upper-left corner of the image. Unit is radians.' do |x,y|
|
|
81
|
+
rect x: x, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
|
|
82
|
+
png x: x, y: y, width: 100, height: 100, angle: Math::PI / 4, file: 'angler-fish.png'
|
|
83
|
+
|
|
84
|
+
rect x: x + 250, y: y, width: 100, height: 100, stroke_width: 3, dash: '3 3', stroke_color: :red
|
|
85
|
+
svg x: x + 250, y: y, width: 100, height: 100, file: 'robot-golem.svg',
|
|
86
|
+
angle: Math::PI / 2 - 0.2
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
sample 'SVGs and PNGs can be used as masks for colors instead of being directly rendered.' do |x,y|
|
|
90
|
+
svg mask: '#00ff00', file: 'glass-heart.svg', x: x - 50, y: y - 50, width: 200, height: 200
|
|
91
|
+
svg mask: '(0,0)(500,0) #eee@0.0 #111@1.0', file: 'glass-heart.svg', x: x + 150, y: y - 50, width: 200, height: 200
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
sample 'PNG masks are based on the alpha channel. Gradient coordinates are relative to the card.' do |x,y|
|
|
95
|
+
png file: 'with-alpha.png', x: x - 50, y: y
|
|
96
|
+
png file: 'with-alpha.png', mask: :magenta, x: x + 50, y: y
|
|
97
|
+
|
|
98
|
+
mask = "(#{x+150+75}, #{y+75}, 0)(#{x+150+75}, #{y+75}, 100) #f00@0.0 #000@1.0"
|
|
99
|
+
png file: 'with-alpha.png', mask: mask, x: x + 150, y: y, width: 150, height: :scale
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
save_png prefix: '_images_'
|
|
104
|
+
end
|