-
-
Notifications
You must be signed in to change notification settings - Fork 23
Usage Examples
thednp edited this page Jan 7, 2021
·
14 revisions
Import, initialize and call multiple instance methods, or return the values right away.
Example
// import the constructor
import SVGPathCommander from 'svg-path-commander'
let pathString = 'M0 0l50 0l50 50z';
// initialize
let mySVGPCInit = new SVGPathCommander(pathString);
/*
returns => {
pathValue: 'M0 0l50 0l50 50z',
segments: [ ['M',0,0], ['l',50,0], ['l',50,50], ['z'] ],
round: 3
}
*/
// direct access to methods
let mySVGPCInit = new SVGPathCommander(pathString).flipX().toString();
// returns => "M100 50L50 0L0 0z"
// for node.js, you also need to bring DOMMatrix shim
const DOMMatrix = require('dommatrix');
// import the constructor
const SVGPathCommander = require('svg-path-commander');
let pathString = 'M0 0l50 0l50 50z';
// initialize
let mySVGPCInit = new SVGPathCommander(pathString);
// or do whatever you want, perhaps you're a font creator?
let mySVGPCString = new SVGPathCommander(pathString)
.flipX()
.optimize()
.toString();