svg-path-contours
Approximates an SVG path into a discrete list of 2D contours (polylines). This is useful for collision detection, intersection, triangulation & WebGL rendering, etc. It does not attempt to clean or optimize the discretized points.
Usage:
var parse = var contours = var path = 'm10,10C45.812,24.024,45.673,24,45.529,24H31.625 c0.482-3.325,6.464-2.758,8.913-3.155z' var result = /* [ [ [10,10], ...etc ] [ [x, y], ... ]]*/
Triangulation example:
var parse = var simplify = var contours = var triangulate = //get a list of polylines/contours from svg contentsvar lines = //simplify the contours before triangulationlines = lines //turns into triangles, returns { positions, cells }var shape = //now draw the simplicial complex with Canvas/WebGL/etc
See demo/index.js for exmaple.
Usage
contours(svg)
Takes parsed SVG contents from parse-svg-path and produces a list of 2D polylines representing the contours of the shape.
License
MIT, see LICENSE.md for details.