Class: VectorSalad::StandardShapes::MultiPath
- Inherits:
-
BasicShape
- Object
- BasicShape
- VectorSalad::StandardShapes::MultiPath
- Defined in:
- lib/vector_salad/exporters/svg_exporter.rb,
lib/vector_salad/standard_shapes/multi_path.rb
Instance Attribute Summary collapse
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Attributes inherited from BasicShape
Instance Method Summary collapse
-
#initialize(*paths, closed: true, **options) ⇒ MultiPath
constructor
A new instance of MultiPath.
- #move(x, y) ⇒ Object
- #rotate(angle) ⇒ Object
- #scale(multiplier) ⇒ Object
- #to_a ⇒ Object
- #to_cubic_path ⇒ Object
- #to_multi_path ⇒ Object
- #to_path ⇒ Object
- #to_simple_path ⇒ Object
- #to_svg ⇒ Object
Constructor Details
#initialize(*paths, closed: true, **options) ⇒ MultiPath
Returns a new instance of MultiPath.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 24 def initialize(*paths, closed: true, **) paths.each do |path| path = path.instance_of?(Array) ? Path.new(*path) : path @paths = Array(@paths) << path end @closed = closed @options = self end |
Instance Attribute Details
#closed ⇒ Object (readonly)
Returns the value of attribute closed.
8 9 10 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 8 def closed @closed end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
8 9 10 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 8 def paths @paths end |
Instance Method Details
#move(x, y) ⇒ Object
37 38 39 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 37 def move(x, y) each_send(:move, x, y) end |
#rotate(angle) ⇒ Object
43 44 45 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 43 def rotate(angle) each_send(:rotate, angle) end |
#scale(multiplier) ⇒ Object
49 50 51 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 49 def scale(multiplier) each_send(:scale, multiplier) end |
#to_a ⇒ Object
69 70 71 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 69 def to_a @paths.map(&:to_a) end |
#to_cubic_path ⇒ Object
57 58 59 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 57 def to_cubic_path self.class.new(*@paths.map(&:to_cubic_path), **@options) end |
#to_multi_path ⇒ Object
65 66 67 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 65 def to_multi_path self end |
#to_path ⇒ Object
53 54 55 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 53 def to_path self end |
#to_simple_path ⇒ Object
61 62 63 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 61 def to_simple_path self.class.new(*@paths.map(&:to_simple_path), **@options) end |
#to_svg ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/vector_salad/exporters/svg_exporter.rb', line 80 def to_svg svg = '<path d="' paths.each do |path| svg << " #{path.to_svg_d_attribute}" end svg << '"' svg << VectorSalad::Exporters::SvgExporter.(@options) svg << '/>' end |