squib 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +14 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +201 -175
- data/Gemfile +2 -4
- data/README.md +650 -645
- data/RELEASE TODO.md +18 -18
- data/Rakefile +106 -99
- data/appveyor.yml +29 -0
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +20 -20
- data/lib/squib/api/data.rb +131 -131
- data/lib/squib/api/image.rb +108 -90
- data/lib/squib/api/save.rb +151 -149
- data/lib/squib/api/settings.rb +35 -35
- data/lib/squib/api/shapes.rb +255 -230
- data/lib/squib/api/text.rb +65 -65
- data/lib/squib/api/text_embed.rb +96 -96
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +54 -54
- data/lib/squib/args/card_range.rb +32 -32
- data/lib/squib/args/color_validator.rb +11 -11
- data/lib/squib/args/coords.rb +32 -32
- data/lib/squib/args/dir_validator.rb +16 -16
- data/lib/squib/args/draw.rb +92 -92
- data/lib/squib/args/embed_adjust.rb +25 -25
- data/lib/squib/args/embed_key.rb +17 -17
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +39 -39
- data/lib/squib/args/input_file.rb +37 -37
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +116 -115
- data/lib/squib/args/save_batch.rb +63 -60
- data/lib/squib/args/scale_box.rb +53 -53
- data/lib/squib/args/sheet.rb +72 -72
- data/lib/squib/args/showcase_special.rb +38 -38
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +60 -24
- data/lib/squib/args/typographer.rb +117 -117
- data/lib/squib/card.rb +66 -67
- data/lib/squib/conf.rb +131 -117
- data/lib/squib/constants.rb +12 -178
- data/lib/squib/deck.rb +113 -113
- data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
- data/lib/squib/graphics/gradient_regex.rb +46 -46
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +103 -76
- data/lib/squib/graphics/save_doc.rb +103 -103
- data/lib/squib/graphics/save_images.rb +39 -33
- data/lib/squib/graphics/shapes.rb +135 -119
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +176 -176
- data/lib/squib/layout_parser.rb +91 -91
- 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/project_template/IDEAS.md +22 -0
- data/lib/squib/project_template/PLAYTESTING.md +26 -0
- data/lib/squib/project_template/RULES.md +21 -0
- data/lib/squib/project_template/config.yml +49 -45
- data/lib/squib/sample_helpers.rb +34 -0
- data/lib/squib/version.rb +10 -10
- data/samples/autoscale_font/_autoscale_font.rb +29 -0
- data/samples/color_shortcuts.rb +6 -6
- data/samples/csv_import.rb +26 -26
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/draw_shapes.rb +48 -45
- data/samples/embed_text.rb +88 -88
- data/samples/excel.rb +55 -55
- data/samples/hand.rb +24 -24
- data/samples/images/_images.rb +104 -0
- data/samples/intro/01_hello.rb +9 -0
- data/samples/intro/02_options.rb +15 -0
- data/samples/intro/03_layout.rb +12 -0
- data/samples/intro/04_arrays.rb +16 -0
- data/samples/intro/05_excel.rb +15 -0
- data/samples/layouts.rb +62 -62
- data/samples/layouts_builtin.rb +51 -51
- data/samples/load_images.rb +99 -78
- data/samples/load_images_config.yml +1 -0
- data/samples/quantity_explosion.csv +2 -2
- data/samples/ranges.rb +64 -64
- data/samples/sample.csv +2 -2
- data/samples/saves.rb +9 -1
- data/samples/sprites.png +0 -0
- data/samples/text/_text.rb +46 -0
- data/samples/text_options.rb +102 -102
- data/spec/api/api_data_spec.rb +117 -117
- data/spec/api/api_settings_spec.rb +37 -37
- data/spec/args/box_spec.rb +127 -127
- data/spec/args/draw_spec.rb +101 -95
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +21 -21
- data/spec/args/paint_spec.rb +21 -21
- data/spec/args/paragraph_spec.rb +152 -152
- data/spec/args/range_spec.rb +40 -40
- data/spec/args/save_batch_spec.rb +51 -51
- data/spec/args/scale_box_spec.rb +71 -71
- data/spec/args/sheet_spec.rb +58 -58
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +25 -0
- data/spec/card_spec.rb +11 -0
- data/spec/conf_spec.rb +13 -3
- data/spec/data/conf/unrecognized.yml +4 -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/samples/autoscale_font.rb.txt +84 -84
- data/spec/data/samples/basic.rb.txt +227 -209
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/csv_import.rb.txt +213 -213
- data/spec/data/samples/custom_config.rb.txt +57 -48
- data/spec/data/samples/draw_shapes.rb.txt +555 -3
- data/spec/data/samples/embed_text.rb.txt +283 -283
- data/spec/data/samples/excel.rb.txt +661 -661
- data/spec/data/samples/gradients.rb.txt +77 -79
- data/spec/data/samples/hand.rb.txt +538 -538
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/load_images.rb.txt +170 -0
- data/spec/data/samples/portrait-landscape.rb.txt +51 -49
- data/spec/data/samples/ranges.rb.txt +472 -460
- data/spec/data/samples/saves.rb.txt +810 -801
- data/spec/data/samples/showcase.rb.txt +5926 -5910
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/data/samples/tgc_proofs.rb.txt +95 -81
- data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
- data/spec/graphics/graphics_save_doc_spec.rb +67 -67
- data/spec/samples/diff-with-css.example.html +39 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/run_samples_spec.rb +17 -0
- data/spec/samples/samples_regression_spec.rb +72 -82
- data/spec/spec_helper.rb +9 -1
- data/squib.gemspec +49 -48
- data/squib.sublime-project +42 -42
- metadata +94 -48
- data/spec/graphics/graphics_images_spec.rb +0 -94
data/lib/squib/api/settings.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
module Squib
|
2
|
-
class Deck
|
3
|
-
|
4
|
-
# Toggle hints globally.
|
5
|
-
#
|
6
|
-
# Text hints are rectangles around where the text will be laid out. They are intended to be temporary.
|
7
|
-
# Setting a hint to nil or to :off will disable hints. @see samples/text.rb
|
8
|
-
# @example
|
9
|
-
# hint text: :cyan
|
10
|
-
# hint text: :cyan
|
11
|
-
#
|
12
|
-
# @param [String] text the color of the text hint. To turn off use :off. @see README.md
|
13
|
-
# @return [nil] Returns nothing
|
14
|
-
# @api public
|
15
|
-
def hint(text: :off)
|
16
|
-
conf.text_hint = text
|
17
|
-
end
|
18
|
-
|
19
|
-
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves when that command supports it.
|
20
|
-
# @example
|
21
|
-
# set font: 'Arial 26'
|
22
|
-
# text 'blah' # in Arial 26
|
23
|
-
# text 'blah24', font: 'Arial 24' # in Arial 24
|
24
|
-
# set font: :default # Back to Squib-wide default
|
25
|
-
#
|
26
|
-
# @option opts font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default.
|
27
|
-
# @return [nil] Returns nothing
|
28
|
-
# @api public
|
29
|
-
def set(opts = {})
|
30
|
-
raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :img_dir
|
31
|
-
@font = (opts[:font] == :default) ? Squib::
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
1
|
+
module Squib
|
2
|
+
class Deck
|
3
|
+
|
4
|
+
# Toggle hints globally.
|
5
|
+
#
|
6
|
+
# Text hints are rectangles around where the text will be laid out. They are intended to be temporary.
|
7
|
+
# Setting a hint to nil or to :off will disable hints. @see samples/text.rb
|
8
|
+
# @example
|
9
|
+
# hint text: :cyan
|
10
|
+
# hint text: :cyan
|
11
|
+
#
|
12
|
+
# @param [String] text the color of the text hint. To turn off use :off. @see README.md
|
13
|
+
# @return [nil] Returns nothing
|
14
|
+
# @api public
|
15
|
+
def hint(text: :off)
|
16
|
+
conf.text_hint = text
|
17
|
+
end
|
18
|
+
|
19
|
+
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves when that command supports it.
|
20
|
+
# @example
|
21
|
+
# set font: 'Arial 26'
|
22
|
+
# text 'blah' # in Arial 26
|
23
|
+
# text 'blah24', font: 'Arial 24' # in Arial 24
|
24
|
+
# set font: :default # Back to Squib-wide default
|
25
|
+
#
|
26
|
+
# @option opts font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default.
|
27
|
+
# @return [nil] Returns nothing
|
28
|
+
# @api public
|
29
|
+
def set(opts = {})
|
30
|
+
raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :img_dir
|
31
|
+
@font = (opts[:font] == :default) ? Squib::DEFAULT_FONT: opts[:font]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/squib/api/shapes.rb
CHANGED
@@ -1,230 +1,255 @@
|
|
1
|
-
require 'squib/args/box'
|
2
|
-
require 'squib/args/draw'
|
3
|
-
require 'squib/args/card_range'
|
4
|
-
require 'squib/args/transform'
|
5
|
-
require 'squib/args/coords'
|
6
|
-
|
7
|
-
module Squib
|
8
|
-
class Deck
|
9
|
-
|
10
|
-
# Draw a rounded rectangle
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# rect x: 0, y: 0, width: 825, height: 1125, radius: 25
|
14
|
-
#
|
15
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
16
|
-
#
|
17
|
-
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
18
|
-
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
19
|
-
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
20
|
-
# @option opts width [Integer] the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
21
|
-
# @option opts height [Integer] the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
22
|
-
# @option opts x_radius [Integer] (0) the radius of the rounded corner horiztonally. Zero is a non-rounded corner. Supports Unit Conversion, see {file:README.md#Units Units}.
|
23
|
-
# @option opts y_radius [Integer] (0) the radius of the rounded corner vertically. Zero is a non-rounded corner. Supports Unit Conversion, see {file:README.md#Units Units}.
|
24
|
-
# @option opts radius [Integer] (nil) when set, overrides both x_radius and y_radius. Supports Unit Conversion, see {file:README.md#Units Units}.
|
25
|
-
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
26
|
-
# @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}
|
27
|
-
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
28
|
-
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
29
|
-
# @option opts join [String] ('miter') how corners will be drawn on stroke. Options are 'miter', 'bevel', or 'round'. Note that this is separate from the x_radius and y_radius of the rounded rectangle. Becomes more obvious with wider strokes.
|
30
|
-
# @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'`).
|
31
|
-
# @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}
|
32
|
-
# @return [nil] intended to be void
|
33
|
-
# @api public
|
34
|
-
def rect(opts = {})
|
35
|
-
range = Args::CardRange.new(opts[:range], deck_size: size)
|
36
|
-
box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
37
|
-
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
38
|
-
range.each { |i| @cards[i].rect(box[i], draw[i]) }
|
39
|
-
end
|
40
|
-
|
41
|
-
# Draw a circle centered at the given coordinates
|
42
|
-
#
|
43
|
-
# @example
|
44
|
-
# circle x: 0, y: 0, radius: 100
|
45
|
-
#
|
46
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
47
|
-
#
|
48
|
-
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
49
|
-
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
50
|
-
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
51
|
-
# @option opts radius [Integer] (100) radius of the circle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
52
|
-
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
53
|
-
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
54
|
-
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
55
|
-
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
56
|
-
# @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'`).
|
57
|
-
# @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}
|
58
|
-
# @return [nil] intended to be void
|
59
|
-
# @api public
|
60
|
-
def circle(opts = {})
|
61
|
-
range = Args::CardRange.new(opts[:range], deck_size: size)
|
62
|
-
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
63
|
-
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
64
|
-
range.each { |i| @cards[i].circle(coords[i], draw[i]) }
|
65
|
-
end
|
66
|
-
|
67
|
-
# Draw an ellipse
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
# ellipse x: 0, y: 0, width: 825, height: 1125
|
71
|
-
#
|
72
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
73
|
-
#
|
74
|
-
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
75
|
-
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
76
|
-
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
77
|
-
# @option opts width [Integer] the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
78
|
-
# @option opts height [Integer] the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
79
|
-
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
80
|
-
# @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}
|
81
|
-
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
82
|
-
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
83
|
-
# @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'`).
|
84
|
-
# @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}
|
85
|
-
# @return [nil] intended to be void
|
86
|
-
# @api public
|
87
|
-
def ellipse(opts = {})
|
88
|
-
range = Args::CardRange.new(opts[:range], deck_size: size)
|
89
|
-
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
90
|
-
box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
91
|
-
range.each { |i| @cards[i].ellipse(box[i], draw[i]) }
|
92
|
-
end
|
93
|
-
|
94
|
-
# Draw
|
95
|
-
#
|
96
|
-
# @example
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
100
|
-
#
|
101
|
-
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
102
|
-
# @option opts
|
103
|
-
# @option opts
|
104
|
-
# @option opts
|
105
|
-
# @option opts
|
106
|
-
# @option opts
|
107
|
-
# @option opts
|
108
|
-
# @option opts
|
109
|
-
# @option opts
|
110
|
-
# @
|
111
|
-
# @
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
# @option opts
|
129
|
-
# @option opts
|
130
|
-
# @option opts
|
131
|
-
# @option opts
|
132
|
-
# @option opts
|
133
|
-
# @option opts
|
134
|
-
# @option opts
|
135
|
-
# @option opts
|
136
|
-
# @option opts
|
137
|
-
# @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'`).
|
138
|
-
# @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}
|
139
|
-
# @return [nil] intended to be void
|
140
|
-
# @api public
|
141
|
-
def
|
142
|
-
range
|
143
|
-
draw
|
144
|
-
coords
|
145
|
-
range.each { |i| @cards[i].
|
146
|
-
end
|
147
|
-
|
148
|
-
# Draw a
|
149
|
-
#
|
150
|
-
# @
|
151
|
-
#
|
152
|
-
#
|
153
|
-
# @option opts
|
154
|
-
# @option opts
|
155
|
-
# @option opts
|
156
|
-
# @option opts
|
157
|
-
# @option opts
|
158
|
-
# @option opts
|
159
|
-
# @option opts
|
160
|
-
# @option opts
|
161
|
-
# @option opts
|
162
|
-
# @option opts
|
163
|
-
# @option opts
|
164
|
-
# @
|
165
|
-
# @
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
#
|
176
|
-
# @
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
# @option opts
|
181
|
-
# @option opts
|
182
|
-
# @option opts
|
183
|
-
# @option opts
|
184
|
-
# @option opts
|
185
|
-
# @option opts
|
186
|
-
# @option opts
|
187
|
-
# @option opts
|
188
|
-
# @option opts
|
189
|
-
# @option opts
|
190
|
-
# @option opts
|
191
|
-
# @
|
192
|
-
# @
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
# @option opts
|
208
|
-
# @option opts
|
209
|
-
# @option opts
|
210
|
-
# @option opts
|
211
|
-
# @option opts
|
212
|
-
# @option opts
|
213
|
-
# @option opts
|
214
|
-
# @option opts
|
215
|
-
# @option opts
|
216
|
-
# @option opts
|
217
|
-
# @
|
218
|
-
# @
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
1
|
+
require 'squib/args/box'
|
2
|
+
require 'squib/args/draw'
|
3
|
+
require 'squib/args/card_range'
|
4
|
+
require 'squib/args/transform'
|
5
|
+
require 'squib/args/coords'
|
6
|
+
|
7
|
+
module Squib
|
8
|
+
class Deck
|
9
|
+
|
10
|
+
# Draw a rounded rectangle
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# rect x: 0, y: 0, width: 825, height: 1125, radius: 25
|
14
|
+
#
|
15
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
16
|
+
#
|
17
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
18
|
+
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
19
|
+
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
20
|
+
# @option opts width [Integer] the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
21
|
+
# @option opts height [Integer] the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
22
|
+
# @option opts x_radius [Integer] (0) the radius of the rounded corner horiztonally. Zero is a non-rounded corner. Supports Unit Conversion, see {file:README.md#Units Units}.
|
23
|
+
# @option opts y_radius [Integer] (0) the radius of the rounded corner vertically. Zero is a non-rounded corner. Supports Unit Conversion, see {file:README.md#Units Units}.
|
24
|
+
# @option opts radius [Integer] (nil) when set, overrides both x_radius and y_radius. Supports Unit Conversion, see {file:README.md#Units Units}.
|
25
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
26
|
+
# @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}
|
27
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
28
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
29
|
+
# @option opts join [String] ('miter') how corners will be drawn on stroke. Options are 'miter', 'bevel', or 'round'. Note that this is separate from the x_radius and y_radius of the rounded rectangle. Becomes more obvious with wider strokes.
|
30
|
+
# @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'`).
|
31
|
+
# @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}
|
32
|
+
# @return [nil] intended to be void
|
33
|
+
# @api public
|
34
|
+
def rect(opts = {})
|
35
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
36
|
+
box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
37
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
38
|
+
range.each { |i| @cards[i].rect(box[i], draw[i]) }
|
39
|
+
end
|
40
|
+
|
41
|
+
# Draw a circle centered at the given coordinates
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# circle x: 0, y: 0, radius: 100
|
45
|
+
#
|
46
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
47
|
+
#
|
48
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
49
|
+
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
50
|
+
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
51
|
+
# @option opts radius [Integer] (100) radius of the circle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
52
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
53
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
54
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
55
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
56
|
+
# @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'`).
|
57
|
+
# @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}
|
58
|
+
# @return [nil] intended to be void
|
59
|
+
# @api public
|
60
|
+
def circle(opts = {})
|
61
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
62
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
63
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
64
|
+
range.each { |i| @cards[i].circle(coords[i], draw[i]) }
|
65
|
+
end
|
66
|
+
|
67
|
+
# Draw an ellipse
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# ellipse x: 0, y: 0, width: 825, height: 1125
|
71
|
+
#
|
72
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
73
|
+
#
|
74
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
75
|
+
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
76
|
+
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
77
|
+
# @option opts width [Integer] (0.25in) the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
78
|
+
# @option opts height [Integer] (0.25in) the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
79
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
80
|
+
# @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}
|
81
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
82
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
83
|
+
# @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'`).
|
84
|
+
# @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}
|
85
|
+
# @return [nil] intended to be void
|
86
|
+
# @api public
|
87
|
+
def ellipse(opts = {})
|
88
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
89
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
90
|
+
box = Args::Box.new(self, {width: '0.25in', height: '0.25in'}).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
91
|
+
range.each { |i| @cards[i].ellipse(box[i], draw[i]) }
|
92
|
+
end
|
93
|
+
|
94
|
+
# Draw an unlimited grid
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# grid x: 0, y: 0, width: 15, height: 15
|
98
|
+
#
|
99
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
100
|
+
#
|
101
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
102
|
+
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
103
|
+
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
104
|
+
# @option opts width [Integer] the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
105
|
+
# @option opts height [Integer] the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
106
|
+
# @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}
|
107
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
108
|
+
# @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'`).
|
109
|
+
# @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}
|
110
|
+
# @return [nil] intended to be void
|
111
|
+
# @api public
|
112
|
+
def grid(opts = {})
|
113
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
114
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
115
|
+
box = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
116
|
+
range.each { |i| @cards[i].grid(box[i], draw[i]) }
|
117
|
+
end
|
118
|
+
|
119
|
+
# Draw a triangle using the given coordinates
|
120
|
+
#
|
121
|
+
# @example
|
122
|
+
# triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50, :x3 => 0, :y3 => 50
|
123
|
+
#
|
124
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
125
|
+
#
|
126
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
127
|
+
# @option opts x1 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
128
|
+
# @option opts y1 [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
129
|
+
# @option opts x2 [Integer] (50) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
130
|
+
# @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
131
|
+
# @option opts x3 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
132
|
+
# @option opts y3 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
133
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
134
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
135
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
136
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
137
|
+
# @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'`).
|
138
|
+
# @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}
|
139
|
+
# @return [nil] intended to be void
|
140
|
+
# @api public
|
141
|
+
def triangle(opts = {})
|
142
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
143
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
144
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
145
|
+
range.each { |i| @cards[i].triangle(coords[i], draw[i]) }
|
146
|
+
end
|
147
|
+
|
148
|
+
# Draw a line using the given coordinates
|
149
|
+
#
|
150
|
+
# @example
|
151
|
+
# triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50
|
152
|
+
#
|
153
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
154
|
+
# @option opts x1 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
155
|
+
# @option opts y1 [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
156
|
+
# @option opts x2 [Integer] (50) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
157
|
+
# @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
158
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
159
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
160
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
161
|
+
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
162
|
+
# @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'`).
|
163
|
+
# @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}
|
164
|
+
# @return [nil] intended to be void
|
165
|
+
# @api public
|
166
|
+
def line(opts = {})
|
167
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
168
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
169
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
170
|
+
range.each { |i| @cards[i].line(coords[i], draw[i]) }
|
171
|
+
end
|
172
|
+
|
173
|
+
# Draw a curve using the given coordinates
|
174
|
+
#
|
175
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
176
|
+
# @option opts x1 [Integer] (0) the x-coordinate of the first endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
|
177
|
+
# @option opts y1 [Integer] (0) the y-coordinate of the first endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
|
178
|
+
# @option opts x2 [Integer] (50) the x-coordinate of the second endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
|
179
|
+
# @option opts y2 [Integer] (50) the y-coordinate of the second endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
|
180
|
+
# @option opts cx1 [Integer] (0) the x-coordinate of the first control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
181
|
+
# @option opts cy1 [Integer] (0) the y-coordinate of the first control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
182
|
+
# @option opts cx2 [Integer] (50) the x-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
183
|
+
# @option opts cy2 [Integer] (50) the y-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
184
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
185
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
186
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
187
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
188
|
+
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
189
|
+
# @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'`).
|
190
|
+
# @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}
|
191
|
+
# @return [nil] intended to be void
|
192
|
+
# @api public
|
193
|
+
def curve(opts = {})
|
194
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
195
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
196
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
197
|
+
range.each { |i| @cards[i].curve(coords[i], draw[i]) }
|
198
|
+
end
|
199
|
+
|
200
|
+
# Draw a star at the given x,y
|
201
|
+
# @example
|
202
|
+
# star x: 10, y: 10, n: 5, angle: Math::PI / 4, inner_radius: 50, outer_radius: 100,
|
203
|
+
# fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
|
204
|
+
#
|
205
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
206
|
+
# @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
207
|
+
# @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
208
|
+
# @option opts n [Integer] (5) the number of points on the star
|
209
|
+
# @option opts angle [Fixnum] (0) the angle at which to rotate
|
210
|
+
# @option opts inner_radius [Fixnum] (0) the inner radius. Supports Unit conversion.
|
211
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
212
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
213
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
214
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
215
|
+
# @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'`).
|
216
|
+
# @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}
|
217
|
+
# @return [nil] intended to be void
|
218
|
+
# @api public
|
219
|
+
def star(opts = {})
|
220
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
221
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
222
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
223
|
+
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
224
|
+
range.each { |i| @cards[i].star(coords[i], trans[i], draw[i]) }
|
225
|
+
end
|
226
|
+
|
227
|
+
# Draw a regular polygon at the given x,y
|
228
|
+
# @example
|
229
|
+
# polygon x: 10, y: 10, n: 5, angle: Math::PI / 4, radius: 50,
|
230
|
+
# fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
|
231
|
+
#
|
232
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
233
|
+
# @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
234
|
+
# @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
235
|
+
# @option opts n [Integer] (5) the number of points on the star
|
236
|
+
# @option opts angle [Fixnum] (0) the angle at which to rotate
|
237
|
+
# @option opts radius [Fixnum] (0) the radius from center to corner. Supports Unit conversion.
|
238
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
239
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
240
|
+
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
241
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
242
|
+
# @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'`).
|
243
|
+
# @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}
|
244
|
+
# @return [nil] intended to be void
|
245
|
+
# @api public
|
246
|
+
def polygon(opts = {})
|
247
|
+
range = Args::CardRange.new(opts[:range], deck_size: size)
|
248
|
+
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
249
|
+
coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
250
|
+
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
251
|
+
range.each { |i| @cards[i].polygon(coords[i], trans[i], draw[i]) }
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
end
|