Skip to content

Commit

Permalink
v.1.1.0
Browse files Browse the repository at this point in the history
* don't track current position
* handle implicit lines in moves
* include id/class atts
* parse defs/style
  • Loading branch information
foo123 committed Apr 23, 2023
1 parent 60fa423 commit b2c5385
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 52 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Simple utility to parse SVG to JSON

**version: 1.0.1** (8 kB minified)
**version: 1.1.0** (9 kB minified)


Example (see tests):
Expand All @@ -23,9 +23,10 @@ output:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- (PD) January 26, 2006 - _Crotalus horridus_ -->
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250">
<defs><style>.circ{stroke:red}/*.foo{fill:none}*/#p,.circ{stroke-width:2}</style></defs>
<g fill="none" stroke="#000" stroke-width="21" transform="scale(1.1 1.1)">
<circle cx="125" cy="125" r="106"/>
<path d="M125,19 v212 M125,125 l-75,75 M125,125 l75,75"/>
<circle class="circ" cx="125" cy="125" r="106"/>
<path id="p" class="pth" d="M125,19 v212 M125,125 l-75,75 M125,125 l75,75"/>
</g>
</svg>
```
Expand All @@ -38,13 +39,30 @@ output:
"width": "250",
"height": "250",
"nodes": [
{
"type": "Defs",
"nodes": [
{
"type": "Style",
"rules": [
{
"selector": ".circ",
"style": {
"stroke": "red"
}
},
{
"selector": "#p,.circ",
"style": {
"stroke-width": "2"
}
}
]
}
]
},
{
"type": "Group",
"style": {
"stroke-width": "21",
"stroke": "#000",
"fill": "none"
},
"transform": [
[
"scale",
Expand All @@ -57,8 +75,7 @@ output:
"nodes": [
{
"type": "Circle",
"style": {},
"transform": null,
"class": "circ",
"center": [
125,
125
Expand All @@ -67,8 +84,8 @@ output:
},
{
"type": "Path",
"style": {},
"transform": null,
"id": "p",
"class": "pth",
"d": [
{
"type": "Move",
Expand Down
Loading

0 comments on commit b2c5385

Please sign in to comment.