Module: Shoes::DSL::Art
- Included in:
- Shoes::DSL
- Defined in:
- shoes-core/lib/shoes/dsl/art.rb
Overview
DSL methods for drawing in Shoes applications.
Instance Method Summary collapse
-
#arc(left = 0, top = 0, width = 0, height = 0, angle1 = 0, angle2 = 0, opts) ⇒ Shoes::Arc
Creates an arc.
-
#arrow(left = 0, top = 0, width = 0, opts) ⇒ Shoes::Arrow
Creates an arrow.
-
#line(x1 = 0, y1 = 0, x2 = 0, y2 = 0, opts) ⇒ Shoes::Line
Draws a line from point A (x1,y1) to point B (x2,y2).
- #mask(*_) ⇒ Object deprecated Deprecated.
-
#oval(left = 0, top = 0, width = 0, height = width, opts) ⇒ Shoes::Oval
Creates an oval.
-
#rect(left = 0, top = 0, width = 0, height = height, rounded = 0, opts) ⇒ Shoes::Rect
Creates a rectangle.
-
#shape(left = 0, top = 0, styles, &block) ⇒ Shoes::Shape
Creates an arbitrary shape.
-
#star(left = 0, top = 0, points = 10, outer = 100, inner = 50, opts) ⇒ Shoes::Star
Creates a star.
Instance Method Details
#arc(left = 0, top = 0, width = 0, height = 0, angle1 = 0, angle2 = 0, opts) ⇒ Shoes::Arc
Creates an arc. Params are optional and may be passed by name in opts hash instead.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 50 def arc(*args, &blk) opts = style_normalizer.normalize pop_style(args) left, top, width, height, angle1, angle2, *leftovers = args = <<~EOS Too many arguments. Must be one of: - arc(left, top, width, height, angle1, angle2, [opts]) - arc(left, top, width, height, angle1, [opts]) - arc(left, top, width, height, [opts]) - arc(left, top, width, [opts]) - arc(left, top, [opts]) - arc(left, [opts]) - arc([opts]) EOS raise ArgumentError, if leftovers.any? create Shoes::Arc, left, top, width, height, angle1, angle2, opts, blk end |
#arrow(left = 0, top = 0, width = 0, opts) ⇒ Shoes::Arrow
Creates an arrow. Params are optional and may be passed by name in opts hash instead.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 19 def arrow(*args, &blk) opts = style_normalizer.normalize pop_style(args) left, top, width, *leftovers = args = <<~EOS Too many arguments. Must be one of: - arrow(left, top, width, [opts]) - arrow(left, top, [opts]) - arrow(left, [opts]) - arrow([opts]) EOS raise ArgumentError, if leftovers.any? create Shoes::Arrow, left, top, width, opts, blk end |
#line(x1 = 0, y1 = 0, x2 = 0, y2 = 0, opts) ⇒ Shoes::Line
Draws a line from point A (x1,y1) to point B (x2,y2). Params are optional and may be passed by name in opts hash instead.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 80 def line(*args, &blk) opts = style_normalizer.normalize pop_style(args) x1, y1, x2, y2, *leftovers = args = <<~EOS Too many arguments. Must be one of: - line(x1, y1, x2, y2, [opts]) - line(x1, y1, x2, [opts]) - line(x1, y1, [opts]) - line(x1, [opts]) - line([opts]) EOS raise ArgumentError, if leftovers.any? create Shoes::Line, x1, y1, x2, y2, opts, blk end |
#mask(*_) ⇒ Object
Raises kinder error message for method Shoes 4 doesn’t support. See github.com/shoes/shoes4/issues/527.
220 221 222 223 224 225 226 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 220 def mask(*_) raise Shoes::NotImplementedError, <<~EOS Sorry mask is not supported currently in Shoes 4! Check out github issue #527 for any changes/updates or if you want to help :) EOS end |
#oval(left = 0, top = 0, width = 0, height = width, opts) ⇒ Shoes::Oval
Creates an oval. Params are optional and may be passed by name in opts hash instead.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 109 def oval(*args, &blk) opts = style_normalizer.normalize pop_style(args) left, top, width, height, *leftovers = args = <<~EOS Wrong number of arguments. Must be one of: - oval(left, top, width, height, [opts]) - oval(left, top, diameter, [opts]) - oval(left, top, [opts]) - oval(left, [opts]) - oval(styles) EOS raise ArgumentError, if leftovers.any? create Shoes::Oval, left, top, width, height, opts, blk end |
#rect(left = 0, top = 0, width = 0, height = height, rounded = 0, opts) ⇒ Shoes::Rect
Creates a rectangle. Params are optional and may be passed by name in opts hash instead.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 139 def rect(*args, &blk) opts = style_normalizer.normalize pop_style(args) left, top, width, height, curve, *leftovers = args opts[:curve] = curve if curve = <<~EOS Wrong number of arguments. Must be one of: - rect(left, top, width, height, curve, [opts]) - rect(left, top, width, height, [opts]) - rect(left, top, side, [opts]) - rect(left, top, [opts]) - rect(left, [opts]) - rect(styles) EOS raise ArgumentError, if leftovers.any? create Shoes::Rect, left, top, width, height, style.merge(opts), blk end |
#shape(left = 0, top = 0, styles, &block) ⇒ Shoes::Shape
Creates an arbitrary shape. Params are optional and may be passed by name in opts hash instead.
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 199 def shape(*args, &blk) opts = style_normalizer.normalize pop_style(args) left, top, *leftovers = args = <<~EOS Wrong number of arguments. Must be one of: - shape(left, top, [opts]) - shape(left, [opts]) - shape([opts]) EOS raise ArgumentError, if leftovers.any? create Shoes::Shape, left, top, opts, blk end |
#star(left = 0, top = 0, points = 10, outer = 100, inner = 50, opts) ⇒ Shoes::Star
Creates a star. Params are optional and may be passed by name in opts hash instead.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'shoes-core/lib/shoes/dsl/art.rb', line 171 def star(*args, &blk) styles = style_normalizer.normalize pop_style(args) left, top, points, outer, inner, *leftovers = args = <<~EOS Wrong number of arguments. Must be one of: - star([styles]) - star(left, [styles]) - star(left, top, [styles]) - star(left, top, points, [styles]) - star(left, top, points, outer, [styles]) - star(left, top, points, outer, inner, [styles]) EOS raise ArgumentError, if leftovers.any? create Shoes::Star, left, top, points, outer, inner, styles, blk end |