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
@@ -1,115 +1,115 @@
|
|
1
|
-
require_relative '../constants'
|
2
|
-
|
3
|
-
module Squib::Args
|
4
|
-
# Internal class for handling arguments
|
5
|
-
class Typographer
|
6
|
-
|
7
|
-
def initialize(config = Squib::Conf::DEFAULTS)
|
8
|
-
%w(lsquote ldquote rsquote rdquote smart_quotes
|
9
|
-
em_dash en_dash ellipsis).each do |var|
|
10
|
-
instance_variable_set("@#{var}", config[var])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def process(str)
|
15
|
-
str = explicit_replacements(str.to_s)
|
16
|
-
str = smart_quotes(str) if @smart_quotes
|
17
|
-
str
|
18
|
-
end
|
19
|
-
|
20
|
-
def explicit_replacements(str)
|
21
|
-
[ :left_curly, :right_curly, :apostraphize,
|
22
|
-
:ellipsificate, :em_dash, :en_dash ].each do |sym|
|
23
|
-
str = each_non_tag(str) do |token|
|
24
|
-
self.method(sym).call(token)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
str
|
28
|
-
end
|
29
|
-
|
30
|
-
def smart_quotes(str)
|
31
|
-
[ :single_inside_double_quote,
|
32
|
-
:right_double_quote,
|
33
|
-
:left_double_quote,
|
34
|
-
:right_single_quote,
|
35
|
-
:left_single_quote].each do |sym|
|
36
|
-
str = each_non_tag(str) do |token|
|
37
|
-
self.method(sym).call(token)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
str
|
41
|
-
end
|
42
|
-
|
43
|
-
# Iterate over each non-tag for processing
|
44
|
-
# Allows us to ignore anything inside < and >
|
45
|
-
def each_non_tag(str)
|
46
|
-
full_str = ''
|
47
|
-
tag_delimit = /(<(?:(?!<).)*>)/ # use non-capturing group w/ negative lookahead
|
48
|
-
str.split(tag_delimit).each do |token|
|
49
|
-
if token.start_with? '<'
|
50
|
-
full_str << token # don't process tags
|
51
|
-
else
|
52
|
-
full_str << yield(token)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
return full_str
|
56
|
-
end
|
57
|
-
|
58
|
-
# Straightforward replace
|
59
|
-
def left_curly(str)
|
60
|
-
str.gsub('``', @ldquote)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Straightforward replace
|
64
|
-
def right_curly(str)
|
65
|
-
str.gsub(%{''}, @rdquote)
|
66
|
-
end
|
67
|
-
|
68
|
-
# A quote between two letters is an apostraphe
|
69
|
-
def apostraphize(str)
|
70
|
-
str.gsub(/(\w)(\')(\w)/, '\1' + @rsquote + '\3')
|
71
|
-
end
|
72
|
-
|
73
|
-
# Straightforward replace
|
74
|
-
def ellipsificate(str)
|
75
|
-
str.gsub('...', @ellipsis)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Straightforward replace
|
79
|
-
def en_dash(str)
|
80
|
-
str.gsub('--', @en_dash)
|
81
|
-
end
|
82
|
-
|
83
|
-
# Straightforward replace
|
84
|
-
def em_dash(str)
|
85
|
-
str.gsub('---', @em_dash)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Quote next to non-whitespace curls
|
89
|
-
def right_double_quote(str)
|
90
|
-
str.gsub(/(\S)(\")/, '\1' + @rdquote)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Quote next to non-whitespace curls
|
94
|
-
def left_double_quote(str)
|
95
|
-
str.gsub(/(\")(\S)/, @ldquote + '\2')
|
96
|
-
end
|
97
|
-
|
98
|
-
# Handle the cases where a double quote is next to a single quote
|
99
|
-
def single_inside_double_quote(str)
|
100
|
-
str.gsub(/(\")(\')(\S)/, @ldquote + @lsquote + '\3')
|
101
|
-
.gsub(/(\")(\')(\S)/, '\1' + @rsquote + @rdquote)
|
102
|
-
end
|
103
|
-
|
104
|
-
# Quote next to non-whitespace curls
|
105
|
-
def right_single_quote(str)
|
106
|
-
str.gsub(/(\S)(\')/, '\1' + @rsquote)
|
107
|
-
end
|
108
|
-
|
109
|
-
# Quote next to non-whitespace curls
|
110
|
-
def left_single_quote(str)
|
111
|
-
str.gsub(/(\')(\S)/, @lsquote + '\2')
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
1
|
+
require_relative '../constants'
|
2
|
+
|
3
|
+
module Squib::Args
|
4
|
+
# Internal class for handling arguments
|
5
|
+
class Typographer
|
6
|
+
|
7
|
+
def initialize(config = Squib::Conf::DEFAULTS)
|
8
|
+
%w(lsquote ldquote rsquote rdquote smart_quotes
|
9
|
+
em_dash en_dash ellipsis).each do |var|
|
10
|
+
instance_variable_set("@#{var}", config[var])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def process(str)
|
15
|
+
str = explicit_replacements(str.to_s)
|
16
|
+
str = smart_quotes(str) if @smart_quotes
|
17
|
+
str
|
18
|
+
end
|
19
|
+
|
20
|
+
def explicit_replacements(str)
|
21
|
+
[ :left_curly, :right_curly, :apostraphize,
|
22
|
+
:ellipsificate, :em_dash, :en_dash ].each do |sym|
|
23
|
+
str = each_non_tag(str) do |token|
|
24
|
+
self.method(sym).call(token)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
str
|
28
|
+
end
|
29
|
+
|
30
|
+
def smart_quotes(str)
|
31
|
+
[ :single_inside_double_quote,
|
32
|
+
:right_double_quote,
|
33
|
+
:left_double_quote,
|
34
|
+
:right_single_quote,
|
35
|
+
:left_single_quote].each do |sym|
|
36
|
+
str = each_non_tag(str) do |token|
|
37
|
+
self.method(sym).call(token)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
str
|
41
|
+
end
|
42
|
+
|
43
|
+
# Iterate over each non-tag for processing
|
44
|
+
# Allows us to ignore anything inside < and >
|
45
|
+
def each_non_tag(str)
|
46
|
+
full_str = ''
|
47
|
+
tag_delimit = /(<(?:(?!<).)*>)/ # use non-capturing group w/ negative lookahead
|
48
|
+
str.split(tag_delimit).each do |token|
|
49
|
+
if token.start_with? '<'
|
50
|
+
full_str << token # don't process tags
|
51
|
+
else
|
52
|
+
full_str << yield(token)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return full_str
|
56
|
+
end
|
57
|
+
|
58
|
+
# Straightforward replace
|
59
|
+
def left_curly(str)
|
60
|
+
str.gsub('``', @ldquote)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Straightforward replace
|
64
|
+
def right_curly(str)
|
65
|
+
str.gsub(%{''}, @rdquote)
|
66
|
+
end
|
67
|
+
|
68
|
+
# A quote between two letters is an apostraphe
|
69
|
+
def apostraphize(str)
|
70
|
+
str.gsub(/(\w)(\')(\w)/, '\1' + @rsquote + '\3')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Straightforward replace
|
74
|
+
def ellipsificate(str)
|
75
|
+
str.gsub('...', @ellipsis)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Straightforward replace
|
79
|
+
def en_dash(str)
|
80
|
+
str.gsub('--', @en_dash)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Straightforward replace
|
84
|
+
def em_dash(str)
|
85
|
+
str.gsub('---', @em_dash)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Quote next to non-whitespace curls
|
89
|
+
def right_double_quote(str)
|
90
|
+
str.gsub(/(\S)(\")/, '\1' + @rdquote)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Quote next to non-whitespace curls
|
94
|
+
def left_double_quote(str)
|
95
|
+
str.gsub(/(\")(\S)/, @ldquote + '\2')
|
96
|
+
end
|
97
|
+
|
98
|
+
# Handle the cases where a double quote is next to a single quote
|
99
|
+
def single_inside_double_quote(str)
|
100
|
+
str.gsub(/(\")(\')(\S)/, @ldquote + @lsquote + '\3')
|
101
|
+
.gsub(/(\")(\')(\S)/, '\1' + @rsquote + @rdquote)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Quote next to non-whitespace curls
|
105
|
+
def right_single_quote(str)
|
106
|
+
str.gsub(/(\S)(\')/, '\1' + @rsquote)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Quote next to non-whitespace curls
|
110
|
+
def left_single_quote(str)
|
111
|
+
str.gsub(/(\')(\S)/, @lsquote + '\2')
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require_relative '../constants'
|
2
|
-
|
3
|
-
|
4
|
-
module Squib
|
5
|
-
module Args
|
6
|
-
module UnitConversion
|
7
|
-
module_function def parse(arg, dpi=300, cell_px=37.5)
|
8
|
-
case arg.to_s.rstrip
|
9
|
-
when /in$/ # ends with "in"
|
10
|
-
arg.rstrip[0..-2].to_f * dpi
|
11
|
-
when /pt$/ # ends with "in"
|
12
|
-
arg.rstrip[0..-2].to_f * dpi / POINTS_PER_IN
|
13
|
-
when /cm$/ # ends with "cm"
|
14
|
-
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
|
15
|
-
when /mm$/ # ends with "mm"
|
16
|
-
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM / 10.0
|
17
|
-
when /deg$/ # ends with "deg"
|
18
|
-
arg.rstrip[0..-3].to_f * (Math::PI / 180.0)
|
19
|
-
when /c(ell)?[s]?$/ # ends with 'c', 'cell', or 'cells'
|
20
|
-
arg.sub(/c(ell)?[s]?$/, '').to_f * cell_px
|
21
|
-
else
|
22
|
-
arg
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
require_relative '../constants'
|
2
|
+
|
3
|
+
|
4
|
+
module Squib
|
5
|
+
module Args
|
6
|
+
module UnitConversion
|
7
|
+
module_function def parse(arg, dpi=300, cell_px=37.5)
|
8
|
+
case arg.to_s.rstrip
|
9
|
+
when /in$/ # ends with "in"
|
10
|
+
arg.rstrip[0..-2].to_f * dpi
|
11
|
+
when /pt$/ # ends with "in"
|
12
|
+
arg.rstrip[0..-2].to_f * dpi / POINTS_PER_IN
|
13
|
+
when /cm$/ # ends with "cm"
|
14
|
+
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
|
15
|
+
when /mm$/ # ends with "mm"
|
16
|
+
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM / 10.0
|
17
|
+
when /deg$/ # ends with "deg"
|
18
|
+
arg.rstrip[0..-3].to_f * (Math::PI / 180.0)
|
19
|
+
when /c(ell)?[s]?$/ # ends with 'c', 'cell', or 'cells'
|
20
|
+
arg.sub(/c(ell)?[s]?$/, '').to_f * cell_px
|
21
|
+
else
|
22
|
+
arg
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require_relative 'unit_conversion'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
module Args
|
5
|
-
module XYWHShorthands
|
6
|
-
|
7
|
-
MIDDLE_ONLY = /^(middle|center)\s*$/
|
8
|
-
DECK_ONLY = /^deck\s*$/
|
9
|
-
MIDDLE_MINUS_REGEX = /^(middle|center)\s*\-\s*/
|
10
|
-
MIDDLE_PLUS_REGEX = /^(middle|center)\s*\+\s*/
|
11
|
-
DECK_MINUS_REGEX = /^deck\s*\-\s*/
|
12
|
-
DECK_PLUS_REGEX = /^deck\s*\+\s*/
|
13
|
-
DECK_DIV_REGEX = /^deck\s*\/\s*/
|
14
|
-
|
15
|
-
# dimension is usually either deck_width or deck_height
|
16
|
-
def apply_shorthands(arg, deck, axis: :x)
|
17
|
-
dimension = (axis == :x) ? deck.width : deck.height
|
18
|
-
arg_s = arg.to_s
|
19
|
-
case arg_s
|
20
|
-
when MIDDLE_ONLY
|
21
|
-
dimension / 2.0
|
22
|
-
when DECK_ONLY
|
23
|
-
dimension
|
24
|
-
when MIDDLE_MINUS_REGEX # e.g. width: middle - 3
|
25
|
-
n = arg_s.sub MIDDLE_MINUS_REGEX, ''
|
26
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
27
|
-
dimension / 2.0 - n
|
28
|
-
when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
|
29
|
-
n = arg_s.sub MIDDLE_PLUS_REGEX, ''
|
30
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
31
|
-
dimension / 2.0 + n
|
32
|
-
when DECK_MINUS_REGEX # e.g. width: deck - 1.5in
|
33
|
-
n = arg_s.sub DECK_MINUS_REGEX, ''
|
34
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
35
|
-
dimension - n
|
36
|
-
when DECK_PLUS_REGEX # e.g. deck + 1.5in (which is weird but ok)
|
37
|
-
n = arg_s.sub DECK_PLUS_REGEX, ''
|
38
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
39
|
-
dimension + n
|
40
|
-
when DECK_DIV_REGEX # e.g. width: deck/3
|
41
|
-
n = arg_s.sub DECK_DIV_REGEX, ''
|
42
|
-
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
43
|
-
dimension / n
|
44
|
-
else
|
45
|
-
arg
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require_relative 'unit_conversion'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
module Args
|
5
|
+
module XYWHShorthands
|
6
|
+
|
7
|
+
MIDDLE_ONLY = /^(middle|center)\s*$/
|
8
|
+
DECK_ONLY = /^deck\s*$/
|
9
|
+
MIDDLE_MINUS_REGEX = /^(middle|center)\s*\-\s*/
|
10
|
+
MIDDLE_PLUS_REGEX = /^(middle|center)\s*\+\s*/
|
11
|
+
DECK_MINUS_REGEX = /^deck\s*\-\s*/
|
12
|
+
DECK_PLUS_REGEX = /^deck\s*\+\s*/
|
13
|
+
DECK_DIV_REGEX = /^deck\s*\/\s*/
|
14
|
+
|
15
|
+
# dimension is usually either deck_width or deck_height
|
16
|
+
def apply_shorthands(arg, deck, axis: :x)
|
17
|
+
dimension = (axis == :x) ? deck.width : deck.height
|
18
|
+
arg_s = arg.to_s
|
19
|
+
case arg_s
|
20
|
+
when MIDDLE_ONLY
|
21
|
+
dimension / 2.0
|
22
|
+
when DECK_ONLY
|
23
|
+
dimension
|
24
|
+
when MIDDLE_MINUS_REGEX # e.g. width: middle - 3
|
25
|
+
n = arg_s.sub MIDDLE_MINUS_REGEX, ''
|
26
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
27
|
+
dimension / 2.0 - n
|
28
|
+
when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
|
29
|
+
n = arg_s.sub MIDDLE_PLUS_REGEX, ''
|
30
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
31
|
+
dimension / 2.0 + n
|
32
|
+
when DECK_MINUS_REGEX # e.g. width: deck - 1.5in
|
33
|
+
n = arg_s.sub DECK_MINUS_REGEX, ''
|
34
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
35
|
+
dimension - n
|
36
|
+
when DECK_PLUS_REGEX # e.g. deck + 1.5in (which is weird but ok)
|
37
|
+
n = arg_s.sub DECK_PLUS_REGEX, ''
|
38
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
39
|
+
dimension + n
|
40
|
+
when DECK_DIV_REGEX # e.g. width: deck/3
|
41
|
+
n = arg_s.sub DECK_DIV_REGEX, ''
|
42
|
+
n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
|
43
|
+
dimension / n
|
44
|
+
else
|
45
|
+
arg
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
#This layout inspired by popular economy games
|
2
|
-
title:
|
3
|
-
x: 90
|
4
|
-
y: 90
|
5
|
-
width: 635
|
6
|
-
height: 50
|
7
|
-
align: center
|
8
|
-
|
9
|
-
art:
|
10
|
-
x: 75
|
11
|
-
y: 150
|
12
|
-
width: 675
|
13
|
-
height: 520
|
14
|
-
|
15
|
-
description:
|
16
|
-
x: 100
|
17
|
-
y: 675
|
18
|
-
width: 625
|
19
|
-
height: 275
|
20
|
-
valign: middle
|
21
|
-
align: center
|
22
|
-
font_size: 6
|
23
|
-
desc: # alias
|
24
|
-
extends: description
|
25
|
-
|
26
|
-
type:
|
27
|
-
x: 90
|
28
|
-
y: 955
|
29
|
-
width: 645
|
30
|
-
height: 50
|
31
|
-
align: center
|
32
|
-
|
33
|
-
lower_right:
|
34
|
-
x: 675
|
35
|
-
y: 975
|
36
|
-
width: 75
|
37
|
-
height: 75
|
38
|
-
font_size: 6
|
39
|
-
valign: bottom
|
40
|
-
align: right
|
41
|
-
lr: #alias
|
42
|
-
extends: lower_right
|
43
|
-
|
44
|
-
lower_left:
|
45
|
-
x: 75
|
46
|
-
y: 975
|
47
|
-
width: 75
|
48
|
-
height: 75
|
49
|
-
font_size: 6
|
50
|
-
valign: bottom
|
51
|
-
align: left
|
52
|
-
ll: # alias
|
53
|
-
extends: lower_left
|
54
|
-
|
55
|
-
copyright:
|
56
|
-
x: 75
|
57
|
-
y: 1025
|
58
|
-
width: 675
|
59
|
-
height: 25
|
60
|
-
font_size: 5
|
61
|
-
align: center
|
62
|
-
valign: bottom
|
63
|
-
#aliases for copyright
|
64
|
-
copy:
|
65
|
-
extends: copyright
|
66
|
-
credit:
|
67
|
-
extends: copyright
|
68
|
-
credits:
|
69
|
-
extends: copyright
|
70
|
-
|
71
|
-
# The "cut line", without rounded corners
|
72
|
-
cut:
|
73
|
-
x: 37.5
|
74
|
-
y: 37.5
|
75
|
-
width: 750
|
76
|
-
height: 1050
|
77
|
-
|
78
|
-
# The "safe zone" as defined by TheGameCrafter poker cards
|
79
|
-
safe:
|
80
|
-
x: 75
|
81
|
-
y: 75
|
82
|
-
width: 675
|
83
|
-
height: 975
|
84
|
-
radius: 16
|
85
|
-
dash: 3 3
|
1
|
+
#This layout inspired by popular economy games
|
2
|
+
title:
|
3
|
+
x: 90
|
4
|
+
y: 90
|
5
|
+
width: 635
|
6
|
+
height: 50
|
7
|
+
align: center
|
8
|
+
|
9
|
+
art:
|
10
|
+
x: 75
|
11
|
+
y: 150
|
12
|
+
width: 675
|
13
|
+
height: 520
|
14
|
+
|
15
|
+
description:
|
16
|
+
x: 100
|
17
|
+
y: 675
|
18
|
+
width: 625
|
19
|
+
height: 275
|
20
|
+
valign: middle
|
21
|
+
align: center
|
22
|
+
font_size: 6
|
23
|
+
desc: # alias
|
24
|
+
extends: description
|
25
|
+
|
26
|
+
type:
|
27
|
+
x: 90
|
28
|
+
y: 955
|
29
|
+
width: 645
|
30
|
+
height: 50
|
31
|
+
align: center
|
32
|
+
|
33
|
+
lower_right:
|
34
|
+
x: 675
|
35
|
+
y: 975
|
36
|
+
width: 75
|
37
|
+
height: 75
|
38
|
+
font_size: 6
|
39
|
+
valign: bottom
|
40
|
+
align: right
|
41
|
+
lr: #alias
|
42
|
+
extends: lower_right
|
43
|
+
|
44
|
+
lower_left:
|
45
|
+
x: 75
|
46
|
+
y: 975
|
47
|
+
width: 75
|
48
|
+
height: 75
|
49
|
+
font_size: 6
|
50
|
+
valign: bottom
|
51
|
+
align: left
|
52
|
+
ll: # alias
|
53
|
+
extends: lower_left
|
54
|
+
|
55
|
+
copyright:
|
56
|
+
x: 75
|
57
|
+
y: 1025
|
58
|
+
width: 675
|
59
|
+
height: 25
|
60
|
+
font_size: 5
|
61
|
+
align: center
|
62
|
+
valign: bottom
|
63
|
+
#aliases for copyright
|
64
|
+
copy:
|
65
|
+
extends: copyright
|
66
|
+
credit:
|
67
|
+
extends: copyright
|
68
|
+
credits:
|
69
|
+
extends: copyright
|
70
|
+
|
71
|
+
# The "cut line", without rounded corners
|
72
|
+
cut:
|
73
|
+
x: 37.5
|
74
|
+
y: 37.5
|
75
|
+
width: 750
|
76
|
+
height: 1050
|
77
|
+
|
78
|
+
# The "safe zone" as defined by TheGameCrafter poker cards
|
79
|
+
safe:
|
80
|
+
x: 75
|
81
|
+
y: 75
|
82
|
+
width: 675
|
83
|
+
height: 975
|
84
|
+
radius: 16
|
85
|
+
dash: 3 3
|