lw.svg-parser
SVG parser for LaserWeb/CNCWeb.
Supported tags
Features
- ViewBox, PreserveAspectRatio
- Clipping paths with Clipper.js
- Promise mechanism
- ES6 / UMD module
Demo
https://lautr3k.github.io/lw.svg-parser/dist/example/
Installation
Using NPM
npm install lw.svg-parser
Using GIT
git clone https://github.com/lautr3k/lw.svg-parser.git
cd svg-parser
npm install
Or download the last build from https://raw.githubusercontent.com/lautr3k/lw.svg-parser/master/dist/lw.svg-parser.js
Settings (all are optional)
let settings = includes: 'svg' 'g' 'defs' 'use' 'line' 'polyline' 'polygon' 'rect' 'circle' 'ellipse' 'path' 'title' 'desc' 'image' 'text' excludes: '#text' '#comment' traceSettings: // Arc, Bezier curves only linear : true // Linear trace mode step : 001 // Step resolution if linear mode = false resolution : 100 // Number of segments we use to approximate arc length segmentLength: 1 // Segment length {} // Called after a tag is parsed
Usages
let parser = settings // <input> must be an raw XML string, XMLDocument, Element or File objectreturn parser;
After the main <svg>
tag was parsed you can access this two properties on the parser instance :
parsereditor // Editor info { name, version, fingerprint }parserdocument // Document info { width, height, viewBox } // where viewBox is { x, y, width, height }