svg-path-generator
Advanced tools
Weekly downloads
Readme
use with node or in browser with browserify
npm install svg-path-generator
var Path = require('svg-path-generator');
var path = Path()
.moveTo(10, 25)
.lineTo(10, 75)
.lineTo(60, 75)
.lineTo(10, 25)
.end();
console.log(path) // M 10 25 L 10 75 L 60 75 L 10 25
to use relative coordinates, call .relative()
before any method
e.g.
var Path = require('svg-path-generator');
var path = Path()
.moveTo(10, 25)
.relative().lineTo(0, 50)
.relative().lineTo(50, 0)
.relative().lineTo(-50, -50)
.end();
console.log(path) // M 10 25 l 0 50 l 50 0 l -50 -50
both paths are equivalent.
moveTo(x, y)
Path.moveTo(x1, y1, x2, y2)
is equivalent to Path.moveTo(x1, y1).moveTo(x2, y2)
lineTo(x, y)
horizontalLineTo(x)
verticalLineTo(y)
curveTo(x1, y1, x2, y2, x, y)
smoothCurveTo(x2, y2, x, y)
bezierCurveTo(x1, y1, x, y)
smoothBezierCurveTo(x, y)
ellipticalArc(rx, ry, xAxisRotation, largeArcFlag, sweepFlag, x, y)
close()
.relative()
call before any method to have the method accept relative instead of absolute coordinates.end()
converts the Path object to a string. This also gets called on the .toString()
methodMIT
FAQs
Easily generate svg path strings
The npm package svg-path-generator receives a total of 695 weekly downloads. As such, svg-path-generator popularity was classified as not popular.
We found that svg-path-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.