class VectorBeWinding::Path
Attributes
sub_paths[R]
Public Class Methods
new(sub_paths, is_tree = false)
click to toggle source
# File lib/vector_be_winding/path.rb, line 16 def initialize(sub_paths, is_tree = false) if is_tree @children = sub_paths @sub_paths = [] children.each {|root| root.each { |subpath| @sub_paths << subpath }} else @sub_paths = sub_paths sub_paths.each {|p| insert_to_tree(p)} end end
with_string(path_string)
click to toggle source
# File lib/vector_be_winding/path.rb, line 7 def self.with_string(path_string) begin svg_path = Savage::Parser.parse(path_string) rescue => e raise ArgumentError, "Possibly wrong path string \"#{path_string}\"" end Path.new(svg_path.subpaths.map { |svg_subpath| SubPath.with_svg(svg_subpath) }) end
Public Instance Methods
area()
click to toggle source
# File lib/vector_be_winding/path.rb, line 31 def area sub_paths.map(&:area).reduce(:+) end
be_winding()
click to toggle source
# File lib/vector_be_winding/path.rb, line 43 def be_winding() wounds = children.map(&:be_winding) Path.new(wounds, true) end
bounding_rect()
click to toggle source
# File lib/vector_be_winding/path.rb, line 27 def bounding_rect @bounding_rect ||= @sub_paths.map(&:bounding_rect).reduce(:|) end
inspect()
click to toggle source
# File lib/vector_be_winding/path.rb, line 35 def inspect "#<Path>" end
is_winding(sign = 1)
click to toggle source
# File lib/vector_be_winding/path.rb, line 39 def is_winding(sign = 1) children.all? { |c| c.is_winding } end
to_command()
click to toggle source
# File lib/vector_be_winding/path.rb, line 48 def to_command sub_paths.map(&:to_command).join end