parse (array = [ 'M', 0, 0 ]) {
    // prepare for parsing
    var s
    var paramCnt = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 }

    if (typeof array === 'string') {
      array = array
        .replace(numbersWithDots, pathRegReplace) // convert 45.123.123 to 45.123 .123
        .replace(pathLetters, ' $& ') // put some room between letters and numbers
        .replace(hyphen, '$1 -') // add space before hyphen
        .trim() // trim
        .split(delimiter) // split into array
    } else {
      // Flatten array
      array = Array.prototype.concat.apply([], array)
    }

    // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...]
    var result = []
    var p = new Point()
    var p0 = new Point()
    var index = 0
    var len = array.length

    do {
      // Test if we have a path letter
      if (isPathLetter.test(array[index])) {
        s = array[index]
        ++index
        // If last letter was a move command and we got no new, it defaults to [L]ine
      } else if (s === 'M') {
        s = 'L'
      } else if (s === 'm') {
        s = 'l'
      }

      result.push(pathHandlers[s].call(null,
        array.slice(index, (index = index + paramCnt[s.toUpperCase()])).map(parseFloat),
        p, p0
      )
      )
    } while (len > index)

    return result
  }
// Absolutize and parse path to array
Absolutize and parse path to array
Absolutize and parse path to array
parse (array = [ 'M', 0, 0 ]) {
    var s
    var paramCnt = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 }
    if (typeof array === 'string') {
      array = array
        .replace(numbersWithDots, pathRegReplace) 
        .replace(pathLetters, ' $& ') 
        .replace(hyphen, '$1 -') 
        .trim() 
        .split(delimiter) 
    } else {
      array = Array.prototype.concat.apply([], array)
    }
    var result = []
    var p = new Point()
    var p0 = new Point()
    var index = 0
    var len = array.length
    do {
      if (isPathLetter.test(array[index])) {
        s = array[index]
        ++index
      } else if (s === 'M') {
        s = 'L'
      } else if (s === 'm') {
        s = 'l'
      }
      result.push(pathHandlers[s].call(null,
        array.slice(index, (index = index + paramCnt[s.toUpperCase()])).map(parseFloat),
        p, p0
      )
      )
    } while (len > index)
    return result
  }
parse ( array = [ 'M' , 0 , 0 ] ) { var s var paramCnt = { M : 2 , L : 2 , H : 1 , V : 1 , C : 6 , S : 4 , Q : 4 , T : 2 , A : 7 , Z : 0 } if ( typeof array === 'string' ) { array = array . replace ( numbersWithDots , pathRegReplace ) . replace ( pathLetters , ' $& ' ) . replace ( hyphen , '$1 -' ) . trim ( ) . split ( delimiter ) } else { array = Array . prototype . concat . apply ( [ ] , array ) } var result = [ ] var p = new Point ( ) var p0 = new Point ( ) var index = 0 var len = array . length do { if ( isPathLetter . test ( array [ index ] ) ) { s = array [ index ] ++ index } else if ( s === 'M' ) { s = 'L' } else if ( s === 'm' ) { s = 'l' } result . push ( pathHandlers [ s ] . call ( null , array . slice ( index , ( index = index + paramCnt [ s . toUpperCase ( ) ] ) ) . map ( parseFloat ) , p , p0 ) ) } while ( len > index ) return result }
Absolutize and parse path to array
Absolutize and parse path to array
// prepare for parsing // convert 45.123.123 to 45.123 .123 // put some room between letters and numbers // add space before hyphen // trim // split into array // Flatten array // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...] // Test if we have a path letter // If last letter was a move command and we got no new, it defaults to [L]ine