svg-path-to-polygons.js
function compare(pathData,opts={}) {
	var polys = svgPathToPolygons(pathData,opts);
	var minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity;
	polys.forEach(poly => {
		poly.forEach(pt => {
			if (pt[0]<minX) minX=pt[0];
			if (pt[1]<minY) minY=pt[1];
			if (pt[0]>maxX) maxX=pt[0];
			if (pt[1]>maxY) maxY=pt[1];
		});
	});
	let dx=maxX-minX, dy=maxY-minY;
	console.log(`
<svg xmlns="http://www.w3.org/2000/svg" width="${dx}px" height="${dy}px" viewBox="${minX} ${minY} ${dx*2} ${dy}">
<style>path,polygon,polyline { fill-opacity:0.2; stroke:black }</style>
<path d="${pathData}"/>
<g transform="translate(${dx},0)">
${polys.map(poly => `  <${poly.closed ? 'polygon' : 'polyline'} points="${poly.join(' ')}"/>`).join("\n")}
</g>
</svg>
	`.trim());
}
function compare(pathData,opts={}) {
	var polys = svgPathToPolygons(pathData,opts);
	var minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity;
	polys.forEach(poly => {
		poly.forEach(pt => {
			if (pt[0]<minX) minX=pt[0];
			if (pt[1]<minY) minY=pt[1];
			if (pt[0]>maxX) maxX=pt[0];
			if (pt[1]>maxY) maxY=pt[1];
		});
	});
	let dx=maxX-minX, dy=maxY-minY;
	console.log(`
<svg xmlns="http://www.w3.org/2000/svg" width="${dx}px" height="${dy}px" viewBox="${minX} ${minY} ${dx*2} ${dy}">
<style>path,polygon,polyline { fill-opacity:0.2; stroke:black }</style>
<path d="${pathData}"/>
<g transform="translate(${dx},0)">
${polys.map(poly => `  <${poly.closed ? 'polygon' : 'polyline'} points="${poly.join(' ')}"/>`).join("\n")}
</g>
</svg>
	`.trim());
}
function compare ( pathData , opts = { } ) { var polys = svgPathToPolygons ( pathData , opts ) ; var minX = Infinity , maxX = - Infinity , minY = Infinity , maxY = - Infinity ; polys . forEach ( poly => { poly . forEach ( pt => { if ( pt [ 0 ] < minX ) minX = pt [ 0 ] ; if ( pt [ 1 ] < minY ) minY = pt [ 1 ] ; if ( pt [ 0 ] > maxX ) maxX = pt [ 0 ] ; if ( pt [ 1 ] > maxY ) maxY = pt [ 1 ] ; } ) ; } ) ; let dx = maxX - minX , dy = maxY - minY ; console . log ( ` ${ dx } ${ dy } ${ minX } ${ minY } ${ dx * 2 } ${ dy } ${ pathData } ${ dx } ${ polys . map ( poly => ` ${ poly . closed ? 'polygon' : 'polyline' } ${ poly . join ( ' ' ) } ` ) . join ( "\n" ) } ` . trim ( ) ) ; }
OMG YOU FOUND THE SECRET UNDOCUMENTED FEATURE
OMG YOU FOUND THE SECRET UNDOCUMENTED FEATURE