Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aykutkardas/svgps
Svg Parser
https://github.com/aykutkardas/svgps
icons parser svg svg-parser
Last synced: 2 months ago
JSON representation
Svg Parser
- Host: GitHub
- URL: https://github.com/aykutkardas/svgps
- Owner: aykutkardas
- License: mit
- Created: 2021-04-08T21:28:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-26T13:30:07.000Z (about 1 year ago)
- Last Synced: 2024-09-25T23:10:33.215Z (3 months ago)
- Topics: icons, parser, svg, svg-parser
- Language: TypeScript
- Homepage: https://svgps.app
- Size: 167 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# svgps
[![npm](https://img.shields.io/npm/v/svgps?color=%234fc921)](https://www.npmjs.com/package/svgps)
[![License](https://img.shields.io/badge/License-MIT-green.svg?color=%234fc921)](https://opensource.org/licenses/MIT)SVG Parser
## Install
```
npm install svgps
```## Utils
- Circle to Path
- Rect to Path
- Line to Path
- Polygon to Path## Usage
```js
import { parse } from 'svgps';parse(`...`);
``````js
// Output
{
"width": 192,
"height": 192,
"viewBox": "0 0 256 256",
"svgAttrs": {
"fill": "#000000"
},
"attrs": [
{
"fill": "none"
},
{
"fill": "none",
"stroke": "#000000",
"strokeLinecap": "round",
"strokeLinejoin": "round",
"strokeWidth": 12
},
// ...
],
"paths": [
"M 0 0, 0 256, 256 256, 256 0, 0 0",
"M 216 40, 216 216",
"M 72 56, 72 112, 184 112, 184 56, 72 56",
"M 32 144, 32 200, 184 200, 184 144, 32 144"
]
}
```### IcoMoon Template
```js
parse(`...`, { template: 'icomoon' });
``````js
// Output
{
"icon": {
"width": 1024,
"attrs": [
{
"fill": "none"
},
{
"fill": "none",
"stroke": "#000000",
"strokeLinecap": "round",
"strokeLinejoin": "round",
"strokeWidth": 48
},
// ...
],
"paths": [
"M0 0L0 1024 1024 1024 1024 0 0 0",
"M864 160L864 864",
"M288 224L288 448 736 448 736 224 288 224",
"M128 576L128 800 736 800 736 576 128 576"
]
},
"properties": {
"name": ""
}
}```