squib 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +14 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +201 -175
  5. data/Gemfile +2 -4
  6. data/README.md +650 -645
  7. data/RELEASE TODO.md +18 -18
  8. data/Rakefile +106 -99
  9. data/appveyor.yml +29 -0
  10. data/lib/squib.rb +32 -32
  11. data/lib/squib/api/background.rb +20 -20
  12. data/lib/squib/api/data.rb +131 -131
  13. data/lib/squib/api/image.rb +108 -90
  14. data/lib/squib/api/save.rb +151 -149
  15. data/lib/squib/api/settings.rb +35 -35
  16. data/lib/squib/api/shapes.rb +255 -230
  17. data/lib/squib/api/text.rb +65 -65
  18. data/lib/squib/api/text_embed.rb +96 -96
  19. data/lib/squib/args/arg_loader.rb +138 -138
  20. data/lib/squib/args/box.rb +54 -54
  21. data/lib/squib/args/card_range.rb +32 -32
  22. data/lib/squib/args/color_validator.rb +11 -11
  23. data/lib/squib/args/coords.rb +32 -32
  24. data/lib/squib/args/dir_validator.rb +16 -16
  25. data/lib/squib/args/draw.rb +92 -92
  26. data/lib/squib/args/embed_adjust.rb +25 -25
  27. data/lib/squib/args/embed_key.rb +17 -17
  28. data/lib/squib/args/hand_special.rb +37 -37
  29. data/lib/squib/args/import.rb +39 -39
  30. data/lib/squib/args/input_file.rb +37 -37
  31. data/lib/squib/args/paint.rb +43 -43
  32. data/lib/squib/args/paragraph.rb +116 -115
  33. data/lib/squib/args/save_batch.rb +63 -60
  34. data/lib/squib/args/scale_box.rb +53 -53
  35. data/lib/squib/args/sheet.rb +72 -72
  36. data/lib/squib/args/showcase_special.rb +38 -38
  37. data/lib/squib/args/svg_special.rb +37 -37
  38. data/lib/squib/args/transform.rb +60 -24
  39. data/lib/squib/args/typographer.rb +117 -117
  40. data/lib/squib/card.rb +66 -67
  41. data/lib/squib/conf.rb +131 -117
  42. data/lib/squib/constants.rb +12 -178
  43. data/lib/squib/deck.rb +113 -113
  44. data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
  45. data/lib/squib/graphics/gradient_regex.rb +46 -46
  46. data/lib/squib/graphics/hand.rb +42 -42
  47. data/lib/squib/graphics/image.rb +103 -76
  48. data/lib/squib/graphics/save_doc.rb +103 -103
  49. data/lib/squib/graphics/save_images.rb +39 -33
  50. data/lib/squib/graphics/shapes.rb +135 -119
  51. data/lib/squib/graphics/showcase.rb +85 -85
  52. data/lib/squib/graphics/text.rb +176 -176
  53. data/lib/squib/layout_parser.rb +91 -91
  54. data/lib/squib/layouts/economy.yml +85 -85
  55. data/lib/squib/layouts/fantasy.yml +101 -101
  56. data/lib/squib/layouts/hand.yml +62 -62
  57. data/lib/squib/layouts/playing-card.yml +35 -35
  58. data/lib/squib/layouts/tuck_box.yml +45 -45
  59. data/lib/squib/project_template/IDEAS.md +22 -0
  60. data/lib/squib/project_template/PLAYTESTING.md +26 -0
  61. data/lib/squib/project_template/RULES.md +21 -0
  62. data/lib/squib/project_template/config.yml +49 -45
  63. data/lib/squib/sample_helpers.rb +34 -0
  64. data/lib/squib/version.rb +10 -10
  65. data/samples/autoscale_font/_autoscale_font.rb +29 -0
  66. data/samples/color_shortcuts.rb +6 -6
  67. data/samples/csv_import.rb +26 -26
  68. data/samples/custom-config.yml +5 -5
  69. data/samples/custom_config.rb +18 -18
  70. data/samples/draw_shapes.rb +48 -45
  71. data/samples/embed_text.rb +88 -88
  72. data/samples/excel.rb +55 -55
  73. data/samples/hand.rb +24 -24
  74. data/samples/images/_images.rb +104 -0
  75. data/samples/intro/01_hello.rb +9 -0
  76. data/samples/intro/02_options.rb +15 -0
  77. data/samples/intro/03_layout.rb +12 -0
  78. data/samples/intro/04_arrays.rb +16 -0
  79. data/samples/intro/05_excel.rb +15 -0
  80. data/samples/layouts.rb +62 -62
  81. data/samples/layouts_builtin.rb +51 -51
  82. data/samples/load_images.rb +99 -78
  83. data/samples/load_images_config.yml +1 -0
  84. data/samples/quantity_explosion.csv +2 -2
  85. data/samples/ranges.rb +64 -64
  86. data/samples/sample.csv +2 -2
  87. data/samples/saves.rb +9 -1
  88. data/samples/sprites.png +0 -0
  89. data/samples/text/_text.rb +46 -0
  90. data/samples/text_options.rb +102 -102
  91. data/spec/api/api_data_spec.rb +117 -117
  92. data/spec/api/api_settings_spec.rb +37 -37
  93. data/spec/args/box_spec.rb +127 -127
  94. data/spec/args/draw_spec.rb +101 -95
  95. data/spec/args/embed_key_spec.rb +13 -13
  96. data/spec/args/input_file_spec.rb +21 -21
  97. data/spec/args/paint_spec.rb +21 -21
  98. data/spec/args/paragraph_spec.rb +152 -152
  99. data/spec/args/range_spec.rb +40 -40
  100. data/spec/args/save_batch_spec.rb +51 -51
  101. data/spec/args/scale_box_spec.rb +71 -71
  102. data/spec/args/sheet_spec.rb +58 -58
  103. data/spec/args/showcase_special_spec.rb +15 -15
  104. data/spec/args/transform_spec.rb +25 -0
  105. data/spec/card_spec.rb +11 -0
  106. data/spec/conf_spec.rb +13 -3
  107. data/spec/data/conf/unrecognized.yml +4 -0
  108. data/spec/data/csv/qty.csv +2 -2
  109. data/spec/data/csv/qty_named.csv +2 -2
  110. data/spec/data/csv/with_spaces.csv +2 -2
  111. data/spec/data/samples/autoscale_font.rb.txt +84 -84
  112. data/spec/data/samples/basic.rb.txt +227 -209
  113. data/spec/data/samples/config_text_markup.rb.txt +72 -72
  114. data/spec/data/samples/csv_import.rb.txt +213 -213
  115. data/spec/data/samples/custom_config.rb.txt +57 -48
  116. data/spec/data/samples/draw_shapes.rb.txt +555 -3
  117. data/spec/data/samples/embed_text.rb.txt +283 -283
  118. data/spec/data/samples/excel.rb.txt +661 -661
  119. data/spec/data/samples/gradients.rb.txt +77 -79
  120. data/spec/data/samples/hand.rb.txt +538 -538
  121. data/spec/data/samples/hello_world.rb.txt +36 -36
  122. data/spec/data/samples/load_images.rb.txt +170 -0
  123. data/spec/data/samples/portrait-landscape.rb.txt +51 -49
  124. data/spec/data/samples/ranges.rb.txt +472 -460
  125. data/spec/data/samples/saves.rb.txt +810 -801
  126. data/spec/data/samples/showcase.rb.txt +5926 -5910
  127. data/spec/data/samples/text_options.rb.txt +1125 -1125
  128. data/spec/data/samples/tgc_proofs.rb.txt +95 -81
  129. data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
  130. data/spec/graphics/graphics_save_doc_spec.rb +67 -67
  131. data/spec/samples/diff-with-css.example.html +39 -0
  132. data/spec/samples/expected/load_images_00.png +0 -0
  133. data/spec/samples/expected/shape_00.png +0 -0
  134. data/spec/samples/run_samples_spec.rb +17 -0
  135. data/spec/samples/samples_regression_spec.rb +72 -82
  136. data/spec/spec_helper.rb +9 -1
  137. data/squib.gemspec +49 -48
  138. data/squib.sublime-project +42 -42
  139. metadata +94 -48
  140. data/spec/graphics/graphics_images_spec.rb +0 -94
@@ -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::SYSTEM_DEFAULTS[:default_font] : opts[:font]
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
@@ -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 a triangle using the given coordinates
95
- #
96
- # @example
97
- # triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50, :x3 => 0, :y3 => 50
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 x1 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
103
- # @option opts y1 [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
104
- # @option opts x2 [Integer] (50) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
105
- # @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
106
- # @option opts x3 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
107
- # @option opts y3 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
108
- # @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
109
- # @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}
110
- # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
111
- # @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
112
- # @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'`).
113
- # @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}
114
- # @return [nil] intended to be void
115
- # @api public
116
- def triangle(opts = {})
117
- range = Args::CardRange.new(opts[:range], deck_size: size)
118
- draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
119
- coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
120
- range.each { |i| @cards[i].triangle(coords[i], draw[i]) }
121
- end
122
-
123
- # Draw a line using the given coordinates
124
- #
125
- # @example
126
- # triangle :x1 => 0, :y1 => 0, :x2 => 50, :y2 => 50
127
- #
128
- # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
129
- # @option opts x1 [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
130
- # @option opts y1 [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
131
- # @option opts x2 [Integer] (50) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
132
- # @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
133
- # @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
134
- # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
135
- # @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
136
- # @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
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 line(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].line(coords[i], draw[i]) }
146
- end
147
-
148
- # Draw a curve using the given coordinates
149
- #
150
- # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
151
- # @option opts x1 [Integer] (0) the x-coordinate of the first endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
152
- # @option opts y1 [Integer] (0) the y-coordinate of the first endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
153
- # @option opts x2 [Integer] (50) the x-coordinate of the second endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
154
- # @option opts y2 [Integer] (50) the y-coordinate of the second endpoint. Supports Unit Conversion, see {file:README.md#Units Units}.
155
- # @option opts cx1 [Integer] (0) the x-coordinate of the first control point. Supports Unit Conversion, see {file:README.md#Units Units}.
156
- # @option opts cy1 [Integer] (0) the y-coordinate of the first control point. Supports Unit Conversion, see {file:README.md#Units Units}.
157
- # @option opts cx2 [Integer] (50) the x-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
158
- # @option opts cy2 [Integer] (50) the y-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
159
- # @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
160
- # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
161
- # @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
162
- # @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
163
- # @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
164
- # @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'`).
165
- # @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}
166
- # @return [nil] intended to be void
167
- # @api public
168
- def curve(opts = {})
169
- range = Args::CardRange.new(opts[:range], deck_size: size)
170
- draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
171
- coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
172
- range.each { |i| @cards[i].curve(coords[i], draw[i]) }
173
- end
174
-
175
- # Draw a star at the given x,y
176
- # @example
177
- # star x: 10, y: 10, n: 5, angle: Math::PI / 4, inner_radius: 50, outer_radius: 100,
178
- # fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
179
- #
180
- # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
181
- # @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
182
- # @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
183
- # @option opts n [Integer] (5) the number of points on the star
184
- # @option opts angle [Fixnum] (0) the angle at which to rotate
185
- # @option opts inner_radius [Fixnum] (0) the inner radius. Supports Unit conversion.
186
- # @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
187
- # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
188
- # @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
189
- # @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
190
- # @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'`).
191
- # @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}
192
- # @return [nil] intended to be void
193
- # @api public
194
- def star(opts = {})
195
- range = Args::CardRange.new(opts[:range], deck_size: size)
196
- draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
197
- coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
198
- trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
199
- range.each { |i| @cards[i].star(coords[i], trans[i], draw[i]) }
200
- end
201
-
202
- # Draw a regular polygon at the given x,y
203
- # @example
204
- # polygon x: 10, y: 10, n: 5, angle: Math::PI / 4, radius: 50,
205
- # fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
206
- #
207
- # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
208
- # @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
209
- # @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
210
- # @option opts n [Integer] (5) the number of points on the star
211
- # @option opts angle [Fixnum] (0) the angle at which to rotate
212
- # @option opts radius [Fixnum] (0) the radius from center to corner. Supports Unit conversion.
213
- # @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
214
- # @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
215
- # @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
216
- # @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
217
- # @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'`).
218
- # @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}
219
- # @return [nil] intended to be void
220
- # @api public
221
- def polygon(opts = {})
222
- range = Args::CardRange.new(opts[:range], deck_size: size)
223
- draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
224
- coords = Args::Coords.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
225
- trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
226
- range.each { |i| @cards[i].polygon(coords[i], trans[i], draw[i]) }
227
- end
228
-
229
- end
230
- end
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