0.0.1 • Published 7 years ago

svg-catmull-rom-spline v0.0.1

Weekly downloads
49
License
ISC
Repository
github
Last release
7 years ago

SVGCatmullRomSpline

Make path line of SVG smooth.

  • Convert series of CatmullRom points to Spline
  • Simplify points (use simplify-js)

Usage

get spline points

var points = [[0, 0], [200, 200], [200, 0], [0, 200]];
var splinePoints = SVGCatmullRomSpline.toPoints(points);

apply spline attribute to SVG path

var points = [[0, 0], [200, 200], [200, 0], [0, 200]];
var tolerance = 4;
var highestQuality = true;
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
var attribute = SVGCatmullRomSpline.toPath(points.map(points), tolerance, highestQuality);
path.setAttributeNS(null, 'd', attribute);