squib 0.9.0 → 0.10.0
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/.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
data/lib/squib/api/text.rb
CHANGED
|
@@ -1,61 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
require_relative 'text_embed'
|
|
2
|
+
require_relative '../args/box'
|
|
3
|
+
require_relative '../args/card_range'
|
|
4
|
+
require_relative '../args/draw'
|
|
5
|
+
require_relative '../args/paragraph'
|
|
6
6
|
|
|
7
7
|
module Squib
|
|
8
8
|
class Deck
|
|
9
9
|
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# Unix-like newlines are interpreted even on Windows.
|
|
13
|
-
# See the {file:samples/text-options.rb samples/text.rb} for a lengthy example.
|
|
14
|
-
#
|
|
15
|
-
# @example
|
|
16
|
-
# text str: 'hello'
|
|
17
|
-
# text str: 'hello', x: 50, y:50, align: center
|
|
18
|
-
#
|
|
19
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
|
20
|
-
#
|
|
21
|
-
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
|
22
|
-
# @option opts str [String, Array] ('') the string to be rendered. Must support `#to_s`. If the card responds to `#each`, it's mapped out one at a time across the cards.
|
|
23
|
-
# @option opts font [String] (Arial 36 or whatever was set with `set`) the Font description string, including family, styles, and size.
|
|
24
|
-
# (e.g. `'Arial bold italic 12'`)
|
|
25
|
-
# For the official documentation, see the [Pango docs](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3AFontDescription#style).
|
|
26
|
-
# This [description](http://www.pygtk.org/pygtk2reference/class-pangofontdescription.html) is also quite good.
|
|
27
|
-
# See the {file:samples/text-options.rb samples/text.rb} as well.
|
|
28
|
-
# @option opts font_size [Integer] (nil) an override of font string description, for scaling the font according to the size of the string
|
|
29
|
-
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
|
30
|
-
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
|
31
|
-
# @option opts color [String] (:black) the color the font will render to. Gradients supported. See {file:README.md#Specifying_Colors___Gradients Specifying Colors}
|
|
32
|
-
# @option opts markup: [Boolean] (false) Enable markup parsing of `str` using the HTML-like Pango Markup syntax, defined [here](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup) and [here](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html). Also does other replacements, such as smart quotes, curly apostraphes, en- and em-dashes, and explict ellipses (not to be confused with ellipsize option). See README for full explanation.
|
|
33
|
-
# @option opts width [Integer, :auto] (:auto) the width of the box the string will be placed in. Stretches to the content by default.. Supports Unit Conversion, see {file:README.md#Units Units}.
|
|
34
|
-
# @option opts height [Integer, :auto] the height of the box the string will be placed in. Stretches to the content by default. Supports Unit Conversion, see {file:README.md#Units Units}.
|
|
35
|
-
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
|
36
|
-
# @option opts wrap [:none, :word, :char, :word_char, true, false] (:word_char) When height is set, determines the behavior of how the string wraps. The `:word_char` option will break at words, but then fall back to characters when the word cannot fit. #
|
|
37
|
-
# Options are `:none, :word, :char, :word_char`. Also: `true` is the same as `:word_char`, `false` is the same as `:none`. Default `:word_char`
|
|
38
|
-
# @option opts spacing [Integer] (0) Adjust the spacing when the text is multiple lines. No effect when the text does not wrap.
|
|
39
|
-
# @option opts align [:left, right, :center] (:left) The alignment of the text
|
|
40
|
-
# @option opts justify [Boolean] (false) toggles whether or not the text is justified or not.
|
|
41
|
-
# @option opts valign [:top, :middle, :bottom] (:top) When width and height are set, align text vertically according to the ink extents of the text.
|
|
42
|
-
# @option opts ellipsize [:none, :start, :middle, :end, true, false] (:end) When width and height are set, determines the behavior of overflowing text. Also: `true` maps to `:end` and `false` maps to `:none`. Default `:end`
|
|
43
|
-
# @option opts angle [FixNum] (0) Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
|
|
44
|
-
# @option opts stroke_width [Decimal] (0.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
|
45
|
-
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
|
46
|
-
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
|
47
|
-
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
|
48
|
-
# @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
|
|
49
|
-
# @return [Array] Returns an Array of hashes keyed by :width and :height that mark the ink extents of the text rendered.
|
|
50
|
-
# @api public
|
|
10
|
+
# DSL method. See http://squib.readthedocs.org
|
|
51
11
|
def text(opts = {})
|
|
52
12
|
range = Args::CardRange.new(opts[:range], deck_size: size)
|
|
53
13
|
para = Args::Paragraph.new(font).load!(opts, expand_by: size, layout: layout)
|
|
54
|
-
box = Args::Box.new(self, {width: :auto, height: :auto}).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
|
14
|
+
box = Args::Box.new(self, { width: :auto, height: :auto }).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
|
55
15
|
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
|
56
|
-
draw = Args::Draw.new(custom_colors, {stroke_width: 0.0}).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
|
16
|
+
draw = Args::Draw.new(custom_colors, { stroke_width: 0.0 }).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
|
57
17
|
embed = TextEmbed.new(size, custom_colors, layout, dpi, img_dir)
|
|
58
|
-
yield(embed) if block_given? #store the opts for later use
|
|
18
|
+
yield(embed) if block_given? # store the opts for later use
|
|
59
19
|
extents = Array.new(@cards.size)
|
|
60
20
|
range.each { |i| extents[i] = @cards[i].text(embed, para[i], box[i], trans[i], draw[i]) }
|
|
61
21
|
return extents
|
data/lib/squib/api/text_embed.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
require_relative '../args/box'
|
|
2
|
+
require_relative '../args/card_range'
|
|
3
|
+
require_relative '../args/embed_adjust'
|
|
4
|
+
require_relative '../args/embed_key'
|
|
5
|
+
require_relative '../args/input_file'
|
|
6
|
+
require_relative '../args/paint'
|
|
7
|
+
require_relative '../args/transform'
|
|
8
8
|
|
|
9
9
|
module Squib
|
|
10
10
|
class TextEmbed
|
|
@@ -42,12 +42,12 @@ module Squib
|
|
|
42
42
|
key = Args::EmbedKey.new.validate_key(opts[:key])
|
|
43
43
|
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
|
44
44
|
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
|
45
|
-
box = Args::Box.new(self, {width: :native, height: :native}).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
46
|
-
adjust= Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
45
|
+
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
46
|
+
adjust = Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
47
47
|
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
48
48
|
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
49
49
|
svg_args = Args::SvgSpecial.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
50
|
-
rule
|
|
50
|
+
rule = { type: :png, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust }
|
|
51
51
|
rule[:draw] = Proc.new do |card, x, y|
|
|
52
52
|
i = card.index
|
|
53
53
|
b = box[i]
|
|
@@ -76,8 +76,8 @@ module Squib
|
|
|
76
76
|
key = Args::EmbedKey.new.validate_key(opts[:key])
|
|
77
77
|
range = Args::CardRange.new(opts[:range], deck_size: @deck_size)
|
|
78
78
|
paint = Args::Paint.new(@custom_colors).load!(opts, expand_by: @deck_size, layout: @layout)
|
|
79
|
-
box = Args::Box.new(self, {width: :native, height: :native}).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
80
|
-
adjust= Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
79
|
+
box = Args::Box.new(self, { width: :native, height: :native }).load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
80
|
+
adjust = Args::EmbedAdjust.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
81
81
|
trans = Args::Transform.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
82
82
|
ifile = Args::InputFile.new.load!(opts, expand_by: @deck_size, layout: @layout, dpi: @dpi)
|
|
83
83
|
rule = { type: :png, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust }
|
data/lib/squib/api/units.rb
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative '../constants'
|
|
2
2
|
|
|
3
3
|
module Squib
|
|
4
4
|
class Deck
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# @example
|
|
9
|
-
# inches(2.5) # 750 (for default Deck::dpi of 300)
|
|
10
|
-
#
|
|
11
|
-
# @param n [Decimal], the number of inches
|
|
12
|
-
# @return [Decimal] the number of pixels, according to the deck's DPI
|
|
13
|
-
# @api public
|
|
6
|
+
# DSL method. See http://squib.readthedocs.org
|
|
14
7
|
def inches(n)
|
|
15
8
|
@dpi * n.to_f
|
|
16
9
|
end
|
|
17
10
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# @example
|
|
21
|
-
# cm(1) # 750 (for default Deck::dpi of 300)
|
|
22
|
-
#
|
|
23
|
-
# @param n [Decimal], the number of centimeters
|
|
24
|
-
# @return [Decimal] the number of pixels, according to the deck's DPI
|
|
25
|
-
# @api public
|
|
11
|
+
# DSL method. See http://squib.readthedocs.org
|
|
26
12
|
def cm(n)
|
|
27
13
|
@dpi * Squib::INCHES_IN_CM * n.to_f
|
|
28
14
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative '../constants'
|
|
2
|
+
require_relative '../conf'
|
|
3
3
|
require 'ostruct'
|
|
4
4
|
|
|
5
5
|
module Squib
|
|
@@ -84,10 +84,10 @@ module Squib
|
|
|
84
84
|
attribute = "@#{param}"
|
|
85
85
|
val = instance_variable_get(attribute)
|
|
86
86
|
if val.respond_to? :each
|
|
87
|
-
new_val =
|
|
87
|
+
new_val = val.map.with_index{ |v, i| send(method, v, i) }
|
|
88
88
|
instance_variable_set(attribute, new_val)
|
|
89
89
|
else
|
|
90
|
-
instance_variable_set(attribute,send(method, val))
|
|
90
|
+
instance_variable_set(attribute, send(method, val))
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -122,9 +122,9 @@ module Squib
|
|
|
122
122
|
|
|
123
123
|
def convert_unit(arg, dpi)
|
|
124
124
|
case arg.to_s.rstrip
|
|
125
|
-
when /in$/ #ends with "in"
|
|
125
|
+
when /in$/ # ends with "in"
|
|
126
126
|
arg.rstrip[0..-2].to_f * dpi
|
|
127
|
-
when /cm$/ #ends with "cm"
|
|
127
|
+
when /cm$/ # ends with "cm"
|
|
128
128
|
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
|
|
129
129
|
else
|
|
130
130
|
arg
|
data/lib/squib/args/box.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Squib
|
|
|
23
23
|
input = 0..(deck_size - 1) if input == :all
|
|
24
24
|
input = (input.to_i)..(input.to_i) if input.respond_to? :to_i
|
|
25
25
|
raise ArgumentError.new("#{input} must be Enumerable (i.e. respond_to :each).") unless input.respond_to? :each
|
|
26
|
-
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size-1}") if (!input.max.nil?) && (input.max > (deck_size - 1))
|
|
26
|
+
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size - 1}") if (!input.max.nil?) && (input.max > (deck_size - 1))
|
|
27
27
|
input
|
|
28
28
|
end
|
|
29
29
|
|
data/lib/squib/args/coords.rb
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'csv'
|
|
2
|
+
|
|
3
|
+
module Squib
|
|
4
|
+
# @api private
|
|
5
|
+
module Args
|
|
6
|
+
class CSV_Opts
|
|
7
|
+
|
|
8
|
+
def initialize(opts)
|
|
9
|
+
opts = opts.keep_if { |k, _v| CSV::DEFAULT_OPTIONS.key? k}
|
|
10
|
+
@hash = CSV::DEFAULT_OPTIONS.merge(opts).merge(required)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_hash
|
|
14
|
+
@hash
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def required
|
|
20
|
+
{ headers: true, converters: :numeric }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/squib/args/draw.rb
CHANGED
data/lib/squib/args/embed_key.rb
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
require 'cairo'
|
|
2
|
-
|
|
3
|
-
module Squib
|
|
4
|
-
# @api private
|
|
5
|
-
module Args
|
|
6
|
-
|
|
7
|
-
class HandSpecial
|
|
8
|
-
include ArgLoader
|
|
9
|
-
|
|
10
|
-
def initialize(card_height)
|
|
11
|
-
@card_height = card_height
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.parameters
|
|
15
|
-
{
|
|
16
|
-
angle_range: (Math::PI / -4.0)..(Math::PI / 4),
|
|
17
|
-
radius: :auto
|
|
18
|
-
}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self.expanding_parameters
|
|
22
|
-
[] # none of them
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.params_with_units
|
|
26
|
-
[ :radius ]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def validate_radius(arg)
|
|
30
|
-
return 0.3 * @card_height if arg.to_s.downcase.strip == 'auto'
|
|
31
|
-
arg
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
end
|
|
1
|
+
require 'cairo'
|
|
2
|
+
|
|
3
|
+
module Squib
|
|
4
|
+
# @api private
|
|
5
|
+
module Args
|
|
6
|
+
|
|
7
|
+
class HandSpecial
|
|
8
|
+
include ArgLoader
|
|
9
|
+
|
|
10
|
+
def initialize(card_height)
|
|
11
|
+
@card_height = card_height
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.parameters
|
|
15
|
+
{
|
|
16
|
+
angle_range: (Math::PI / -4.0)..(Math::PI / 4),
|
|
17
|
+
radius: :auto
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.expanding_parameters
|
|
22
|
+
[] # none of them
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.params_with_units
|
|
26
|
+
[ :radius ]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def validate_radius(arg)
|
|
30
|
+
return 0.3 * @card_height if arg.to_s.downcase.strip == 'auto'
|
|
31
|
+
arg
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/squib/args/import.rb
CHANGED
data/lib/squib/args/paint.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'cairo'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
require_relative 'arg_loader'
|
|
3
|
+
require_relative 'color_validator'
|
|
4
4
|
|
|
5
5
|
module Squib
|
|
6
6
|
# @api private
|
|
@@ -41,4 +41,4 @@ module Squib
|
|
|
41
41
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
end
|
|
44
|
+
end
|
data/lib/squib/args/paragraph.rb
CHANGED
data/lib/squib/args/scale_box.rb
CHANGED
data/lib/squib/args/sheet.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'cairo'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
require_relative 'arg_loader'
|
|
3
|
+
require_relative 'color_validator'
|
|
4
|
+
require_relative 'dir_validator'
|
|
5
5
|
|
|
6
6
|
module Squib
|
|
7
7
|
# @api private
|