Class: VectorSalad::StandardShapes::MultiPath
- Inherits:
-
BasicShape
- Object
- BasicShape
- VectorSalad::StandardShapes::MultiPath
- Includes:
- Mixins::Transforms
- Defined in:
- lib/vector_salad/standard_shapes/multi_path.rb,
lib/vector_salad/exporters/svg_exporter.rb
Overview
MultiPath shape is a collection of Paths. It is mainly to store the result of Clip operations.
Instance Attribute Summary (collapse)
-
- (Object) closed
readonly
Returns the value of attribute closed.
-
- (Object) options
inherited
from BasicShape
Returns the value of attribute options.
-
- (Object) paths
readonly
Returns the value of attribute paths.
Instance Method Summary (collapse)
-
- (Any) [](x, y)
included
from Mixins::Transforms
Move the shape absolutely.
-
- (MultiPath) initialize(*paths, closed: true, **options)
constructor
See Path for details on constructing paths.
-
- (Any) move(x, y)
included
from Mixins::Transforms
Move the shape relatively.
-
- (Any) rotate(angle)
included
from Mixins::Transforms
Rotates the shape by the specified angle about the origin.
-
- (Any) scale(multiplier)
included
from Mixins::Transforms
Scale a shape by multiplier about the origin.
-
- (Object) to_a
Return an array of paths that are and array of node coordinates.
-
- (Object) to_bezier_path
Convert the complex paths in the MultiPath to bezier paths.
-
- (Object) to_cubic_path
Convert the complex paths in the MultiPath to cubic bezier paths only.
-
- (Object) to_multi_path
Returns self.
-
- (Object) to_path
Convert the shape to a path.
-
- (Object) to_simple_path
Convert the complex paths in the MultiPath to simple paths.
-
- (Object) to_svg
Export the shape to an svg string.
Constructor Details
- (MultiPath) initialize(*paths, closed: true, **options)
See Path for details on constructing paths.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 28 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
- (Object) closed (readonly)
Returns the value of attribute closed
13 14 15 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 13 def closed @closed end |
- (Object) options Originally defined in class BasicShape
Returns the value of attribute options
- (Object) paths (readonly)
Returns the value of attribute paths
13 14 15 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 13 def paths @paths end |
Instance Method Details
- (Any) [](x, y) Originally defined in module Mixins::Transforms
Move the shape absolutely.
- (Any) move(x, y) Originally defined in module Mixins::Transforms
Move the shape relatively.
- (Any) rotate(angle) Originally defined in module Mixins::Transforms
Rotates the shape by the specified angle about the origin.
- (Any) scale(multiplier) Originally defined in module Mixins::Transforms
Scale a shape by multiplier about the origin.
- (Object) to_a
Return an array of paths that are and array of node coordinates.
65 66 67 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 65 def to_a @paths.map(&:to_a) end |
- (Object) to_bezier_path
Convert the complex paths in the MultiPath to bezier paths.
45 46 47 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 45 def to_bezier_path self.class.new(*@paths.map(&:to_bezier_path), **@options) end |
- (Object) to_cubic_path
Convert the complex paths in the MultiPath to cubic bezier paths only.
50 51 52 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 50 def to_cubic_path self.class.new(*@paths.map(&:to_cubic_path), **@options) end |
- (Object) to_multi_path
Returns self
60 61 62 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 60 def to_multi_path self end |
- (Object) to_path
Convert the shape to a path
40 41 42 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 40 def to_path self end |
- (Object) to_simple_path
Convert the complex paths in the MultiPath to simple paths.
55 56 57 |
# File 'lib/vector_salad/standard_shapes/multi_path.rb', line 55 def to_simple_path self.class.new(*@paths.map(&:to_simple_path), **@options) end |
- (Object) to_svg
Export the shape to an svg string
89 90 91 92 93 94 95 96 97 |
# File 'lib/vector_salad/exporters/svg_exporter.rb', line 89 def to_svg svg = '<path d="' paths.each do |path| svg << " #{path.to_svg_d_attribute}" end svg << '"' svg << Exporters::SvgExporter.(@options) svg << "/>" end |