lib/prawn/svg/parser/path.rb
#
# Parses an SVG path and returns a Prawn-compatible call tree.
#
Parses an SVG path and returns a Prawn-compatible call tree.
Parses an SVG path and returns a Prawn - compatible call tree .
def parse(data)
        @subpath_initial_point = @last_point = nil
        @previous_control_point = @previous_quadratic_control_point = nil
        @calls = []
        data = data.gsub(/#{OUTSIDE_SPACE_REGEXP}$/, '')
        matched_commands = match_all(data, COMMAND_REGEXP)
        raise InvalidError, "Invalid/unsupported syntax for SVG path data" if matched_commands.nil?
        matched_commands.each do |matched_command|
          command = matched_command[1]
          matched_values = match_all(matched_command[2], VALUES_REGEXP)
          raise "should be impossible to have invalid inside data, but we ended up here" if matched_values.nil?
          values = matched_values.collect {|value| value[1].to_f}
          run_path_command(command, values)
        end
        @calls
      end
def parse ( data ) @subpath_initial_point = @last_point = nil @previous_control_point = @previous_quadratic_control_point = nil @calls = [ ] data = data . gsub ( / #{ OUTSIDE_SPACE_REGEXP } $ / , '' ) matched_commands = match_all ( data , COMMAND_REGEXP ) raise InvalidError , "Invalid/unsupported syntax for SVG path data" if matched_commands . nil? matched_commands . each do | matched_command | command = matched_command [ 1 ] matched_values = match_all ( matched_command [ 2 ] , VALUES_REGEXP ) raise "should be impossible to have invalid inside data, but we ended up here" if matched_values . nil? values = matched_values . collect { | value | value [ 1 ] . to_f } run_path_command ( command , values ) end @calls end
Parses an SVG path and returns a Prawn-compatible call tree.
Parses an SVG path and returns a Prawn - compatible call tree .
data
<not_specific>