examples/svg-boundings.js
function (str) {
    var output = [];
    var idx = 0;
    var c, num;

    var nextNumber = function () {
      var chars = [];

      while (/[^-\d\.]/.test(str.charAt(idx))) {
        // skip the non-digit characters
        idx++;
      }

      if ('-' === str.charAt(idx)) {
        chars.push('-');
        idx++;
      }

      while ((c = str.charAt(idx)) && /[\d\.Ee]/.test(c)) {
        chars.push(c);
        idx++;
      }

      return parseFloat(chars.join(''));
    };

    while (!isNaN(num = nextNumber())) output.push(num);

    return output;
  }
function (str) {
    var output = [];
    var idx = 0;
    var c, num;

    var nextNumber = function () {
      var chars = [];

      while (/[^-\d\.]/.test(str.charAt(idx))) {
        // skip the non-digit characters
        idx++;
      }

      if ('-' === str.charAt(idx)) {
        chars.push('-');
        idx++;
      }

      while ((c = str.charAt(idx)) && /[\d\.Ee]/.test(c)) {
        chars.push(c);
        idx++;
      }

      return parseFloat(chars.join(''));
    };

    while (!isNaN(num = nextNumber())) output.push(num);

    return output;
  }
function ( str ) { var output = [ ] ; var idx = 0 ; var c , num ; var nextNumber = function ( ) { var chars = [ ] ; while ( / [^-\d\.] / . test ( str . charAt ( idx ) ) ) { // skip the non-digit characters idx ++ ; } if ( '-' === str . charAt ( idx ) ) { chars . push ( '-' ) ; idx ++ ; } while ( ( c = str . charAt ( idx ) ) && / [\d\.Ee] / . test ( c ) ) { chars . push ( c ) ; idx ++ ; } return parseFloat ( chars . join ( '' ) ) ; } ; while ( ! isNaN ( num = nextNumber ( ) ) ) output . push ( num ) ; return output ; }
Helper - get arguments of a path drawing command
Helper - get arguments of a path drawing command