Skip to content

Instantly share code, notes, and snippets.

@YannickBochatay
YannickBochatay / normalizePath.js
Created October 19, 2011 07:37
javascript workaround for unimplemented normalizedPathSegList
/*
Transform paths with only M,L,C,Z as described by w3c
http://www.w3.org/TR/2003/REC-SVG11-20030114/paths.html#InterfaceSVGAnimatedPathData
Example :
var path = document.createElementNS("http://www.w3.org/2000/svg",tag);
path.setAttribute('d','M30 30S40 23 23 42C113,113 136,113 150,80t40,50T230,240q20 20 54 20s40 23 23 42t20,30a20,30 0,0,1 -50,-50');
path.normalizePath();