Class: VectorSalad::StandardShapes::MultiPath

Inherits:
BasicShape
  • Object
show all
Defined in:
lib/vector_salad/exporters/svg_exporter.rb,
lib/vector_salad/standard_shapes/multi_path.rb

Instance Attribute Summary collapse

Attributes inherited from BasicShape

#options

Instance Method Summary collapse

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, **options)
  paths.each do |path|
    path = path.instance_of?(Array) ? Path.new(*path) : path
    @paths = Array(@paths) << path
  end

  @closed = closed
  @options = options
  self
end

Instance Attribute Details

#closedObject (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

#pathsObject (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_aObject



69
70
71
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 69

def to_a
  @paths.map(&:to_a)
end

#to_cubic_pathObject



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_pathObject



65
66
67
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 65

def to_multi_path
  self
end

#to_pathObject



53
54
55
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 53

def to_path
  self
end

#to_simple_pathObject



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_svgObject



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(@options)
  svg << '/>'
end