{"_id":"svg-path-parser","_rev":"222875","name":"svg-path-parser","description":"A parser for SVG's path syntax","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"hughsk","email":""}],"time":{"modified":"2023-03-24T09:40:19.000Z","created":"2013-09-16T12:38:25.104Z","1.1.0":"2017-06-19T18:40:45.301Z","1.0.2":"2017-06-19T18:40:07.714Z","1.0.1":"2014-10-31T01:32:38.446Z","1.0.0":"2014-10-12T20:35:53.862Z","0.0.4":"2014-10-11T04:19:30.279Z","0.0.3":"2014-10-01T17:43:07.372Z","0.0.2":"2014-10-01T17:36:13.402Z","0.0.1":"2014-02-25T02:45:48.168Z","0.0.0":"2013-09-16T12:38:25.104Z"},"users":{},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"versions":{"1.1.0":{"name":"svg-path-parser","version":"1.1.0","description":"A parser for SVG's path syntax","license":"MIT","main":"index.js","scripts":{"prepublish":"pegjs -o parser.js grammar.peg"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"^0.10.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"gitHead":"701893acedb778a467dd23eb1e1b6b6895647eb5","bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser#readme","_id":"svg-path-parser@1.1.0","_shasum":"e16b4b39df0d2b0d39e8347db79fdda1453a6046","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"dist":{"shasum":"e16b4b39df0d2b0d39e8347db79fdda1453a6046","size":9299,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-1.1.0.tgz"},"maintainers":[{"name":"hughsk","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svg-path-parser-1.1.0.tgz_1497897645173_0.2359926167409867"},"directories":{},"publish_time":1497897645301,"_hasShrinkwrap":false,"_cnpm_publish_time":1497897645301,"_cnpmcore_publish_time":"2021-12-16T18:51:53.027Z"},"1.0.2":{"name":"svg-path-parser","version":"1.0.2","description":"A parser for SVG's path syntax","license":"MIT","main":"index.js","scripts":{"prepublish":"pegjs -o parser.js grammar.peg"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":">=0.10 <1"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"gitHead":"91b4acb1327e693f4e4eb3820e582ab4e9ebea0b","bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser#readme","_id":"svg-path-parser@1.0.2","_shasum":"b93cbc12927573acb48cd19f6b19eb6beb8d2a6b","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"dist":{"shasum":"b93cbc12927573acb48cd19f6b19eb6beb8d2a6b","size":8063,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-1.0.2.tgz"},"maintainers":[{"name":"hughsk","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svg-path-parser-1.0.2.tgz_1497897607629_0.543329190229997"},"directories":{},"publish_time":1497897607714,"_hasShrinkwrap":false,"_cnpm_publish_time":1497897607714,"_cnpmcore_publish_time":"2021-12-16T18:51:53.281Z"},"1.0.1":{"name":"svg-path-parser","version":"1.0.1","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"pegjs grammar.peg parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@1.0.1","dist":{"shasum":"3e59f5e5d70d2fc0d7c17f7cc547bc3c3faac157","size":8100,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-1.0.1.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"maintainers":[{"name":"hughsk","email":""}],"directories":{},"publish_time":1414719158446,"_hasShrinkwrap":false,"_cnpm_publish_time":1414719158446,"_cnpmcore_publish_time":"2021-12-16T18:51:53.495Z"},"1.0.0":{"name":"svg-path-parser","version":"1.0.0","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"pegjs grammar.peg parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@1.0.0","dist":{"shasum":"f8250cdb7ab7499cd4cf6c17c83510d1f078ed49","size":7769,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-1.0.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"maintainers":[{"name":"hughsk","email":""}],"directories":{},"publish_time":1413146153862,"_hasShrinkwrap":false,"_cnpm_publish_time":1413146153862,"_cnpmcore_publish_time":"2021-12-16T18:51:54.118Z"},"0.0.4":{"name":"svg-path-parser","version":"0.0.4","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"pegjs grammar.peg parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@0.0.4","dist":{"shasum":"3ae50f18869b25a225469e3dbeaecbef38367282","size":7082,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-0.0.4.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-0.0.4.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"maintainers":[{"name":"hughsk","email":""}],"directories":{},"publish_time":1413001170279,"_hasShrinkwrap":false,"_cnpm_publish_time":1413001170279,"_cnpmcore_publish_time":"2021-12-16T18:51:54.307Z"},"0.0.3":{"name":"svg-path-parser","version":"0.0.3","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"node build.js > parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"gitHead":"ce15e031ccf6180527b6e139cac7bc331c8e1da5","bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@0.0.3","_shasum":"4ab8238858b5dbb779517b43ee09eaa3bc3ccdae","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"maintainers":[{"name":"hughsk","email":""}],"dist":{"shasum":"4ab8238858b5dbb779517b43ee09eaa3bc3ccdae","size":18517,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-0.0.3.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-0.0.3.tgz"},"directories":{},"publish_time":1412185387372,"_hasShrinkwrap":false,"_cnpm_publish_time":1412185387372,"_cnpmcore_publish_time":"2021-12-16T18:51:54.550Z"},"0.0.2":{"name":"svg-path-parser","version":"0.0.2","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"node build.js > parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"gitHead":"1510419242db364b850aa653b1a4d642c03f9497","bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@0.0.2","_shasum":"4c4838cf96d2fbcbfbd53e7d40349738549d7197","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"phrogz","email":"!@phrogz.net"},"maintainers":[{"name":"hughsk","email":""}],"dist":{"shasum":"4c4838cf96d2fbcbfbd53e7d40349738549d7197","size":18502,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-0.0.2.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-0.0.2.tgz"},"directories":{},"publish_time":1412184973402,"_hasShrinkwrap":false,"_cnpm_publish_time":1412184973402,"_cnpmcore_publish_time":"2021-12-16T18:51:54.842Z"},"0.0.1":{"name":"svg-path-parser","version":"0.0.1","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"node build.js > parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"keywords":["svg","path","d","attribute","parser","lines","drawing"],"bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"homepage":"https://github.com/hughsk/svg-path-parser","_id":"svg-path-parser@0.0.1","dist":{"shasum":"b23c30ca971645b9fa5690e416ee887d7500f95d","size":6416,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-0.0.1.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-0.0.1.tgz"},"_from":".","_npmVersion":"1.4.2","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":""}],"directories":{},"publish_time":1393296348168,"_hasShrinkwrap":false,"_cnpm_publish_time":1393296348168,"_cnpmcore_publish_time":"2021-12-16T18:51:55.122Z"},"0.0.0":{"name":"svg-path-parser","version":"0.0.0","description":"A parser for SVG's path syntax","main":"index.js","scripts":{"prepublish":"node build.js > parser.js"},"repository":{"type":"git","url":"git://github.com/hughsk/svg-path-parser.git"},"dependencies":{},"devDependencies":{"pegjs":"~0.7.0"},"readmeFilename":"README.md","keywords":["svg","path","d","attribute","parser","lines","drawing"],"_id":"svg-path-parser@0.0.0","dist":{"shasum":"ec2fcc66867ff80979bd275459b90385c311d072","size":6414,"noattachment":false,"key":"/svg-path-parser/-/svg-path-parser-0.0.0.tgz","tarball":"http://name.csiicloud.com:7001/svg-path-parser/download/svg-path-parser-0.0.0.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":""}],"directories":{},"publish_time":1379335105104,"_hasShrinkwrap":false,"_cnpm_publish_time":1379335105104,"_cnpmcore_publish_time":"2021-12-16T18:51:55.349Z"}},"readme":"# svg-path-parser [![stable](http://hughsk.github.io/stability-badges/dist/stable.svg)](http://github.com/hughsk/stability-badges) #\n\nAn SVG path parser, originally built from the [PEG.js](http://pegjs.majda.cz/) grammar\nspecified [here](http://pastie.org/1036541), published as an NPM module.\n\nGrammar originally written by [Gavin Kistner](http://github.com/Phrogz).\n\n[![svg-path-parser](https://nodei.co/npm/svg-path-parser.png?mini=true)](https://nodei.co/npm/svg-path-parser)\n\n## Usage ##\n\n### `require('svg-path-parser')(d)` ###\n\nTakes an SVG path string. The following code…\n\n``` javascript\nvar parseSVG = require('svg-path-parser');\nvar d='M3,7 5-6 L1,7 1e2-.4 m-10,10 l10,0  \\\n  V27 89 H23           v10 h10             \\\n  C33,43 38,47 43,47   c0,5 5,10 10,10     \\\n  S63,67 63,67         s-10,10 10,10       \\\n  Q50,50 73,57         q20,-5 0,-10        \\\n  T70,40               t0,-15              \\\n  A5,5 45 1,0 40,20    a5,5 20 0,1 -10-10  Z';\nconsole.log(parseSVG(d));\n```\n\n…will yield an array of commands that define the path, like so:\n\n``` javascript\n[ { code:'M', command:'moveto', x:3, y:7 },\n  { code:'L', command:'lineto', x:5, y:-6 },\n  { code:'L', command:'lineto', x:1, y:7 },\n  { code:'L', command:'lineto', x:100, y:-0.4 },\n  { code:'m', command:'moveto', relative:true, x:-10, y:10 },\n  { code:'l', command:'lineto', relative:true, x:10, y:0 },\n  { code:'V', command:'vertical lineto', y:27 },\n  { code:'V', command:'vertical lineto', y:89 },\n  { code:'H', command:'horizontal lineto', x:23 },\n  { code:'v', command:'vertical lineto', relative:true, y:10 },\n  { code:'h', command:'horizontal lineto', relative:true, x:10 },\n  { code:'C', command:'curveto', x1:33, y1:43, x2:38, y2:47, x:43, y:47 },\n  { code:'c', command:'curveto', relative:true, x1:0, y1:5, x2:5, y2:10, x:10, y:10 },\n  { code:'S', command:'smooth curveto', x2:63, y2:67, x:63, y:67 },\n  { code:'s', command:'smooth curveto', relative:true, x2:-10, y2:10, x:10, y:10 },\n  { code:'Q', command:'quadratic curveto', x1:50, y1:50, x:73, y:57 },\n  { code:'q', command:'quadratic curveto', relative:true, x1:20, y1:-5, x:0, y:-10 },\n  { code:'T', command:'smooth quadratic curveto', x:70, y:40 },\n  { code:'t', command:'smooth quadratic curveto', relative:true, x:0, y:-15 },\n  { code:'A', command:'elliptical arc', rx:5, ry:5, xAxisRotation:45, largeArc:true, sweep:false, x:40, y:20 },\n  { code:'a', command:'elliptical arc', relative:true, rx:5, ry:5, xAxisRotation:20, largeArc:false, sweep:true, x:-10, y:-10 },\n  { code:'Z', command:'closepath' } ]\n```\n\nAlternatively, from version 1.1 on, the module exports multiple functions that you can separately use:\n\n```js\nconst {parseSVG, makeAbsolute} = require('svg-path-parser');\n```\n\n## Absolute Path Commands\n\nVersion 1.1 adds the ability to convert an array of path commands into their absolute-coordinate equivalents. This modifies the parsed command objects in place, and also returns the array of commands. Continuing the example above:\n\n```js\nconst {parseSVG, makeAbsolute} = require('svg-path-parser');\nconst commands = parseSVG(d);\nmakeAbsolute(commands); // Note: mutates the commands in place!\nconsole.log(commands);\n```\n\n``` javascript\n[ { code:'M', command:'moveto',                   x0:0, y0:0 x:3, y:7 },\n  { code:'L', command:'lineto',                   x0:3, y0:7 x:5, y:-6 },\n  { code:'L', command:'lineto',                   x0:5, y0:-6 x:1, y:7 },\n  { code:'L', command:'lineto',                   x0:1, y0:7 x:100, y:-0.4 },\n  { code:'M', command:'moveto',                   x0:100, y0:-0.4 x:90, y:9.6 },\n  { code:'L', command:'lineto',                   x0:90, y0:9.6 x:100, y:9.6 },\n  { code:'V', command:'vertical lineto',          x0:100, y0:9.6, x:100, y:27  },\n  { code:'V', command:'vertical lineto',          x0:100, y0:27, x:100, y:89 },\n  { code:'H', command:'horizontal lineto',        x0:100, y0:89, x:23, y:89 },\n  { code:'V', command:'vertical lineto',          x0:23, y0:89, y:99, x:23 },\n  { code:'H', command:'horizontal lineto',        x0:23, y0:99, x:33, y:99 },\n  { code:'C', command:'curveto',                  x0:33, y0:99 x1:33, y1:43, x2:38, y2:47, x:43, y:47 },\n  { code:'C', command:'curveto',                  x0:43, y0:47 x1:43, y1:52, x2:48, y2:57, x:53, y:57 },\n  { code:'S', command:'smooth curveto',           x0:53, y0:57 x2:63, y2:67, x:63, y:67 },\n  { code:'S', command:'smooth curveto',           x0:63, y0:67 x2:53, y2:77, x:73, y:77 },\n  { code:'Q', command:'quadratic curveto',        x0:73, y0:77 x1:50, y1:50, x:73, y:57 },\n  { code:'Q', command:'quadratic curveto',        x0:73, y0:57 x1:93, y1:52, x:73, y:47 },\n  { code:'T', command:'smooth quadratic curveto', x0:73, y0:47 x:70, y:40 },\n  { code:'T', command:'smooth quadratic curveto', x0:70, y0:40 x:70, y:25 },\n  { code:'A', command:'elliptical arc',           x0:70, y0:25 rx:5, ry:5, xAxisRotation:45, largeArc:true, sweep:false, x:40, y:20 },\n  { code:'A', command:'elliptical arc',           x0:40, y0:20 rx:5, ry:5, xAxisRotation:20, largeArc:false, sweep:true, x:30, y:10 },\n  { code:'Z', command:'closepath',                x0:30, y0:10, x:90, y:9.6 } ]\n```\n\nIn addition to converting all commands to absolute coordinates, the `makeAbsolute` function ensures that:\n\n* Every command has `x0` and `y0` properties showing the start point for the command.\n* Every command has `x` and `y` properties showing the finish point for the command.\n  * This makes `H`, `V`, and `Z` commands equivalent to an `L` command.\n\n## History\n\n### v1.1.0 - 2017-Jun-19\n+ Add `makeAbsolute(cmds)`.\n\n### v1.0.2 - 2017-Mar-1\n+ Update package to allow latest PEGJS versions (was locked to v0.7.x).\n+ Fix bug preventing parsing errors from appearing for newer PEGJS. (Issue #9)\n\n### v1.0.1 - 2014-Oct-30\n+ Fix bug that prevented more than two subpaths from being returned.\n\n### v1.0.0 - 2014-Oct-12\n+ Changed return values to represent each unique path command as its own object,\n  regardless of whether the markup merged them or not. Arguments for a command\n  (e.g. `.x`) are no longer in a `.args` array of values, but are instead part\n  of the command object itself.\n\n### v0.0.4 - 2014-Oct-10\n+ Unroll recursive grammar descriptions that could cause parsing a large path to overflow the stack.\n\n### v0.0.3 - 2014-Oct-1\n+ Fix bug that prevented parsing some valid documents.\n\n### v0.0.2 - 2014-Oct-1\n+ Fix parsing of numbers other than integers to work.\n+ First `moveto` command is always absolute.\n+ Additional coordinates after moveto are treated as lineto.\n\n## License\n\nThis library is released under an MIT-style license. That generally means that you are free to do almost anything you want with it as long as you give a bit of credit where credit is due. See the LICENSE file included for the actual legal limitations.","_attachments":{},"homepage":"https://github.com/hughsk/svg-path-parser#readme","bugs":{"url":"https://github.com/hughsk/svg-path-parser/issues"},"license":"MIT"}