0.0.4 • Published 8 years ago

svg-flat-document v0.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

SVGFlatDocument

ES6 SVG document without tree (flat)

Install

npm install svg-flat-document

Usage

Parse from SVG string

import SVGFlatDocument from 'svg-flat-document';

let doc = SVGFlatDocument.parse(svgString);

With svgString =

<svg width=100>
  <g transform="translate(100, 0)">
    <rect id="me" x="0" y="0" width="100" height="200" />
  </g>
</svg>

Retreive element

let node = doc.mapping.me;
let attr = node.attributes;

console.log(attr.x, attr.y, attr.width, attr.height);
// 0 0 100 200

console.log(attr.transform);
// matrix(1,0,0,1,100,0)

So groups are ignored and children absorb every parents transforms.