sdfsdfs
This commit is contained in:
23
node_modules/parse-svg-path/License
generated
vendored
Normal file
23
node_modules/parse-svg-path/License
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2013 Jake Rosoman <jkroso@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
32
node_modules/parse-svg-path/Readme.md
generated
vendored
Normal file
32
node_modules/parse-svg-path/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
# parse-svg-path
|
||||
|
||||
A minimal svg path parser. For the delux model see [hughsk/svg-path-parser](//github.com/hughsk/svg-path-parser) or for the streaming model see [nfroidure/SVGPathData](//github.com/nfroidure/SVGPathData).
|
||||
|
||||
## Installation
|
||||
|
||||
- [packin](//github.com/jkroso/packin): `packin add jkroso/parse-svg-path`
|
||||
- [component](//github.com/component/component#installing-packages): `component install jkroso/parse-svg-path`
|
||||
- [npm](//npmjs.org/doc/cli/npm-install.html): `npm install parse-svg-path`
|
||||
|
||||
then in your app:
|
||||
|
||||
```js
|
||||
var parse = require('parse-svg-path')
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### parse(string)
|
||||
|
||||
parse an svg path data string. Generates an Array
|
||||
of commands where each command is an Array of the
|
||||
form `[command, arg1, arg2, ...]`
|
||||
|
||||
```js
|
||||
parse('m1 2 3 4') // => [['m',1,2],['l',3,4]]
|
||||
```
|
||||
|
||||
## Running the tests
|
||||
|
||||
Just run `make` and navigate your browser to the test directory.
|
57
node_modules/parse-svg-path/index.js
generated
vendored
Normal file
57
node_modules/parse-svg-path/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
module.exports = parse
|
||||
|
||||
/**
|
||||
* expected argument lengths
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
var length = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0}
|
||||
|
||||
/**
|
||||
* segment pattern
|
||||
* @type {RegExp}
|
||||
*/
|
||||
|
||||
var segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig
|
||||
|
||||
/**
|
||||
* parse an svg path data string. Generates an Array
|
||||
* of commands where each command is an Array of the
|
||||
* form `[command, arg1, arg2, ...]`
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
function parse(path) {
|
||||
var data = []
|
||||
path.replace(segment, function(_, command, args){
|
||||
var type = command.toLowerCase()
|
||||
args = parseValues(args)
|
||||
|
||||
// overloaded moveTo
|
||||
if (type == 'm' && args.length > 2) {
|
||||
data.push([command].concat(args.splice(0, 2)))
|
||||
type = 'l'
|
||||
command = command == 'm' ? 'l' : 'L'
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (args.length == length[type]) {
|
||||
args.unshift(command)
|
||||
return data.push(args)
|
||||
}
|
||||
if (args.length < length[type]) throw new Error('malformed path data')
|
||||
data.push([command].concat(args.splice(0, length[type])))
|
||||
}
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
var number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig
|
||||
|
||||
function parseValues(args) {
|
||||
var numbers = args.match(number)
|
||||
return numbers ? numbers.map(Number) : []
|
||||
}
|
17
node_modules/parse-svg-path/package.json
generated
vendored
Normal file
17
node_modules/parse-svg-path/package.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "parse-svg-path",
|
||||
"version": "0.1.2",
|
||||
"description": "svg path parser",
|
||||
"keywords": ["svg","path","parse","parser"],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"serve": "jkroso/serve#1.5.1",
|
||||
"mocha": "*",
|
||||
"chai": "*"
|
||||
},
|
||||
"repository": "git://github.com/jkroso/parse-svg-path.git",
|
||||
"bugs": "https://github.com/jkroso/parse-svg-path/issues",
|
||||
"author": "Jake Rosoman",
|
||||
"files": ["index.js"],
|
||||
"license": "MIT"
|
||||
}
|
Reference in New Issue
Block a user