diff --git a/src/geometry/Svg.js b/src/geometry/Svg.js index 9c0f65d..6ed51bc 100644 --- a/src/geometry/Svg.js +++ b/src/geometry/Svg.js @@ -13,6 +13,7 @@ var Svg = {}; module.exports = Svg; var Bounds = require('../geometry/Bounds'); +var Common = require('../core/Common'); (function() { @@ -21,12 +22,17 @@ var Bounds = require('../geometry/Bounds'); * If the input path forms a concave shape, you must decompose the result into convex parts before use. * See `Bodies.fromVertices` which provides support for this. * Note that this function is not guaranteed to support complex paths (such as those with holes). + * You must load the `pathseg.js` polyfill on newer browsers. * @method pathToVertices * @param {SVGPathElement} path * @param {Number} [sampleLength=15] * @return {Vector[]} points */ Svg.pathToVertices = function(path, sampleLength) { + if (typeof window !== 'undefined' && !('SVGPathSeg' in window)) { + Common.warn('Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.'); + } + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js var i, il, total, point, segment, segments, segmentsQueue, lastSegment,