From d55d9f0db00c1bb341eecaea786ca05dd2c51e95 Mon Sep 17 00:00:00 2001 From: Nicolas Froidure Date: Thu, 30 Jan 2020 08:43:30 +0100 Subject: [PATCH] fix(parser): fix parsing merged numbers with arc flags --- .npmignore | 5 +- lib/SVGPathData.js | 2 +- lib/SVGPathData.module.js | 2 +- src/SVGPathDataParser.ts | 42 ++++++++++-- tests/arc.mocha.js | 4 +- tests/realword.mocha.js | 134 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 177 insertions(+), 12 deletions(-) diff --git a/.npmignore b/.npmignore index 26c761e..e6a7a9c 100644 --- a/.npmignore +++ b/.npmignore @@ -42,4 +42,7 @@ jspm_packages # tsc generated files out -.* \ No newline at end of file +.* + +rollup.config.js +tests \ No newline at end of file diff --git a/lib/SVGPathData.js b/lib/SVGPathData.js index dbc4892..38e5678 100644 --- a/lib/SVGPathData.js +++ b/lib/SVGPathData.js @@ -12,5 +12,5 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. - ***************************************************************************** */var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])})(t,e)};function e(t,e){function a(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)}function a(t,r){var e=t[0],a=t[1];return[e*Math.cos(r)-a*Math.sin(r),e*Math.sin(r)+a*Math.cos(r)]}function n(){for(var t=[],r=0;rt.phi1&&(t.phi2-=2*i),1===t.sweepFlag&&t.phi2a)return[];if(0===a)return[[t*e/(t*t+r*r),r*e/(t*t+r*r)]];var i=Math.sqrt(a);return[[(t*e+r*i)/(t*t+r*r),(r*e-t*i)/(t*t+r*r)],[(t*e-r*i)/(t*t+r*r),(r*e+t*i)/(t*t+r*r)]]}var u=Math.PI/180;function h(t,r,e){return(1-e)*t+e*r}function c(t,r,e,a){return t+Math.cos(a/180*i)*r+Math.sin(a/180*i)*e}function m(t,r,e,a){var n=r-t,i=e-r,o=3*n+3*(a-e)-6*i,s=6*(i-n),u=3*n;return Math.abs(o)<1e-6?[-u/s]:function(t,r,e){void 0===e&&(e=1e-6);var a=t*t/4-r;if(a<-e)return[];if(a<=e)return[-t/2];var n=Math.sqrt(a);return[-t/2-n,-t/2+n]}(s/o,u/o,1e-6)}function y(t,r,e,a,n){var i=1-n;return t*(i*i*i)+r*(3*i*i*n)+e*(3*i*n*n)+a*(n*n*n)}!function(t){function r(){return p((function(t,r,e){return t.relative&&(void 0!==t.x1&&(t.x1+=r),void 0!==t.y1&&(t.y1+=e),void 0!==t.x2&&(t.x2+=r),void 0!==t.y2&&(t.y2+=e),void 0!==t.x&&(t.x+=r),void 0!==t.y&&(t.y+=e),t.relative=!1),t}))}function e(){var t=NaN,r=NaN,e=NaN,a=NaN;return p((function(n,i,o){return n.type&l.SMOOTH_CURVE_TO&&(n.type=l.CURVE_TO,t=isNaN(t)?i:t,r=isNaN(r)?o:r,n.x1=n.relative?i-t:2*i-t,n.y1=n.relative?o-r:2*o-r),n.type&l.CURVE_TO?(t=n.relative?i+n.x2:n.x2,r=n.relative?o+n.y2:n.y2):(t=NaN,r=NaN),n.type&l.SMOOTH_QUAD_TO&&(n.type=l.QUAD_TO,e=isNaN(e)?i:e,a=isNaN(a)?o:a,n.x1=n.relative?i-e:2*i-e,n.y1=n.relative?o-a:2*o-a),n.type&l.QUAD_TO?(e=n.relative?i+n.x1:n.x1,a=n.relative?o+n.y1:n.y1):(e=NaN,a=NaN),n}))}function i(){var t=NaN,r=NaN;return p((function(e,a,n){if(e.type&l.SMOOTH_QUAD_TO&&(e.type=l.QUAD_TO,t=isNaN(t)?a:t,r=isNaN(r)?n:r,e.x1=e.relative?a-t:2*a-t,e.y1=e.relative?n-r:2*n-r),e.type&l.QUAD_TO){t=e.relative?a+e.x1:e.x1,r=e.relative?n+e.y1:e.y1;var i=e.x1,o=e.y1;e.type=l.CURVE_TO,e.x1=((e.relative?0:a)+2*i)/3,e.y1=((e.relative?0:n)+2*o)/3,e.x2=(e.x+2*i)/3,e.y2=(e.y+2*o)/3}else t=NaN,r=NaN;return e}))}function p(t){var r=0,e=0,a=NaN,n=NaN;return function(i){if(isNaN(a)&&!(i.type&l.MOVE_TO))throw new Error("path must start with moveto");var o=t(i,r,e,a,n);return i.type&l.CLOSE_PATH&&(r=a,e=n),void 0!==i.x&&(r=i.relative?r+i.x:i.x),void 0!==i.y&&(e=i.relative?e+i.y:i.y),i.type&l.MOVE_TO&&(a=r,n=e),o}}function T(t,r,e,a,i,o){return n(t,r,e,a,i,o),p((function(n,s,u,h){var c=n.x1,m=n.x2,y=n.relative&&!isNaN(h),p=void 0!==n.x?n.x:y?0:s,T=void 0!==n.y?n.y:y?0:u;function O(t){return t*t}n.type&l.HORIZ_LINE_TO&&0!==r&&(n.type=l.LINE_TO,n.y=n.relative?0:u),n.type&l.VERT_LINE_TO&&0!==e&&(n.type=l.LINE_TO,n.x=n.relative?0:s),void 0!==n.x&&(n.x=n.x*t+T*e+(y?0:i)),void 0!==n.y&&(n.y=p*r+n.y*a+(y?0:o)),void 0!==n.x1&&(n.x1=n.x1*t+n.y1*e+(y?0:i)),void 0!==n.y1&&(n.y1=c*r+n.y1*a+(y?0:o)),void 0!==n.x2&&(n.x2=n.x2*t+n.y2*e+(y?0:i)),void 0!==n.y2&&(n.y2=m*r+n.y2*a+(y?0:o));var _=t*a-r*e;if(void 0!==n.xRot&&(1!==t||0!==r||0!==e||1!==a))if(0===_)delete n.rX,delete n.rY,delete n.xRot,delete n.lArcFlag,delete n.sweepFlag,n.type=l.LINE_TO;else{var f=n.xRot*Math.PI/180,v=Math.sin(f),N=Math.cos(f),E=1/O(n.rX),d=1/O(n.rY),A=O(N)*E+O(v)*d,x=2*v*N*(E-d),C=O(v)*E+O(N)*d,M=A*a*a-x*r*a+C*r*r,R=x*(t*a+r*e)-2*(A*e*a+C*t*r),S=A*e*e-x*t*e+C*t*t,I=(Math.atan2(R,M-S)+Math.PI)%Math.PI/2,g=Math.sin(I),V=Math.cos(I);n.rX=Math.abs(_)/Math.sqrt(M*O(V)+R*g*V+S*O(g)),n.rY=Math.abs(_)/Math.sqrt(M*O(g)-R*g*V+S*O(V)),n.xRot=180*I/Math.PI}return void 0!==n.sweepFlag&&0>_&&(n.sweepFlag=+!n.sweepFlag),n}))}function O(){return function(t){var r={};for(var e in t)r[e]=t[e];return r}}t.ROUND=function(t){function r(r){return Math.round(r*t)/t}return void 0===t&&(t=1e13),n(t),function(t){return void 0!==t.x1&&(t.x1=r(t.x1)),void 0!==t.y1&&(t.y1=r(t.y1)),void 0!==t.x2&&(t.x2=r(t.x2)),void 0!==t.y2&&(t.y2=r(t.y2)),void 0!==t.x&&(t.x=r(t.x)),void 0!==t.y&&(t.y=r(t.y)),void 0!==t.rX&&(t.rX=r(t.rX)),void 0!==t.rY&&(t.rY=r(t.rY)),t}},t.TO_ABS=r,t.TO_REL=function(){return p((function(t,r,e){return t.relative||(void 0!==t.x1&&(t.x1-=r),void 0!==t.y1&&(t.y1-=e),void 0!==t.x2&&(t.x2-=r),void 0!==t.y2&&(t.y2-=e),void 0!==t.x&&(t.x-=r),void 0!==t.y&&(t.y-=e),t.relative=!0),t}))},t.NORMALIZE_HVZ=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!0),p((function(a,n,i,o,s){if(isNaN(o)&&!(a.type&l.MOVE_TO))throw new Error("path must start with moveto");return r&&a.type&l.HORIZ_LINE_TO&&(a.type=l.LINE_TO,a.y=a.relative?0:i),e&&a.type&l.VERT_LINE_TO&&(a.type=l.LINE_TO,a.x=a.relative?0:n),t&&a.type&l.CLOSE_PATH&&(a.type=l.LINE_TO,a.x=a.relative?o-n:o,a.y=a.relative?s-i:s),a.type&l.ARC&&(0===a.rX||0===a.rY)&&(a.type=l.LINE_TO,delete a.rX,delete a.rY,delete a.xRot,delete a.lArcFlag,delete a.sweepFlag),a}))},t.NORMALIZE_ST=e,t.QT_TO_C=i,t.INFO=p,t.SANITIZE=function(t){void 0===t&&(t=0),n(t);var r=NaN,e=NaN,a=NaN,i=NaN;return p((function(n,o,s,u,h){var c=Math.abs,m=!1,y=0,p=0;if(n.type&l.SMOOTH_CURVE_TO&&(y=isNaN(r)?0:o-r,p=isNaN(e)?0:s-e),n.type&(l.CURVE_TO|l.SMOOTH_CURVE_TO)?(r=n.relative?o+n.x2:n.x2,e=n.relative?s+n.y2:n.y2):(r=NaN,e=NaN),n.type&l.SMOOTH_QUAD_TO?(a=isNaN(a)?o:2*o-a,i=isNaN(i)?s:2*s-i):n.type&l.QUAD_TO?(a=n.relative?o+n.x1:n.x1,i=n.relative?s+n.y1:n.y2):(a=NaN,i=NaN),n.type&l.LINE_COMMANDS||n.type&l.ARC&&(0===n.rX||0===n.rY||!n.lArcFlag)||n.type&l.CURVE_TO||n.type&l.SMOOTH_CURVE_TO||n.type&l.QUAD_TO||n.type&l.SMOOTH_QUAD_TO){var T=void 0===n.x?0:n.relative?n.x:n.x-o,O=void 0===n.y?0:n.relative?n.y:n.y-s;y=isNaN(a)?void 0===n.x1?y:n.relative?n.x:n.x1-o:a-o,p=isNaN(i)?void 0===n.y1?p:n.relative?n.y:n.y1-s:i-s;var _=void 0===n.x2?0:n.relative?n.x:n.x2-o,f=void 0===n.y2?0:n.relative?n.y:n.y2-s;c(T)<=t&&c(O)<=t&&c(y)<=t&&c(p)<=t&&c(_)<=t&&c(f)<=t&&(m=!0)}return n.type&l.CLOSE_PATH&&c(o-u)<=t&&c(s-h)<=t&&(m=!0),m?[]:n}))},t.MATRIX=T,t.ROTATE=function(t,r,e){void 0===r&&(r=0),void 0===e&&(e=0),n(t,r,e);var a=Math.sin(t),i=Math.cos(t);return T(i,a,-a,i,r-r*i+e*a,e-r*a-e*i)},t.TRANSLATE=function(t,r){return void 0===r&&(r=0),n(t,r),T(1,0,0,1,t,r)},t.SCALE=function(t,r){return void 0===r&&(r=t),n(t,r),T(t,0,0,r,0,0)},t.SKEW_X=function(t){return n(t),T(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return n(t),T(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(1,0,0,-1,0,t)},t.A_TO_C=function(){return p((function(t,r,e){return l.ARC===t.type?function(t,r,e){var n,i,s,c;t.cX||o(t,r,e);for(var m=Math.min(t.phi1,t.phi2),y=Math.max(t.phi1,t.phi2)-m,p=Math.ceil(y/90),T=new Array(p),O=r,_=e,f=0;fh.maxX&&(h.maxX=t),th.maxY&&(h.maxY=t),tU&&T(y(e,p.x1,p.x2,p.x,U))}for(var v=0,N=m(i,p.y1,p.y2,p.y);vU&&O(y(i,p.y1,p.y2,p.y,U))}}if(p.type&l.ARC){T(p.x),O(p.y),o(p,e,i);for(var E=p.xRot/180*Math.PI,d=Math.cos(E)*p.rX,A=Math.sin(E)*p.rX,x=-Math.sin(E)*p.rY,C=Math.cos(E)*p.rY,M=p.phi1p.phi2?[p.phi2+360,p.phi1+360]:[p.phi2,p.phi1],R=M[0],S=M[1],I=function(t){var r=t[0],e=t[1],a=180*Math.atan2(e,r)/Math.PI;return aR&&UR&&Uo)throw new SyntaxError('Expected positive number, got "'+o+'" at index "'+n+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+n+'"');this.curArgs.push(o),this.curArgs.length===N[this.curCommandType]&&(l.HORIZ_LINE_TO===this.curCommandType?a({type:l.HORIZ_LINE_TO,relative:this.curCommandRelative,x:o}):l.VERT_LINE_TO===this.curCommandType?a({type:l.VERT_LINE_TO,relative:this.curCommandRelative,y:o}):this.curCommandType===l.MOVE_TO||this.curCommandType===l.LINE_TO||this.curCommandType===l.SMOOTH_QUAD_TO?(a({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),l.MOVE_TO===this.curCommandType&&(this.curCommandType=l.LINE_TO)):this.curCommandType===l.CURVE_TO?a({type:l.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===l.SMOOTH_CURVE_TO?a({type:l.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.QUAD_TO?a({type:l.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.ARC&&a({type:l.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!_(i))if(","===i&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==i&&"-"!==i&&"."!==i){if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+n+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+i+'" at index '+n+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==i&&"Z"!==i)if("h"===i||"H"===i)this.curCommandType=l.HORIZ_LINE_TO,this.curCommandRelative="h"===i;else if("v"===i||"V"===i)this.curCommandType=l.VERT_LINE_TO,this.curCommandRelative="v"===i;else if("m"===i||"M"===i)this.curCommandType=l.MOVE_TO,this.curCommandRelative="m"===i;else if("l"===i||"L"===i)this.curCommandType=l.LINE_TO,this.curCommandRelative="l"===i;else if("c"===i||"C"===i)this.curCommandType=l.CURVE_TO,this.curCommandRelative="c"===i;else if("s"===i||"S"===i)this.curCommandType=l.SMOOTH_CURVE_TO,this.curCommandRelative="s"===i;else if("q"===i||"Q"===i)this.curCommandType=l.QUAD_TO,this.curCommandRelative="q"===i;else if("t"===i||"T"===i)this.curCommandType=l.SMOOTH_QUAD_TO,this.curCommandRelative="t"===i;else{if("a"!==i&&"A"!==i)throw new SyntaxError('Unexpected character "'+i+'" at index '+n+".");this.curCommandType=l.ARC,this.curCommandRelative="a"===i}else r.push({type:l.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=i,this.curNumberHasDecimal="."===i}else this.curNumber+=i,this.curNumberHasDecimal=!0;else this.curNumber+=i;else this.curNumber+=i,this.curNumberHasExp=!0}return r},r.prototype.transform=function(t){return Object.create(this,{parse:{value:function(r,e){void 0===e&&(e=[]);for(var a=0,n=Object.getPrototypeOf(this).parse.call(this,r);at.phi1&&(t.phi2-=2*o),1===t.sweepFlag&&t.phi2a)return[];if(0===a)return[[t*e/(t*t+r*r),r*e/(t*t+r*r)]];var i=Math.sqrt(a);return[[(t*e+r*i)/(t*t+r*r),(r*e-t*i)/(t*t+r*r)],[(t*e-r*i)/(t*t+r*r),(r*e+t*i)/(t*t+r*r)]]}var h=Math.PI/180;function c(t,r,e){return(1-e)*t+e*r}function m(t,r,e,a){return t+Math.cos(a/180*o)*r+Math.sin(a/180*o)*e}function y(t,r,e,a){var i=r-t,n=e-r,o=3*i+3*(a-e)-6*n,s=6*(n-i),u=3*i;return Math.abs(o)<1e-6?[-u/s]:function(t,r,e){void 0===e&&(e=1e-6);var a=t*t/4-r;if(a<-e)return[];if(a<=e)return[-t/2];var i=Math.sqrt(a);return[-t/2-i,-t/2+i]}(s/o,u/o,1e-6)}function p(t,r,e,a,i){var n=1-i;return t*(n*n*n)+r*(3*n*n*i)+e*(3*n*i*i)+a*(i*i*i)}!function(t){function r(){return o((function(t,r,e){return t.relative&&(void 0!==t.x1&&(t.x1+=r),void 0!==t.y1&&(t.y1+=e),void 0!==t.x2&&(t.x2+=r),void 0!==t.y2&&(t.y2+=e),void 0!==t.x&&(t.x+=r),void 0!==t.y&&(t.y+=e),t.relative=!1),t}))}function e(){var t=NaN,r=NaN,e=NaN,a=NaN;return o((function(i,n,o){return i.type&_.SMOOTH_CURVE_TO&&(i.type=_.CURVE_TO,t=isNaN(t)?n:t,r=isNaN(r)?o:r,i.x1=i.relative?n-t:2*n-t,i.y1=i.relative?o-r:2*o-r),i.type&_.CURVE_TO?(t=i.relative?n+i.x2:i.x2,r=i.relative?o+i.y2:i.y2):(t=NaN,r=NaN),i.type&_.SMOOTH_QUAD_TO&&(i.type=_.QUAD_TO,e=isNaN(e)?n:e,a=isNaN(a)?o:a,i.x1=i.relative?n-e:2*n-e,i.y1=i.relative?o-a:2*o-a),i.type&_.QUAD_TO?(e=i.relative?n+i.x1:i.x1,a=i.relative?o+i.y1:i.y1):(e=NaN,a=NaN),i}))}function a(){var t=NaN,r=NaN;return o((function(e,a,i){if(e.type&_.SMOOTH_QUAD_TO&&(e.type=_.QUAD_TO,t=isNaN(t)?a:t,r=isNaN(r)?i:r,e.x1=e.relative?a-t:2*a-t,e.y1=e.relative?i-r:2*i-r),e.type&_.QUAD_TO){t=e.relative?a+e.x1:e.x1,r=e.relative?i+e.y1:e.y1;var n=e.x1,o=e.y1;e.type=_.CURVE_TO,e.x1=((e.relative?0:a)+2*n)/3,e.y1=((e.relative?0:i)+2*o)/3,e.x2=(e.x+2*n)/3,e.y2=(e.y+2*o)/3}else t=NaN,r=NaN;return e}))}function o(t){var r=0,e=0,a=NaN,i=NaN;return function(n){if(isNaN(a)&&!(n.type&_.MOVE_TO))throw new Error("path must start with moveto");var o=t(n,r,e,a,i);return n.type&_.CLOSE_PATH&&(r=a,e=i),void 0!==n.x&&(r=n.relative?r+n.x:n.x),void 0!==n.y&&(e=n.relative?e+n.y:n.y),n.type&_.MOVE_TO&&(a=r,i=e),o}}function T(t,r,e,a,i,s){return n(t,r,e,a,i,s),o((function(n,o,u,h){var c=n.x1,m=n.x2,y=n.relative&&!isNaN(h),p=void 0!==n.x?n.x:y?0:o,T=void 0!==n.y?n.y:y?0:u;function f(t){return t*t}n.type&_.HORIZ_LINE_TO&&0!==r&&(n.type=_.LINE_TO,n.y=n.relative?0:u),n.type&_.VERT_LINE_TO&&0!==e&&(n.type=_.LINE_TO,n.x=n.relative?0:o),void 0!==n.x&&(n.x=n.x*t+T*e+(y?0:i)),void 0!==n.y&&(n.y=p*r+n.y*a+(y?0:s)),void 0!==n.x1&&(n.x1=n.x1*t+n.y1*e+(y?0:i)),void 0!==n.y1&&(n.y1=c*r+n.y1*a+(y?0:s)),void 0!==n.x2&&(n.x2=n.x2*t+n.y2*e+(y?0:i)),void 0!==n.y2&&(n.y2=m*r+n.y2*a+(y?0:s));var O=t*a-r*e;if(void 0!==n.xRot&&(1!==t||0!==r||0!==e||1!==a))if(0===O)delete n.rX,delete n.rY,delete n.xRot,delete n.lArcFlag,delete n.sweepFlag,n.type=_.LINE_TO;else{var v=n.xRot*Math.PI/180,l=Math.sin(v),N=Math.cos(v),d=1/f(n.rX),x=1/f(n.rY),A=f(N)*d+f(l)*x,E=2*l*N*(d-x),C=f(l)*d+f(N)*x,M=A*a*a-E*r*a+C*r*r,R=E*(t*a+r*e)-2*(A*e*a+C*t*r),S=A*e*e-E*t*e+C*t*t,g=(Math.atan2(R,M-S)+Math.PI)%Math.PI/2,I=Math.sin(g),V=Math.cos(g);n.rX=Math.abs(O)/Math.sqrt(M*f(V)+R*I*V+S*f(I)),n.rY=Math.abs(O)/Math.sqrt(M*f(I)-R*I*V+S*f(V)),n.xRot=180*g/Math.PI}return void 0!==n.sweepFlag&&0>O&&(n.sweepFlag=+!n.sweepFlag),n}))}function f(){return function(t){var r={};for(var e in t)r[e]=t[e];return r}}t.ROUND=function(t){function r(r){return Math.round(r*t)/t}return void 0===t&&(t=1e13),n(t),function(t){return void 0!==t.x1&&(t.x1=r(t.x1)),void 0!==t.y1&&(t.y1=r(t.y1)),void 0!==t.x2&&(t.x2=r(t.x2)),void 0!==t.y2&&(t.y2=r(t.y2)),void 0!==t.x&&(t.x=r(t.x)),void 0!==t.y&&(t.y=r(t.y)),void 0!==t.rX&&(t.rX=r(t.rX)),void 0!==t.rY&&(t.rY=r(t.rY)),t}},t.TO_ABS=r,t.TO_REL=function(){return o((function(t,r,e){return t.relative||(void 0!==t.x1&&(t.x1-=r),void 0!==t.y1&&(t.y1-=e),void 0!==t.x2&&(t.x2-=r),void 0!==t.y2&&(t.y2-=e),void 0!==t.x&&(t.x-=r),void 0!==t.y&&(t.y-=e),t.relative=!0),t}))},t.NORMALIZE_HVZ=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!0),o((function(a,i,n,o,s){if(isNaN(o)&&!(a.type&_.MOVE_TO))throw new Error("path must start with moveto");return r&&a.type&_.HORIZ_LINE_TO&&(a.type=_.LINE_TO,a.y=a.relative?0:n),e&&a.type&_.VERT_LINE_TO&&(a.type=_.LINE_TO,a.x=a.relative?0:i),t&&a.type&_.CLOSE_PATH&&(a.type=_.LINE_TO,a.x=a.relative?o-i:o,a.y=a.relative?s-n:s),a.type&_.ARC&&(0===a.rX||0===a.rY)&&(a.type=_.LINE_TO,delete a.rX,delete a.rY,delete a.xRot,delete a.lArcFlag,delete a.sweepFlag),a}))},t.NORMALIZE_ST=e,t.QT_TO_C=a,t.INFO=o,t.SANITIZE=function(t){void 0===t&&(t=0),n(t);var r=NaN,e=NaN,a=NaN,i=NaN;return o((function(n,o,s,u,h){var c=Math.abs,m=!1,y=0,p=0;if(n.type&_.SMOOTH_CURVE_TO&&(y=isNaN(r)?0:o-r,p=isNaN(e)?0:s-e),n.type&(_.CURVE_TO|_.SMOOTH_CURVE_TO)?(r=n.relative?o+n.x2:n.x2,e=n.relative?s+n.y2:n.y2):(r=NaN,e=NaN),n.type&_.SMOOTH_QUAD_TO?(a=isNaN(a)?o:2*o-a,i=isNaN(i)?s:2*s-i):n.type&_.QUAD_TO?(a=n.relative?o+n.x1:n.x1,i=n.relative?s+n.y1:n.y2):(a=NaN,i=NaN),n.type&_.LINE_COMMANDS||n.type&_.ARC&&(0===n.rX||0===n.rY||!n.lArcFlag)||n.type&_.CURVE_TO||n.type&_.SMOOTH_CURVE_TO||n.type&_.QUAD_TO||n.type&_.SMOOTH_QUAD_TO){var T=void 0===n.x?0:n.relative?n.x:n.x-o,f=void 0===n.y?0:n.relative?n.y:n.y-s;y=isNaN(a)?void 0===n.x1?y:n.relative?n.x:n.x1-o:a-o,p=isNaN(i)?void 0===n.y1?p:n.relative?n.y:n.y1-s:i-s;var O=void 0===n.x2?0:n.relative?n.x:n.x2-o,v=void 0===n.y2?0:n.relative?n.y:n.y2-s;c(T)<=t&&c(f)<=t&&c(y)<=t&&c(p)<=t&&c(O)<=t&&c(v)<=t&&(m=!0)}return n.type&_.CLOSE_PATH&&c(o-u)<=t&&c(s-h)<=t&&(m=!0),m?[]:n}))},t.MATRIX=T,t.ROTATE=function(t,r,e){void 0===r&&(r=0),void 0===e&&(e=0),n(t,r,e);var a=Math.sin(t),i=Math.cos(t);return T(i,a,-a,i,r-r*i+e*a,e-r*a-e*i)},t.TRANSLATE=function(t,r){return void 0===r&&(r=0),n(t,r),T(1,0,0,1,t,r)},t.SCALE=function(t,r){return void 0===r&&(r=t),n(t,r),T(t,0,0,r,0,0)},t.SKEW_X=function(t){return n(t),T(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return n(t),T(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(1,0,0,-1,0,t)},t.A_TO_C=function(){return o((function(t,r,e){return _.ARC===t.type?function(t,r,e){var a,n,o,u;t.cX||s(t,r,e);for(var m=Math.min(t.phi1,t.phi2),y=Math.max(t.phi1,t.phi2)-m,p=Math.ceil(y/90),T=new Array(p),f=r,O=e,v=0;vc.maxX&&(c.maxX=t),tc.maxY&&(c.maxY=t),tH&&T(p(e,o.x1,o.x2,o.x,H))}for(var l=0,N=y(a,o.y1,o.y2,o.y);lH&&f(p(a,o.y1,o.y2,o.y,H))}}if(o.type&_.ARC){T(o.x),f(o.y),s(o,e,a);for(var d=o.xRot/180*Math.PI,x=Math.cos(d)*o.rX,A=Math.sin(d)*o.rX,E=-Math.sin(d)*o.rY,C=Math.cos(d)*o.rY,M=o.phi1o.phi2?[o.phi2+360,o.phi1+360]:[o.phi2,o.phi1],R=M[0],S=M[1],g=function(t){var r=t[0],e=t[1],a=180*Math.atan2(e,r)/Math.PI;return aR&&HR&&Hu)throw new SyntaxError('Expected positive number, got "'+u+'" at index "'+i+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+i+'"');this.curArgs.push(u),this.curArgs.length===N[this.curCommandType]&&(_.HORIZ_LINE_TO===this.curCommandType?a({type:_.HORIZ_LINE_TO,relative:this.curCommandRelative,x:u}):_.VERT_LINE_TO===this.curCommandType?a({type:_.VERT_LINE_TO,relative:this.curCommandRelative,y:u}):this.curCommandType===_.MOVE_TO||this.curCommandType===_.LINE_TO||this.curCommandType===_.SMOOTH_QUAD_TO?(a({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),_.MOVE_TO===this.curCommandType&&(this.curCommandType=_.LINE_TO)):this.curCommandType===_.CURVE_TO?a({type:_.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===_.SMOOTH_CURVE_TO?a({type:_.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.QUAD_TO?a({type:_.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.ARC&&a({type:_.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!O(n))if(","===n&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==n&&"-"!==n&&"."!==n)if(s)this.curNumber=n,this.curNumberHasDecimal=!1;else{if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+i+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+n+'" at index '+i+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==n&&"Z"!==n)if("h"===n||"H"===n)this.curCommandType=_.HORIZ_LINE_TO,this.curCommandRelative="h"===n;else if("v"===n||"V"===n)this.curCommandType=_.VERT_LINE_TO,this.curCommandRelative="v"===n;else if("m"===n||"M"===n)this.curCommandType=_.MOVE_TO,this.curCommandRelative="m"===n;else if("l"===n||"L"===n)this.curCommandType=_.LINE_TO,this.curCommandRelative="l"===n;else if("c"===n||"C"===n)this.curCommandType=_.CURVE_TO,this.curCommandRelative="c"===n;else if("s"===n||"S"===n)this.curCommandType=_.SMOOTH_CURVE_TO,this.curCommandRelative="s"===n;else if("q"===n||"Q"===n)this.curCommandType=_.QUAD_TO,this.curCommandRelative="q"===n;else if("t"===n||"T"===n)this.curCommandType=_.SMOOTH_QUAD_TO,this.curCommandRelative="t"===n;else{if("a"!==n&&"A"!==n)throw new SyntaxError('Unexpected character "'+n+'" at index '+i+".");this.curCommandType=_.ARC,this.curCommandRelative="a"===n}else r.push({type:_.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=n,this.curNumberHasDecimal="."===n}else this.curNumber+=n,this.curNumberHasDecimal=!0;else this.curNumber+=n;else this.curNumber+=n,this.curNumberHasExp=!0;else this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp}return r},r.prototype.transform=function(t){return Object.create(this,{parse:{value:function(r,e){void 0===e&&(e=[]);for(var a=0,i=Object.getPrototypeOf(this).parse.call(this,r);at.phi1&&(t.phi2-=2*a),1===t.sweepFlag&&t.phi2a)return[];if(0===a)return[[t*e/(t*t+r*r),r*e/(t*t+r*r)]];var n=Math.sqrt(a);return[[(t*e+r*n)/(t*t+r*r),(r*e-t*n)/(t*t+r*r)],[(t*e-r*n)/(t*t+r*r),(r*e+t*n)/(t*t+r*r)]]}var s,u=Math.PI/180;function c(t,r,e){return(1-e)*t+e*r}function h(t,r,e,i){return t+Math.cos(i/180*a)*r+Math.sin(i/180*a)*e}function y(t,r,e,i){var a=r-t,n=e-r,o=3*a+3*(i-e)-6*n,s=6*(n-a),u=3*a;return Math.abs(o)<1e-6?[-u/s]:function(t,r,e){void 0===e&&(e=1e-6);var i=t*t/4-r;if(i<-e)return[];if(i<=e)return[-t/2];var a=Math.sqrt(i);return[-t/2-a,-t/2+a]}(s/o,u/o,1e-6)}function p(t,r,e,i,a){var n=1-a;return t*(n*n*n)+r*(3*n*n*a)+e*(3*n*a*a)+i*(a*a*a)}!function(t){function r(){return O((function(t,r,e){return t.relative&&(void 0!==t.x1&&(t.x1+=r),void 0!==t.y1&&(t.y1+=e),void 0!==t.x2&&(t.x2+=r),void 0!==t.y2&&(t.y2+=e),void 0!==t.x&&(t.x+=r),void 0!==t.y&&(t.y+=e),t.relative=!1),t}))}function a(){var t=NaN,r=NaN,e=NaN,i=NaN;return O((function(a,n,o){return a.type&l.SMOOTH_CURVE_TO&&(a.type=l.CURVE_TO,t=isNaN(t)?n:t,r=isNaN(r)?o:r,a.x1=a.relative?n-t:2*n-t,a.y1=a.relative?o-r:2*o-r),a.type&l.CURVE_TO?(t=a.relative?n+a.x2:a.x2,r=a.relative?o+a.y2:a.y2):(t=NaN,r=NaN),a.type&l.SMOOTH_QUAD_TO&&(a.type=l.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,a.x1=a.relative?n-e:2*n-e,a.y1=a.relative?o-i:2*o-i),a.type&l.QUAD_TO?(e=a.relative?n+a.x1:a.x1,i=a.relative?o+a.y1:a.y1):(e=NaN,i=NaN),a}))}function s(){var t=NaN,r=NaN;return O((function(e,i,a){if(e.type&l.SMOOTH_QUAD_TO&&(e.type=l.QUAD_TO,t=isNaN(t)?i:t,r=isNaN(r)?a:r,e.x1=e.relative?i-t:2*i-t,e.y1=e.relative?a-r:2*a-r),e.type&l.QUAD_TO){t=e.relative?i+e.x1:e.x1,r=e.relative?a+e.y1:e.y1;var n=e.x1,o=e.y1;e.type=l.CURVE_TO,e.x1=((e.relative?0:i)+2*n)/3,e.y1=((e.relative?0:a)+2*o)/3,e.x2=(e.x+2*n)/3,e.y2=(e.y+2*o)/3}else t=NaN,r=NaN;return e}))}function O(t){var r=0,e=0,i=NaN,a=NaN;return function(n){if(isNaN(i)&&!(n.type&l.MOVE_TO))throw new Error("path must start with moveto");var o=t(n,r,e,i,a);return n.type&l.CLOSE_PATH&&(r=i,e=a),void 0!==n.x&&(r=n.relative?r+n.x:n.x),void 0!==n.y&&(e=n.relative?e+n.y:n.y),n.type&l.MOVE_TO&&(i=r,a=e),o}}function m(t,r,e,a,n,o){return i(t,r,e,a,n,o),O((function(i,s,u,c){var h=i.x1,y=i.x2,p=i.relative&&!isNaN(c),O=void 0!==i.x?i.x:p?0:s,m=void 0!==i.y?i.y:p?0:u;function T(t){return t*t}i.type&l.HORIZ_LINE_TO&&0!==r&&(i.type=l.LINE_TO,i.y=i.relative?0:u),i.type&l.VERT_LINE_TO&&0!==e&&(i.type=l.LINE_TO,i.x=i.relative?0:s),void 0!==i.x&&(i.x=i.x*t+m*e+(p?0:n)),void 0!==i.y&&(i.y=O*r+i.y*a+(p?0:o)),void 0!==i.x1&&(i.x1=i.x1*t+i.y1*e+(p?0:n)),void 0!==i.y1&&(i.y1=h*r+i.y1*a+(p?0:o)),void 0!==i.x2&&(i.x2=i.x2*t+i.y2*e+(p?0:n)),void 0!==i.y2&&(i.y2=y*r+i.y2*a+(p?0:o));var _=t*a-r*e;if(void 0!==i.xRot&&(1!==t||0!==r||0!==e||1!==a))if(0===_)delete i.rX,delete i.rY,delete i.xRot,delete i.lArcFlag,delete i.sweepFlag,i.type=l.LINE_TO;else{var v=i.xRot*Math.PI/180,f=Math.sin(v),N=Math.cos(v),E=1/T(i.rX),A=1/T(i.rY),d=T(N)*E+T(f)*A,x=2*f*N*(E-A),C=T(f)*E+T(N)*A,M=d*a*a-x*r*a+C*r*r,R=x*(t*a+r*e)-2*(d*e*a+C*t*r),I=d*e*e-x*t*e+C*t*t,g=(Math.atan2(R,M-I)+Math.PI)%Math.PI/2,S=Math.sin(g),L=Math.cos(g);i.rX=Math.abs(_)/Math.sqrt(M*T(L)+R*S*L+I*T(S)),i.rY=Math.abs(_)/Math.sqrt(M*T(S)-R*S*L+I*T(L)),i.xRot=180*g/Math.PI}return void 0!==i.sweepFlag&&0>_&&(i.sweepFlag=+!i.sweepFlag),i}))}function T(){return function(t){var r={};for(var e in t)r[e]=t[e];return r}}t.ROUND=function(t){function r(r){return Math.round(r*t)/t}return void 0===t&&(t=1e13),i(t),function(t){return void 0!==t.x1&&(t.x1=r(t.x1)),void 0!==t.y1&&(t.y1=r(t.y1)),void 0!==t.x2&&(t.x2=r(t.x2)),void 0!==t.y2&&(t.y2=r(t.y2)),void 0!==t.x&&(t.x=r(t.x)),void 0!==t.y&&(t.y=r(t.y)),void 0!==t.rX&&(t.rX=r(t.rX)),void 0!==t.rY&&(t.rY=r(t.rY)),t}},t.TO_ABS=r,t.TO_REL=function(){return O((function(t,r,e){return t.relative||(void 0!==t.x1&&(t.x1-=r),void 0!==t.y1&&(t.y1-=e),void 0!==t.x2&&(t.x2-=r),void 0!==t.y2&&(t.y2-=e),void 0!==t.x&&(t.x-=r),void 0!==t.y&&(t.y-=e),t.relative=!0),t}))},t.NORMALIZE_HVZ=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!0),O((function(i,a,n,o,s){if(isNaN(o)&&!(i.type&l.MOVE_TO))throw new Error("path must start with moveto");return r&&i.type&l.HORIZ_LINE_TO&&(i.type=l.LINE_TO,i.y=i.relative?0:n),e&&i.type&l.VERT_LINE_TO&&(i.type=l.LINE_TO,i.x=i.relative?0:a),t&&i.type&l.CLOSE_PATH&&(i.type=l.LINE_TO,i.x=i.relative?o-a:o,i.y=i.relative?s-n:s),i.type&l.ARC&&(0===i.rX||0===i.rY)&&(i.type=l.LINE_TO,delete i.rX,delete i.rY,delete i.xRot,delete i.lArcFlag,delete i.sweepFlag),i}))},t.NORMALIZE_ST=a,t.QT_TO_C=s,t.INFO=O,t.SANITIZE=function(t){void 0===t&&(t=0),i(t);var r=NaN,e=NaN,a=NaN,n=NaN;return O((function(i,o,s,u,c){var h=Math.abs,y=!1,p=0,O=0;if(i.type&l.SMOOTH_CURVE_TO&&(p=isNaN(r)?0:o-r,O=isNaN(e)?0:s-e),i.type&(l.CURVE_TO|l.SMOOTH_CURVE_TO)?(r=i.relative?o+i.x2:i.x2,e=i.relative?s+i.y2:i.y2):(r=NaN,e=NaN),i.type&l.SMOOTH_QUAD_TO?(a=isNaN(a)?o:2*o-a,n=isNaN(n)?s:2*s-n):i.type&l.QUAD_TO?(a=i.relative?o+i.x1:i.x1,n=i.relative?s+i.y1:i.y2):(a=NaN,n=NaN),i.type&l.LINE_COMMANDS||i.type&l.ARC&&(0===i.rX||0===i.rY||!i.lArcFlag)||i.type&l.CURVE_TO||i.type&l.SMOOTH_CURVE_TO||i.type&l.QUAD_TO||i.type&l.SMOOTH_QUAD_TO){var m=void 0===i.x?0:i.relative?i.x:i.x-o,T=void 0===i.y?0:i.relative?i.y:i.y-s;p=isNaN(a)?void 0===i.x1?p:i.relative?i.x:i.x1-o:a-o,O=isNaN(n)?void 0===i.y1?O:i.relative?i.y:i.y1-s:n-s;var _=void 0===i.x2?0:i.relative?i.x:i.x2-o,v=void 0===i.y2?0:i.relative?i.y:i.y2-s;h(m)<=t&&h(T)<=t&&h(p)<=t&&h(O)<=t&&h(_)<=t&&h(v)<=t&&(y=!0)}return i.type&l.CLOSE_PATH&&h(o-u)<=t&&h(s-c)<=t&&(y=!0),y?[]:i}))},t.MATRIX=m,t.ROTATE=function(t,r,e){void 0===r&&(r=0),void 0===e&&(e=0),i(t,r,e);var a=Math.sin(t),n=Math.cos(t);return m(n,a,-a,n,r-r*n+e*a,e-r*a-e*n)},t.TRANSLATE=function(t,r){return void 0===r&&(r=0),i(t,r),m(1,0,0,1,t,r)},t.SCALE=function(t,r){return void 0===r&&(r=t),i(t,r),m(t,0,0,r,0,0)},t.SKEW_X=function(t){return i(t),m(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return i(t),m(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),i(t),m(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),i(t),m(1,0,0,-1,0,t)},t.A_TO_C=function(){return O((function(t,r,i){return l.ARC===t.type?function(t,r,i){var a,o,s,h;t.cX||n(t,r,i);for(var y=Math.min(t.phi1,t.phi2),p=Math.max(t.phi1,t.phi2)-y,O=Math.ceil(p/90),m=new Array(O),T=r,_=i,v=0;vc.maxX&&(c.maxX=t),tc.maxY&&(c.maxY=t),tV&&m(p(a,O.x1,O.x2,O.x,V))}for(var f=0,N=y(s,O.y1,O.y2,O.y);fV&&T(p(s,O.y1,O.y2,O.y,V))}}if(O.type&l.ARC){m(O.x),T(O.y),n(O,a,s);for(var E=O.xRot/180*Math.PI,A=Math.cos(E)*O.rX,d=Math.sin(E)*O.rX,x=-Math.sin(E)*O.rY,C=Math.cos(E)*O.rY,M=O.phi1O.phi2?[O.phi2+360,O.phi1+360]:[O.phi2,O.phi1],R=M[0],I=M[1],g=function(t){var r=t[0],e=t[1],i=180*Math.atan2(e,r)/Math.PI;return iR&&VR&&Vo)throw new SyntaxError('Expected positive number, got "'+o+'" at index "'+a+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+a+'"');this.curArgs.push(o),this.curArgs.length===N[this.curCommandType]&&(l.HORIZ_LINE_TO===this.curCommandType?i({type:l.HORIZ_LINE_TO,relative:this.curCommandRelative,x:o}):l.VERT_LINE_TO===this.curCommandType?i({type:l.VERT_LINE_TO,relative:this.curCommandRelative,y:o}):this.curCommandType===l.MOVE_TO||this.curCommandType===l.LINE_TO||this.curCommandType===l.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),l.MOVE_TO===this.curCommandType&&(this.curCommandType=l.LINE_TO)):this.curCommandType===l.CURVE_TO?i({type:l.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===l.SMOOTH_CURVE_TO?i({type:l.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.QUAD_TO?i({type:l.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.ARC&&i({type:l.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!_(n))if(","===n&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==n&&"-"!==n&&"."!==n){if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+a+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+n+'" at index '+a+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==n&&"Z"!==n)if("h"===n||"H"===n)this.curCommandType=l.HORIZ_LINE_TO,this.curCommandRelative="h"===n;else if("v"===n||"V"===n)this.curCommandType=l.VERT_LINE_TO,this.curCommandRelative="v"===n;else if("m"===n||"M"===n)this.curCommandType=l.MOVE_TO,this.curCommandRelative="m"===n;else if("l"===n||"L"===n)this.curCommandType=l.LINE_TO,this.curCommandRelative="l"===n;else if("c"===n||"C"===n)this.curCommandType=l.CURVE_TO,this.curCommandRelative="c"===n;else if("s"===n||"S"===n)this.curCommandType=l.SMOOTH_CURVE_TO,this.curCommandRelative="s"===n;else if("q"===n||"Q"===n)this.curCommandType=l.QUAD_TO,this.curCommandRelative="q"===n;else if("t"===n||"T"===n)this.curCommandType=l.SMOOTH_QUAD_TO,this.curCommandRelative="t"===n;else{if("a"!==n&&"A"!==n)throw new SyntaxError('Unexpected character "'+n+'" at index '+a+".");this.curCommandType=l.ARC,this.curCommandRelative="a"===n}else r.push({type:l.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=n,this.curNumberHasDecimal="."===n}else this.curNumber+=n,this.curNumberHasDecimal=!0;else this.curNumber+=n;else this.curNumber+=n,this.curNumberHasExp=!0}return r},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(r,e){void 0===e&&(e=[]);for(var i=0,a=Object.getPrototypeOf(this).parse.call(this,r);it.phi1&&(t.phi2-=2*n),1===t.sweepFlag&&t.phi2i)return[];if(0===i)return[[t*e/(t*t+r*r),r*e/(t*t+r*r)]];var n=Math.sqrt(i);return[[(t*e+r*n)/(t*t+r*r),(r*e-t*n)/(t*t+r*r)],[(t*e-r*n)/(t*t+r*r),(r*e+t*n)/(t*t+r*r)]]}var u,h=Math.PI/180;function c(t,r,e){return(1-e)*t+e*r}function y(t,r,e,i){return t+Math.cos(i/180*n)*r+Math.sin(i/180*n)*e}function p(t,r,e,i){var a=r-t,n=e-r,o=3*a+3*(i-e)-6*n,s=6*(n-a),u=3*a;return Math.abs(o)<1e-6?[-u/s]:function(t,r,e){void 0===e&&(e=1e-6);var i=t*t/4-r;if(i<-e)return[];if(i<=e)return[-t/2];var a=Math.sqrt(i);return[-t/2-a,-t/2+a]}(s/o,u/o,1e-6)}function m(t,r,e,i,a){var n=1-a;return t*(n*n*n)+r*(3*n*n*a)+e*(3*n*a*a)+i*(a*a*a)}!function(t){function r(){return u((function(t,r,e){return t.relative&&(void 0!==t.x1&&(t.x1+=r),void 0!==t.y1&&(t.y1+=e),void 0!==t.x2&&(t.x2+=r),void 0!==t.y2&&(t.y2+=e),void 0!==t.x&&(t.x+=r),void 0!==t.y&&(t.y+=e),t.relative=!1),t}))}function e(){var t=NaN,r=NaN,e=NaN,i=NaN;return u((function(a,n,o){return a.type&f.SMOOTH_CURVE_TO&&(a.type=f.CURVE_TO,t=isNaN(t)?n:t,r=isNaN(r)?o:r,a.x1=a.relative?n-t:2*n-t,a.y1=a.relative?o-r:2*o-r),a.type&f.CURVE_TO?(t=a.relative?n+a.x2:a.x2,r=a.relative?o+a.y2:a.y2):(t=NaN,r=NaN),a.type&f.SMOOTH_QUAD_TO&&(a.type=f.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,a.x1=a.relative?n-e:2*n-e,a.y1=a.relative?o-i:2*o-i),a.type&f.QUAD_TO?(e=a.relative?n+a.x1:a.x1,i=a.relative?o+a.y1:a.y1):(e=NaN,i=NaN),a}))}function n(){var t=NaN,r=NaN;return u((function(e,i,a){if(e.type&f.SMOOTH_QUAD_TO&&(e.type=f.QUAD_TO,t=isNaN(t)?i:t,r=isNaN(r)?a:r,e.x1=e.relative?i-t:2*i-t,e.y1=e.relative?a-r:2*a-r),e.type&f.QUAD_TO){t=e.relative?i+e.x1:e.x1,r=e.relative?a+e.y1:e.y1;var n=e.x1,o=e.y1;e.type=f.CURVE_TO,e.x1=((e.relative?0:i)+2*n)/3,e.y1=((e.relative?0:a)+2*o)/3,e.x2=(e.x+2*n)/3,e.y2=(e.y+2*o)/3}else t=NaN,r=NaN;return e}))}function u(t){var r=0,e=0,i=NaN,a=NaN;return function(n){if(isNaN(i)&&!(n.type&f.MOVE_TO))throw new Error("path must start with moveto");var o=t(n,r,e,i,a);return n.type&f.CLOSE_PATH&&(r=i,e=a),void 0!==n.x&&(r=n.relative?r+n.x:n.x),void 0!==n.y&&(e=n.relative?e+n.y:n.y),n.type&f.MOVE_TO&&(i=r,a=e),o}}function O(t,r,e,i,n,o){return a(t,r,e,i,n,o),u((function(a,s,u,h){var c=a.x1,y=a.x2,p=a.relative&&!isNaN(h),m=void 0!==a.x?a.x:p?0:s,O=void 0!==a.y?a.y:p?0:u;function T(t){return t*t}a.type&f.HORIZ_LINE_TO&&0!==r&&(a.type=f.LINE_TO,a.y=a.relative?0:u),a.type&f.VERT_LINE_TO&&0!==e&&(a.type=f.LINE_TO,a.x=a.relative?0:s),void 0!==a.x&&(a.x=a.x*t+O*e+(p?0:n)),void 0!==a.y&&(a.y=m*r+a.y*i+(p?0:o)),void 0!==a.x1&&(a.x1=a.x1*t+a.y1*e+(p?0:n)),void 0!==a.y1&&(a.y1=c*r+a.y1*i+(p?0:o)),void 0!==a.x2&&(a.x2=a.x2*t+a.y2*e+(p?0:n)),void 0!==a.y2&&(a.y2=y*r+a.y2*i+(p?0:o));var v=t*i-r*e;if(void 0!==a.xRot&&(1!==t||0!==r||0!==e||1!==i))if(0===v)delete a.rX,delete a.rY,delete a.xRot,delete a.lArcFlag,delete a.sweepFlag,a.type=f.LINE_TO;else{var l=a.xRot*Math.PI/180,_=Math.sin(l),N=Math.cos(l),x=1/T(a.rX),d=1/T(a.rY),A=T(N)*x+T(_)*d,E=2*_*N*(x-d),C=T(_)*x+T(N)*d,M=A*i*i-E*r*i+C*r*r,R=E*(t*i+r*e)-2*(A*e*i+C*t*r),g=A*e*e-E*t*e+C*t*t,I=(Math.atan2(R,M-g)+Math.PI)%Math.PI/2,S=Math.sin(I),L=Math.cos(I);a.rX=Math.abs(v)/Math.sqrt(M*T(L)+R*S*L+g*T(S)),a.rY=Math.abs(v)/Math.sqrt(M*T(S)-R*S*L+g*T(L)),a.xRot=180*I/Math.PI}return void 0!==a.sweepFlag&&0>v&&(a.sweepFlag=+!a.sweepFlag),a}))}function T(){return function(t){var r={};for(var e in t)r[e]=t[e];return r}}t.ROUND=function(t){function r(r){return Math.round(r*t)/t}return void 0===t&&(t=1e13),a(t),function(t){return void 0!==t.x1&&(t.x1=r(t.x1)),void 0!==t.y1&&(t.y1=r(t.y1)),void 0!==t.x2&&(t.x2=r(t.x2)),void 0!==t.y2&&(t.y2=r(t.y2)),void 0!==t.x&&(t.x=r(t.x)),void 0!==t.y&&(t.y=r(t.y)),void 0!==t.rX&&(t.rX=r(t.rX)),void 0!==t.rY&&(t.rY=r(t.rY)),t}},t.TO_ABS=r,t.TO_REL=function(){return u((function(t,r,e){return t.relative||(void 0!==t.x1&&(t.x1-=r),void 0!==t.y1&&(t.y1-=e),void 0!==t.x2&&(t.x2-=r),void 0!==t.y2&&(t.y2-=e),void 0!==t.x&&(t.x-=r),void 0!==t.y&&(t.y-=e),t.relative=!0),t}))},t.NORMALIZE_HVZ=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!0),u((function(i,a,n,o,s){if(isNaN(o)&&!(i.type&f.MOVE_TO))throw new Error("path must start with moveto");return r&&i.type&f.HORIZ_LINE_TO&&(i.type=f.LINE_TO,i.y=i.relative?0:n),e&&i.type&f.VERT_LINE_TO&&(i.type=f.LINE_TO,i.x=i.relative?0:a),t&&i.type&f.CLOSE_PATH&&(i.type=f.LINE_TO,i.x=i.relative?o-a:o,i.y=i.relative?s-n:s),i.type&f.ARC&&(0===i.rX||0===i.rY)&&(i.type=f.LINE_TO,delete i.rX,delete i.rY,delete i.xRot,delete i.lArcFlag,delete i.sweepFlag),i}))},t.NORMALIZE_ST=e,t.QT_TO_C=n,t.INFO=u,t.SANITIZE=function(t){void 0===t&&(t=0),a(t);var r=NaN,e=NaN,i=NaN,n=NaN;return u((function(a,o,s,u,h){var c=Math.abs,y=!1,p=0,m=0;if(a.type&f.SMOOTH_CURVE_TO&&(p=isNaN(r)?0:o-r,m=isNaN(e)?0:s-e),a.type&(f.CURVE_TO|f.SMOOTH_CURVE_TO)?(r=a.relative?o+a.x2:a.x2,e=a.relative?s+a.y2:a.y2):(r=NaN,e=NaN),a.type&f.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,n=isNaN(n)?s:2*s-n):a.type&f.QUAD_TO?(i=a.relative?o+a.x1:a.x1,n=a.relative?s+a.y1:a.y2):(i=NaN,n=NaN),a.type&f.LINE_COMMANDS||a.type&f.ARC&&(0===a.rX||0===a.rY||!a.lArcFlag)||a.type&f.CURVE_TO||a.type&f.SMOOTH_CURVE_TO||a.type&f.QUAD_TO||a.type&f.SMOOTH_QUAD_TO){var O=void 0===a.x?0:a.relative?a.x:a.x-o,T=void 0===a.y?0:a.relative?a.y:a.y-s;p=isNaN(i)?void 0===a.x1?p:a.relative?a.x:a.x1-o:i-o,m=isNaN(n)?void 0===a.y1?m:a.relative?a.y:a.y1-s:n-s;var v=void 0===a.x2?0:a.relative?a.x:a.x2-o,l=void 0===a.y2?0:a.relative?a.y:a.y2-s;c(O)<=t&&c(T)<=t&&c(p)<=t&&c(m)<=t&&c(v)<=t&&c(l)<=t&&(y=!0)}return a.type&f.CLOSE_PATH&&c(o-u)<=t&&c(s-h)<=t&&(y=!0),y?[]:a}))},t.MATRIX=O,t.ROTATE=function(t,r,e){void 0===r&&(r=0),void 0===e&&(e=0),a(t,r,e);var i=Math.sin(t),n=Math.cos(t);return O(n,i,-i,n,r-r*n+e*i,e-r*i-e*n)},t.TRANSLATE=function(t,r){return void 0===r&&(r=0),a(t,r),O(1,0,0,1,t,r)},t.SCALE=function(t,r){return void 0===r&&(r=t),a(t,r),O(t,0,0,r,0,0)},t.SKEW_X=function(t){return a(t),O(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return a(t),O(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),a(t),O(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),a(t),O(1,0,0,-1,0,t)},t.A_TO_C=function(){return u((function(t,r,e){return f.ARC===t.type?function(t,r,e){var a,n,s,u;t.cX||o(t,r,e);for(var y=Math.min(t.phi1,t.phi2),p=Math.max(t.phi1,t.phi2)-y,m=Math.ceil(p/90),O=new Array(m),T=r,v=e,l=0;lc.maxX&&(c.maxX=t),tc.maxY&&(c.maxY=t),tw&&O(m(e,u.x1,u.x2,u.x,w))}for(var _=0,N=p(n,u.y1,u.y2,u.y);_w&&T(m(n,u.y1,u.y2,u.y,w))}}if(u.type&f.ARC){O(u.x),T(u.y),o(u,e,n);for(var x=u.xRot/180*Math.PI,d=Math.cos(x)*u.rX,A=Math.sin(x)*u.rX,E=-Math.sin(x)*u.rY,C=Math.cos(x)*u.rY,M=u.phi1u.phi2?[u.phi2+360,u.phi1+360]:[u.phi2,u.phi1],R=M[0],g=M[1],I=function(t){var r=t[0],e=t[1],i=180*Math.atan2(e,r)/Math.PI;return iR&&wR&&wu)throw new SyntaxError('Expected positive number, got "'+u+'" at index "'+a+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+a+'"');this.curArgs.push(u),this.curArgs.length===N[this.curCommandType]&&(f.HORIZ_LINE_TO===this.curCommandType?i({type:f.HORIZ_LINE_TO,relative:this.curCommandRelative,x:u}):f.VERT_LINE_TO===this.curCommandType?i({type:f.VERT_LINE_TO,relative:this.curCommandRelative,y:u}):this.curCommandType===f.MOVE_TO||this.curCommandType===f.LINE_TO||this.curCommandType===f.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),f.MOVE_TO===this.curCommandType&&(this.curCommandType=f.LINE_TO)):this.curCommandType===f.CURVE_TO?i({type:f.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===f.SMOOTH_CURVE_TO?i({type:f.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===f.QUAD_TO?i({type:f.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===f.ARC&&i({type:f.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!v(n))if(","===n&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==n&&"-"!==n&&"."!==n)if(s)this.curNumber=n,this.curNumberHasDecimal=!1;else{if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+a+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+n+'" at index '+a+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==n&&"Z"!==n)if("h"===n||"H"===n)this.curCommandType=f.HORIZ_LINE_TO,this.curCommandRelative="h"===n;else if("v"===n||"V"===n)this.curCommandType=f.VERT_LINE_TO,this.curCommandRelative="v"===n;else if("m"===n||"M"===n)this.curCommandType=f.MOVE_TO,this.curCommandRelative="m"===n;else if("l"===n||"L"===n)this.curCommandType=f.LINE_TO,this.curCommandRelative="l"===n;else if("c"===n||"C"===n)this.curCommandType=f.CURVE_TO,this.curCommandRelative="c"===n;else if("s"===n||"S"===n)this.curCommandType=f.SMOOTH_CURVE_TO,this.curCommandRelative="s"===n;else if("q"===n||"Q"===n)this.curCommandType=f.QUAD_TO,this.curCommandRelative="q"===n;else if("t"===n||"T"===n)this.curCommandType=f.SMOOTH_QUAD_TO,this.curCommandRelative="t"===n;else{if("a"!==n&&"A"!==n)throw new SyntaxError('Unexpected character "'+n+'" at index '+a+".");this.curCommandType=f.ARC,this.curCommandRelative="a"===n}else r.push({type:f.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=n,this.curNumberHasDecimal="."===n}else this.curNumber+=n,this.curNumberHasDecimal=!0;else this.curNumber+=n;else this.curNumber+=n,this.curNumberHasExp=!0;else this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp}return r},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(r,e){void 0===e&&(e=[]);for(var i=0,a=Object.getPrototypeOf(this).parse.call(this,r);i " " === c || "\t" === c || "\r" === c || "\n" === c; +const isWhiteSpace = (c: string) => + " " === c || "\t" === c || "\r" === c || "\n" === c; const isDigit = (c: string) => "0".charCodeAt(0) <= c.charCodeAt(0) && c.charCodeAt(0) <= "9".charCodeAt(0); const COMMANDS = "mMzZlLhHvVcCsSqQtTaA"; @@ -42,8 +43,19 @@ export class SVGPathDataParser extends TransformableSVG { for (let i = 0; i < str.length; i++) { const c = str[i]; // White spaces parsing + const isAArcFlag = this.curCommandType === SVGPathData.ARC && + (this.curArgs.length === 3 || this.curArgs.length === 4) && + this.curNumber.length === 1 && + (this.curNumber === "0" || this.curNumber === "1"); + const isEndingDigit = isDigit(c) && ( + (this.curNumber === "0" && c === "0") || + isAArcFlag + ); - if (isDigit(c)) { + if ( + isDigit(c) && + !isEndingDigit + ) { this.curNumber += c; this.curNumberHasExpDigits = this.curNumberHasExp; continue; @@ -53,12 +65,16 @@ export class SVGPathDataParser extends TransformableSVG { this.curNumberHasExp = true; continue; } - if (("-" === c || "+" === c) && this.curNumberHasExp && !this.curNumberHasExpDigits) { + if ( + ("-" === c || "+" === c) && + this.curNumberHasExp && + !this.curNumberHasExpDigits + ) { this.curNumber += c; continue; } // if we already have a ".", it means we are starting a new number - if ("." === c && !this.curNumberHasExp && !this.curNumberHasDecimal) { + if ("." === c && !this.curNumberHasExp && !this.curNumberHasDecimal && !isAArcFlag) { this.curNumber += c; this.curNumberHasDecimal = true; continue; @@ -73,11 +89,15 @@ export class SVGPathDataParser extends TransformableSVG { if (this.curCommandType === SVGPathData.ARC) { if (0 === this.curArgs.length || 1 === this.curArgs.length) { if (0 > val) { - throw new SyntaxError(`Expected positive number, got "${val}" at index "${i}"`); + throw new SyntaxError( + `Expected positive number, got "${val}" at index "${i}"`, + ); } } else if (3 === this.curArgs.length || 4 === this.curArgs.length) { if ("0" !== this.curNumber && "1" !== this.curNumber) { - throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${i}"`); + throw new SyntaxError( + `Expected a flag, got "${this.curNumber}" at index "${i}"`, + ); } } } @@ -175,13 +195,21 @@ export class SVGPathDataParser extends TransformableSVG { this.curNumberHasDecimal = "." === c; continue; } + // if a 0 is detected, then parse the new number + if (isEndingDigit) { + this.curNumber = c; + this.curNumberHasDecimal = false; + continue; + } // Adding residual command if (0 !== this.curArgs.length) { throw new SyntaxError(`Unterminated command at index ${i}.`); } if (!this.canParseCommandOrComma) { - throw new SyntaxError(`Unexpected character "${c}" at index ${i}. Command cannot follow comma`); + throw new SyntaxError( + `Unexpected character "${c}" at index ${i}. Command cannot follow comma`, + ); } this.canParseCommandOrComma = false; // Detecting the next command diff --git a/tests/arc.mocha.js b/tests/arc.mocha.js index ff28d6f..077238f 100644 --- a/tests/arc.mocha.js +++ b/tests/arc.mocha.js @@ -49,13 +49,13 @@ describe('Parsing elliptical arc commands', () => { it('should not work with bad lArcFlag value', () => { assert.throw(() => { new SVGPathData('A30,50,0,15,1,162.55,162.45'); - }, SyntaxError, 'Expected a flag, got "15" at index "11"'); + }, SyntaxError, 'Expected a flag, got "5" at index "11"'); }); it('should not work with bad sweepFlag value', () => { assert.throw(() => { new SVGPathData('A30,50,0,0,15,162.55,162.45'); - }, SyntaxError, 'Expected a flag, got "15" at index "13"'); + }, SyntaxError, 'Unterminated command at the path end.'); }); it('should work with comma separated coordinates', () => { diff --git a/tests/realword.mocha.js b/tests/realword.mocha.js index c1548f0..7afa19b 100644 --- a/tests/realword.mocha.js +++ b/tests/realword.mocha.js @@ -35,4 +35,138 @@ describe('Dealing with real world commands', () => { assert.equal(new SVGPathData('M382.658 327.99c16.71-17.204 26.987-40.676 26.987-66.542 0-52.782-42.792-95.575-95.574-95.575-29.894 0-56.583 13.74-74.104 35.24-17.47-7.164-37.11-9.877-57.725-7.596-44.774 4.964-82.87 38.712-94.42 84.393-2.14 8.447-5.14 13.34-14.276 16.473-26.103 8.952-42.988 35.322-41.446 61.6 1.696 28.703 21.253 52.36 48.917 59.185 1.942.48 3.813.668 5.61 1.048.063 0 .114-.216.166-.216h224.753c.154 0 .31.235.463.216 39.072-1.706 70.56-33.144 71.865-71.815.197-5.66-.225-11.13-1.21-16.472m-63.554 62.75c-2.312.503-4.697.847-7.1 1.166-6.095.83-3.763.156-18.232.156H103.716c-3.113 0-6.207.11-9.29-.044-21.283-1.038-36.646-16.796-37.243-37.185-.617-20.696 13.596-37.283 34.52-39.833 5.365-.646 10.873-.082 16.217-.082 6.186-58.885 31.18-90.46 76.418-96.802 19.834-2.785 38.66.794 56.06 10.825 25.434 14.654 38.69 37.81 44.127 66.47 4.748-1.108 8.355-1.973 11.962-2.796 27.85-6.33 54.868 10.033 61.034 36.958 6.516 28.426-9.844 55.01-38.414 61.168zm8.86-121.502c-4.225-1.07-8.613-1.778-13.125-2.097-1.756-.124-3.35-.34-4.788-.668-6.207-1.4-9.794-4.8-13.124-11.49-.185-.37-.37-.73-.555-1.1-5.333-10.44-11.92-19.68-19.537-27.604l-17.82-14.973-.42-.35c13.616-13.822 34.58-24.47 55.473-24.47 41.363 0 75.02 33.657 75.02 75.022 0 16.452-5.334 31.683-14.357 44.056-9.68-17.788-26.348-31.2-46.768-36.327z').toAbs().round(1000).encode(), 'M382.658 327.99C399.368 310.786 409.645 287.314 409.645 261.448C409.645 208.666 366.853 165.873 314.071 165.873C284.177 165.873 257.488 179.613 239.967 201.113C222.497 193.949 202.857 191.236 182.242 193.517C137.468 198.481 99.372 232.229 87.822 277.91C85.682 286.357 82.682 291.25 73.546 294.383C47.443 303.335 30.558 329.705 32.1 355.983C33.796 384.686 53.353 408.343 81.017 415.168C82.959 415.648 84.83 415.836 86.627 416.216C86.69 416.216 86.741 416 86.793 416H311.546C311.7 416 311.856 416.235 312.009 416.216C351.081 414.51 382.569 383.072 383.874 344.401C384.071 338.741 383.649 333.271 382.664 327.929M319.11 390.679C316.798 391.182 314.413 391.526 312.01 391.845C305.915 392.675 308.247 392.001 293.778 392.001H103.716C100.603 392.001 97.509 392.111 94.426 391.957C73.143 390.919 57.78 375.161 57.183 354.772C56.566 334.076 70.779 317.489 91.703 314.939C97.068 314.293 102.576 314.857 107.92 314.857C114.106 255.972 139.1 224.397 184.338 218.055C204.172 215.27 222.998 218.849 240.398 228.88C265.832 243.534 279.088 266.69 284.525 295.35C289.273 294.242 292.88 293.377 296.487 292.554C324.337 286.224 351.355 302.587 357.521 329.512C364.037 357.938 347.677 384.522 319.107 390.68zM327.97 269.177C323.745 268.107 319.357 267.399 314.845 267.08C313.089 266.956 311.495 266.74 310.057 266.412C303.85 265.012 300.263 261.612 296.933 254.922C296.748 254.552 296.563 254.192 296.378 253.822C291.045 243.382 284.458 234.142 276.841 226.218L259.021 211.245L258.601 210.895C272.217 197.073 293.181 186.425 314.074 186.425C355.437 186.425 389.094 220.082 389.094 261.447C389.094 277.899 383.76 293.13 374.737 305.503C365.057 287.715 348.389 274.303 327.969 269.176z'); }); + it('of kaptinlin bug report', () => { + assert.equal(new SVGPathData('M13 5H8V2.6a1 1 0 00.42-.46l5.08-.64a.5.5 0 000-1l-5.22.65a1 1 0 00-.78-.4 1 1 0 00-.92.62L1.5 2a.5.5 0 000 1l5.22-.65c.077.1.172.185.28.25V5H2a1 1 0 00-1 1v7a1 1 0 001 1h11a1 1 0 001-1V6a1 1 0 00-1-1zm-6 6H3V7h4v4zm5 0H8V7h4v4z').toAbs().round(1000).encode(), 'M13 5H8V2.6A1 1 0 0 0 8.42 2.14L13.5 1.5A0.5 0.5 0 0 0 13.5 0.5L8.28 1.15A1 1 0 0 0 7.5 0.75A1 1 0 0 0 6.58 1.37L1.5 2A0.5 0.5 0 0 0 1.5 3L6.72 2.35C6.797 2.45 6.892 2.535 7 2.6V5H2A1 1 0 0 0 1 6V13A1 1 0 0 0 2 14H13A1 1 0 0 0 14 13V6A1 1 0 0 0 13 5zM7 11H3V7H7V11zM12 11H8V7H12V11z'); + }); + + it('of kaptinlin bug report 2', () => { + assert.equal(new SVGPathData('M13 5H8V2.6a1 1 0 00 .42-.46l5.08-.64a.5.5 0 000-1l-5.22.65a1 1 0 00-.78-.4 1 1 0 00-.92.62L1.5 2a.5.5 0 000 1l5.22-.65c.077.1.172.185.28.25V5H2a1 1 0 00-1 1v7a1 1 0 001 1h11a1 1 0 001-1V6a1 1 0 00-1-1zm-6 6H3V7h4v4zm5 0H8V7h4v4z').toAbs().round(1000).encode(), 'M13 5H8V2.6A1 1 0 0 0 8.42 2.14L13.5 1.5A0.5 0.5 0 0 0 13.5 0.5L8.28 1.15A1 1 0 0 0 7.5 0.75A1 1 0 0 0 6.58 1.37L1.5 2A0.5 0.5 0 0 0 1.5 3L6.72 2.35C6.797 2.45 6.892 2.535 7 2.6V5H2A1 1 0 0 0 1 6V13A1 1 0 0 0 2 14H13A1 1 0 0 0 14 13V6A1 1 0 0 0 13 5zM7 11H3V7H7V11zM12 11H8V7H12V11z'); + }); + + describe('bootstrap-icons', () => { + + it('box-arrow-up-right', () => { + assert.equal(new SVGPathData('M3.5 15A1.5 1.5 0 005 16.5h8a1.5 1.5 0 001.5-1.5v-4a.5.5 0 00-1 0v4a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V7a.5.5 0 01.5-.5h4a.5.5 0 000-1H5A1.5 1.5 0 003.5 7v8zm7-11a.5.5 0 01.5-.5h5a.5.5 0 01.5.5v5a.5.5 0 01-1 0V4.5H11a.5.5 0 01-.5-.5z').toAbs().round(1000).encode(), 'M3.5 15A1.5 1.5 0 0 0 5 16.5H13A1.5 1.5 0 0 0 14.5 15V11A0.5 0.5 0 0 0 13.5 11V15A0.5 0.5 0 0 1 13 15.5H5A0.5 0.5 0 0 1 4.5 15V7A0.5 0.5 0 0 1 5 6.5H9A0.5 0.5 0 0 0 9 5.5H5A1.5 1.5 0 0 0 3.5 7V15zM10.5 4A0.5 0.5 0 0 1 11 3.5H16A0.5 0.5 0 0 1 16.5 4V9A0.5 0.5 0 0 1 15.5 9V4.5H11A0.5 0.5 0 0 1 10.5 4z'); + }); + + it('bootstrap', () => { + assert.equal(new SVGPathData('M14 3H6a3 3 0 00-3 3v8a3 3 0 003 3h8a3 3 0 003-3V6a3 3 0 00-3-3zM6 2a4 4 0 00-4 4v8a4 4 0 004 4h8a4 4 0 004-4V6a4 4 0 00-4-4H6z').toAbs().round(1000).encode(), 'M14 3H6A3 3 0 0 0 3 6V14A3 3 0 0 0 6 17H14A3 3 0 0 0 17 14V6A3 3 0 0 0 14 3zM6 2A4 4 0 0 0 2 6V14A4 4 0 0 0 6 18H14A4 4 0 0 0 18 14V6A4 4 0 0 0 14 2H6z'); + }); + + it('camera', () => { + assert.equal(new SVGPathData('M16.333 5h-2.015A5.97 5.97 0 0011 4a5.972 5.972 0 00-3.318 1H3.667C2.747 5 2 5.746 2 6.667v6.666C2 14.253 2.746 15 3.667 15h4.015c.95.632 2.091 1 3.318 1a5.973 5.973 0 003.318-1h2.015c.92 0 1.667-.746 1.667-1.667V6.667C18 5.747 17.254 5 16.333 5zM3.5 7a.5.5 0 100-1 .5.5 0 000 1zm7.5 8a5 5 0 100-10 5 5 0 000 10z').toAbs().round(1000).encode(), 'M16.333 5H14.318A5.97 5.97 0 0 0 11 4A5.972 5.972 0 0 0 7.682 5H3.667C2.747 5 2 5.746 2 6.667V13.333C2 14.253 2.746 15 3.667 15H7.682C8.632 15.632 9.773 16 11 16A5.973 5.973 0 0 0 14.318 15H16.333C17.253 15 18 14.254 18 13.333V6.667C18 5.747 17.254 5 16.333 5zM3.5 7A0.5 0.5 0 1 0 3.5 6A0.5 0.5 0 0 0 3.5 7zM11 15A5 5 0 1 0 11 5A5 5 0 0 0 11 15z'); + }); + + it('bucket', () => { + assert.equal(new SVGPathData('M10 3.5A4.5 4.5 0 005.5 8h-1a5.5 5.5 0 1111 0h-1A4.5 4.5 0 0010 3.5z').toAbs().round(1000).encode(), 'M10 3.5A4.5 4.5 0 0 0 5.5 8H4.5A5.5 5.5 0 1 1 15.5 8H14.5A4.5 4.5 0 0 0 10 3.5z'); + }); + + it('check-box', () => { + assert.equal(new SVGPathData('M3.5 15A1.5 1.5 0 005 16.5h10a1.5 1.5 0 001.5-1.5v-5a.5.5 0 00-1 0v5a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V5a.5.5 0 01.5-.5h8a.5.5 0 000-1H5A1.5 1.5 0 003.5 5v10z').toAbs().round(1000).encode(), 'M3.5 15A1.5 1.5 0 0 0 5 16.5H15A1.5 1.5 0 0 0 16.5 15V10A0.5 0.5 0 0 0 15.5 10V15A0.5 0.5 0 0 1 15 15.5H5A0.5 0.5 0 0 1 4.5 15V5A0.5 0.5 0 0 1 5 4.5H13A0.5 0.5 0 0 0 13 3.5H5A1.5 1.5 0 0 0 3.5 5V15z'); + }); + + it('diamond-half', () => { + assert.equal(new SVGPathData('M8.94 2.354a1.5 1.5 0 012.12 0l6.586 6.585a1.5 1.5 0 010 2.122l-6.585 6.585a1.5 1.5 0 01-2.122 0l-6.585-6.585a1.5 1.5 0 010-2.122l6.585-6.585zm1.06.56a.498.498 0 00-.354.147L3.061 9.646a.5.5 0 000 .707l6.585 6.586a.499.499 0 00.354.147V2.914z').toAbs().round(1000).encode(), 'M8.94 2.354A1.5 1.5 0 0 1 11.06 2.354L17.646 8.939A1.5 1.5 0 0 1 17.646 11.061L11.061 17.646A1.5 1.5 0 0 1 8.939 17.646L2.354 11.061A1.5 1.5 0 0 1 2.354 8.939L8.939 2.354zM10 2.914A0.498 0.498 0 0 0 9.646 3.061L3.061 9.646A0.5 0.5 0 0 0 3.061 10.353L9.646 16.939A0.499 0.499 0 0 0 10 17.086V2.914z'); + }); + + it('document', () => { + assert.equal(new SVGPathData('M6 3h8a2 2 0 012 2v10a2 2 0 01-2 2H6a2 2 0 01-2-2V5a2 2 0 012-2zm0 1a1 1 0 00-1 1v10a1 1 0 001 1h8a1 1 0 001-1V5a1 1 0 00-1-1H6z').toAbs().round(1000).encode(), 'M6 3H14A2 2 0 0 1 16 5V15A2 2 0 0 1 14 17H6A2 2 0 0 1 4 15V5A2 2 0 0 1 6 3zM6 4A1 1 0 0 0 5 5V15A1 1 0 0 0 6 16H14A1 1 0 0 0 15 15V5A1 1 0 0 0 14 4H6z'); + }); + + it('trash', () => { + assert.equal(new SVGPathData('M7.5 7.5A.5.5 0 018 8v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm2.5 0a.5.5 0 01.5.5v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm3 .5a.5.5 0 00-1 0v6a.5.5 0 001 0V8z').toAbs().round(1000).encode(), 'M7.5 7.5A0.5 0.5 0 0 1 8 8V14A0.5 0.5 0 0 1 7 14V8A0.5 0.5 0 0 1 7.5 7.5zM10 7.5A0.5 0.5 0 0 1 10.5 8V14A0.5 0.5 0 0 1 9.5 14V8A0.5 0.5 0 0 1 10 7.5zM13 8A0.5 0.5 0 0 0 12 8V14A0.5 0.5 0 0 0 13 14V8z'); + }); + + it('tv-fill', () => { + assert.equal(new SVGPathData('M4.5 15.5A.5.5 0 015 15h10a.5.5 0 010 1H5a.5.5 0 01-.5-.5zM4 4h12s2 0 2 2v6s0 2-2 2H4s-2 0-2-2V6s0-2 2-2z').toAbs().round(1000).encode(), 'M4.5 15.5A0.5 0.5 0 0 1 5 15H15A0.5 0.5 0 0 1 15 16H5A0.5 0.5 0 0 1 4.5 15.5zM4 4H16S18 4 18 6V12S18 14 16 14H4S2 14 2 12V6S2 4 4 4z'); + }); + + it('unlock-fill', () => { + assert.equal(new SVGPathData('M2.5 10a2 2 0 012-2h7a2 2 0 012 2v5a2 2 0 01-2 2h-7a2 2 0 01-2-2v-5z').toAbs().round(1000).encode(), 'M2.5 10A2 2 0 0 1 4.5 8H11.5A2 2 0 0 1 13.5 10V15A2 2 0 0 1 11.5 17H4.5A2 2 0 0 1 2.5 15V10z'); + }); + + it('watch', () => { + assert.equal(new SVGPathData('M6 16.333v-1.86A5.985 5.985 0 014 10c0-1.777.772-3.374 2-4.472V3.667C6 2.747 6.746 2 7.667 2h4.666C13.253 2 14 2.746 14 3.667v1.86A5.985 5.985 0 0116 10a5.985 5.985 0 01-2 4.472v1.861c0 .92-.746 1.667-1.667 1.667H7.667C6.747 18 6 17.254 6 16.333zM15 10a5 5 0 10-10 0 5 5 0 0010 0z').toAbs().round(1000).encode(), 'M6 16.333V14.473A5.985 5.985 0 0 1 4 10C4 8.223 4.772 6.626 6 5.528V3.667C6 2.747 6.746 2 7.667 2H12.333C13.253 2 14 2.746 14 3.667V5.527A5.985 5.985 0 0 1 16 10A5.985 5.985 0 0 1 14 14.472V16.333C14 17.253 13.254 18 12.333 18H7.667C6.747 18 6 17.254 6 16.333zM15 10A5 5 0 1 0 5 10A5 5 0 0 0 15 10z'); + }); + + it('wrench', () => { + assert.equal(new SVGPathData('M2.102 4.223A3.004 3.004 0 005 8c.27 0 .532-.036.78-.103l6.342 6.252A3.003 3.003 0 0015 18a3 3 0 10-.851-5.878L7.897 5.781A3.004 3.004 0 004.223 2.1l2.141 2.142L6 6l-1.757.364-2.141-2.141zm13.37 9.019L15 13l-.471.242-.529.026-.287.445-.445.287-.026.529L13 15l.242.471.026.529.445.287.287.445.529.026L15 17l.471-.242.529-.026.287-.445.445-.287.026-.529L17 15l-.242-.471-.026-.529-.445-.287-.287-.445-.529-.026z').toAbs().round(1000).encode(), 'M2.102 4.223A3.004 3.004 0 0 0 5 8C5.27 8 5.532 7.964 5.78 7.897L12.122 14.149A3.003 3.003 0 0 0 15 18A3 3 0 1 0 14.149 12.122L7.897 5.781A3.004 3.004 0 0 0 4.223 2.1L6.364 4.242L6 6L4.243 6.364L2.102 4.223zM15.472 13.242L15 13L14.529 13.242L14 13.268L13.713 13.713L13.268 14L13.242 14.529L13 15L13.242 15.471L13.268 16L13.713 16.287L14 16.732L14.529 16.758L15 17L15.471 16.758L16 16.732L16.287 16.287L16.732 16L16.758 15.471L17 15L16.758 14.529L16.732 14L16.287 13.713L16 13.268L15.471 13.242z'); + }); + + it('x-octagon', () => { + assert.equal(new SVGPathData('M6.54 2.146A.5.5 0 016.893 2h6.214a.5.5 0 01.353.146l4.394 4.394a.5.5 0 01.146.353v6.214a.5.5 0 01-.146.353l-4.394 4.394a.5.5 0 01-.353.146H6.893a.5.5 0 01-.353-.146L2.146 13.46A.5.5 0 012 13.107V6.893a.5.5 0 01.146-.353L6.54 2.146zM7.1 3L3 7.1v5.8L7.1 17h5.8l4.1-4.1V7.1L12.9 3H7.1z').toAbs().round(1000).encode(), 'M6.54 2.146A0.5 0.5 0 0 1 6.893 2H13.107A0.5 0.5 0 0 1 13.46 2.146L17.854 6.54A0.5 0.5 0 0 1 18 6.893V13.107A0.5 0.5 0 0 1 17.854 13.46L13.46 17.854A0.5 0.5 0 0 1 13.107 18H6.893A0.5 0.5 0 0 1 6.54 17.854L2.146 13.46A0.5 0.5 0 0 1 2 13.107V6.893A0.5 0.5 0 0 1 2.146 6.54L6.54 2.146zM7.1 3L3 7.1V12.9L7.1 17H12.9L17 12.9V7.1L12.9 3H7.1z'); + }); + + it('x-square-fill', () => { + assert.equal(new SVGPathData('M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm3.354 4.646L10 9.293l2.646-2.647a.5.5 0 01.708.708L10.707 10l2.647 2.646a.5.5 0 01-.708.708L10 10.707l-2.646 2.647a.5.5 0 01-.708-.708L9.293 10 6.646 7.354a.5.5 0 11.708-.708z').toAbs().round(1000).encode(), 'M4 2A2 2 0 0 0 2 4V16A2 2 0 0 0 4 18H16A2 2 0 0 0 18 16V4A2 2 0 0 0 16 2H4zM7.354 6.646L10 9.293L12.646 6.646A0.5 0.5 0 0 1 13.354 7.354L10.707 10L13.354 12.646A0.5 0.5 0 0 1 12.646 13.354L10 10.707L7.354 13.354A0.5 0.5 0 0 1 6.646 12.646L9.293 10L6.646 7.354A0.5 0.5 0 1 1 7.354 6.646z'); + }); + }); + + describe('maki-icons', () => { + it('alcohol-shop', () => { + assert.equal(new SVGPathData('M14 4h-4v3.5a2 2 0 001.5 1.93V13H11a.5.5 0 000 1h2a.5.5 0 000-1h-.5V9.43A2 2 0 0014 7.5V4zm-1 3.5a1 1 0 11-2 0V5h2v2.5zm-7.5-5V2a.5.5 0 000-1V.5A.5.5 0 005 0H4a.5.5 0 00-.5.5V1a.5.5 0 000 1v.5C3.5 3.93 1 5.57 1 7v6a1 1 0 001 1h5a1.1 1.1 0 001-1V7c0-1.35-2.5-3.15-2.5-4.5zm-1 9.5a2.5 2.5 0 110-5 2.5 2.5 0 010 5z').toAbs().round(1000).encode(), 'M14 4H10V7.5A2 2 0 0 0 11.5 9.43V13H11A0.5 0.5 0 0 0 11 14H13A0.5 0.5 0 0 0 13 13H12.5V9.43A2 2 0 0 0 14 7.5V4zM13 7.5A1 1 0 1 1 11 7.5V5H13V7.5zM5.5 2.5V2A0.5 0.5 0 0 0 5.5 1V0.5A0.5 0.5 0 0 0 5 0H4A0.5 0.5 0 0 0 3.5 0.5V1A0.5 0.5 0 0 0 3.5 2V2.5C3.5 3.93 1 5.57 1 7V13A1 1 0 0 0 2 14H7A1.1 1.1 0 0 0 8 13V7C8 5.65 5.5 3.85 5.5 2.5zM4.5 12A2.5 2.5 0 1 1 4.5 7A2.5 2.5 0 0 1 4.5 12z'); + }); + + it('baseball', () => { + assert.equal(new SVGPathData('M10 3.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM7 .28A.28.28 0 006.72 0a.49.49 0 00-.25.16L4 4.59a.48.48 0 000 .13c0 .155.125.28.28.28a.49.49 0 00.26-.16L7 .41a.472.472 0 000-.13zm5.9 13.92L10 6.39A.49.49 0 009.52 6h-5a.5.5 0 000 1H7l1.45 2.51-4.27 4.61a.49.49 0 00-.18.38.5.5 0 00.5.5.49.49 0 00.33-.13l4.45-4.15 2.76 4a.51.51 0 00.44.26c.28 0 .51-.22.52-.5a.5.5 0 00-.1-.28z').toAbs().round(1000).encode(), 'M10 3.5A1.5 1.5 0 1 1 7 3.5A1.5 1.5 0 0 1 10 3.5zM7 0.28A0.28 0.28 0 0 0 6.72 0A0.49 0.49 0 0 0 6.47 0.16L4 4.59A0.48 0.48 0 0 0 4 4.72C4 4.875 4.125 5 4.28 5A0.49 0.49 0 0 0 4.54 4.84L7 0.41A0.472 0.472 0 0 0 7 0.28zM12.9 14.2L10 6.39A0.49 0.49 0 0 0 9.52 6H4.52A0.5 0.5 0 0 0 4.52 7H7L8.45 9.51L4.18 14.12A0.49 0.49 0 0 0 4 14.5A0.5 0.5 0 0 0 4.5 15A0.49 0.49 0 0 0 4.83 14.87L9.28 10.72L12.04 14.72A0.51 0.51 0 0 0 12.48 14.98C12.76 14.98 12.99 14.76 13 14.48A0.5 0.5 0 0 0 12.9 14.2z'); + }); + + it('beach', () => { + assert.equal(new SVGPathData('M5.36 1.67l-.01 4.02a4.452 4.452 0 00-1.1-.11c-.37.1-.74.63-1.1.76a4.202 4.202 0 012.21-4.67zm2.41-.64L9.8 4.48a3.183 3.183 0 01.84-.61c.36-.1.94.17 1.34.11a4.202 4.202 0 00-4.21-2.95zM1 13h13c-.66-.66-2.64-1.11-4.34-1.33l-1.87-7c.52-.05 1.15.03 1.53 0l-2.11-3.6H7.2a6.174 6.174 0 00-.7.14 4.38 4.38 0 00-.64.22l-.01 4.15c.35-.17.84-.54 1.3-.74l1.8 6.74c-.58-.05-1.09-.08-1.45-.08C6.03 11.5 2 12 1 13z').toAbs().round(1000).encode(), 'M5.36 1.67L5.35 5.69A4.452 4.452 0 0 0 4.25 5.58C3.88 5.68 3.51 6.21 3.15 6.34A4.202 4.202 0 0 1 5.36 1.67zM7.77 1.03L9.8 4.48A3.183 3.183 0 0 1 10.64 3.87C11 3.77 11.58 4.04 11.98 3.98A4.202 4.202 0 0 0 7.77 1.03zM1 13H14C13.34 12.34 11.36 11.89 9.66 11.67L7.79 4.67C8.31 4.62 8.94 4.7 9.32 4.67L7.21 1.07H7.2A6.174 6.174 0 0 0 6.5 1.21A4.38 4.38 0 0 0 5.86 1.43L5.85 5.58C6.2 5.41 6.69 5.04 7.15 4.84L8.95 11.58C8.37 11.53 7.86 11.5 7.5 11.5C6.03 11.5 2 12 1 13z'); + }); + + it('cafe', () => { + assert.equal(new SVGPathData('M12 5h-2V3H2v4a4 4 0 007.45 2H12a2 2 0 100-4zm0 3H9.86A4 4 0 0010 7V6h2a1 1 0 110 2zm-2 4.5a.5.5 0 01-.5.5h-7a.5.5 0 010-1h7a.5.5 0 01.5.5z').toAbs().round(1000).encode(), 'M12 5H10V3H2V7A4 4 0 0 0 9.45 9H12A2 2 0 1 0 12 5zM12 8H9.86A4 4 0 0 0 10 7V6H12A1 1 0 1 1 12 8zM10 12.5A0.5 0.5 0 0 1 9.5 13H2.5A0.5 0.5 0 0 1 2.5 12H9.5A0.5 0.5 0 0 1 10 12.5z'); + }); + + it('car', () => { + assert.equal(new SVGPathData('M14 7a1.5 1.5 0 00-1.15-1.45l-1.39-3.24A.5.5 0 0011 2H4a.5.5 0 00-.44.28L2.15 5.54A1.5 1.5 0 001 7v3.5h1v1a1 1 0 102 0v-1h7v1a1 1 0 102 0v-1h1V7zM4.3 3h6.4l1.05 2.5h-8.5L4.3 3zM3 9a1 1 0 110-2 1 1 0 010 2zm9 0a1 1 0 110-2 1 1 0 010 2z').toAbs().round(1000).encode(), 'M14 7A1.5 1.5 0 0 0 12.85 5.55L11.46 2.31A0.5 0.5 0 0 0 11 2H4A0.5 0.5 0 0 0 3.56 2.28L2.15 5.54A1.5 1.5 0 0 0 1 7V10.5H2V11.5A1 1 0 1 0 4 11.5V10.5H11V11.5A1 1 0 1 0 13 11.5V10.5H14V7zM4.3 3H10.7L11.75 5.5H3.25L4.3 3zM3 9A1 1 0 1 1 3 7A1 1 0 0 1 3 9zM12 9A1 1 0 1 1 12 7A1 1 0 0 1 12 9z'); + }); + + it('casino', () => { + assert.equal(new SVGPathData('M8.5 10A2.5 2.5 0 0013 8.5c0-.564-.194-1.079-.509-1.497L12.5 7l-5-6-5 6 .009.003A2.478 2.478 0 002 8.5 2.5 2.5 0 006.5 10l.5-.666V11.5C7 13 4.5 13 4.5 13a.5.5 0 100 1h6a.5.5 0 000-1S8 13 8 11.5V9.334l.5.666z').toAbs().round(1000).encode(), 'M8.5 10A2.5 2.5 0 0 0 13 8.5C13 7.936 12.806 7.421 12.491 7.003L12.5 7L7.5 1L2.5 7L2.509 7.003A2.478 2.478 0 0 0 2 8.5A2.5 2.5 0 0 0 6.5 10L7 9.334V11.5C7 13 4.5 13 4.5 13A0.5 0.5 0 1 0 4.5 14H10.5A0.5 0.5 0 0 0 10.5 13S8 13 8 11.5V9.334L8.5 10z'); + }); + + it('cross', () => { + assert.equal(new SVGPathData('M2.64 1.27L7.5 6.13l4.84-4.84A.92.92 0 0113 1a1 1 0 011 1 .9.9 0 01-.27.66L8.84 7.5l4.89 4.89A.9.9 0 0114 13a1 1 0 01-1 1 .92.92 0 01-.69-.27L7.5 8.87l-4.85 4.85A.92.92 0 012 14a1 1 0 01-1-1 .9.9 0 01.27-.66L6.16 7.5 1.27 2.61A.9.9 0 011 2a1 1 0 011-1c.24.003.47.1.64.27z').toAbs().round(1000).encode(), 'M2.64 1.27L7.5 6.13L12.34 1.29A0.92 0.92 0 0 1 13 1A1 1 0 0 1 14 2A0.9 0.9 0 0 1 13.73 2.66L8.84 7.5L13.73 12.39A0.9 0.9 0 0 1 14 13A1 1 0 0 1 13 14A0.92 0.92 0 0 1 12.31 13.73L7.5 8.87L2.65 13.72A0.92 0.92 0 0 1 2 14A1 1 0 0 1 1 13A0.9 0.9 0 0 1 1.27 12.34L6.16 7.5L1.27 2.61A0.9 0.9 0 0 1 1 2A1 1 0 0 1 2 1C2.24 1.003 2.47 1.1 2.64 1.27z'); + }); + }); + + describe('octicons', () => { + it('broadcast', () => { + assert.equal(new SVGPathData('M9 9H8c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1H6c-.55 0-1 .45-1 1v2h1v3c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-3h1v-2c0-.55-.45-1-1-1zM7 7h1v1H7V7zm2 4H8v4H7v-4H6v-1h3v1zm2.09-3.5c0-1.98-1.61-3.59-3.59-3.59A3.593 3.593 0 004 8.31v1.98c-.61-.77-1-1.73-1-2.8 0-2.48 2.02-4.5 4.5-4.5S12 5.01 12 7.49c0 1.06-.39 2.03-1 2.8V8.31c.06-.27.09-.53.09-.81zm3.91 0c0 2.88-1.63 5.38-4 6.63v-1.05a6.553 6.553 0 003.09-5.58A6.59 6.59 0 007.5.91 6.59 6.59 0 00.91 7.5c0 2.36 1.23 4.42 3.09 5.58v1.05A7.497 7.497 0 017.5 0C11.64 0 15 3.36 15 7.5z').toAbs().round(1000).encode(), 'M9 9H8C8.55 9 9 8.55 9 8V7C9 6.45 8.55 6 8 6H7C6.45 6 6 6.45 6 7V8C6 8.55 6.45 9 7 9H6C5.45 9 5 9.45 5 10V12H6V15C6 15.55 6.45 16 7 16H8C8.55 16 9 15.55 9 15V12H10V10C10 9.45 9.55 9 9 9zM7 7H8V8H7V7zM9 11H8V15H7V11H6V10H9V11zM11.09 7.5C11.09 5.52 9.48 3.91 7.5 3.91A3.593 3.593 0 0 0 4 8.31V10.29C3.39 9.52 3 8.56 3 7.49C3 5.01 5.02 2.99 7.5 2.99S12 5.01 12 7.49C12 8.55 11.61 9.52 11 10.29V8.31C11.06 8.04 11.09 7.78 11.09 7.5zM15 7.5C15 10.38 13.37 12.88 11 14.13V13.08A6.553 6.553 0 0 0 14.09 7.5A6.59 6.59 0 0 0 7.5 0.91A6.59 6.59 0 0 0 0.91 7.5C0.91 9.86 2.14 11.92 4 13.08V14.13A7.497 7.497 0 0 1 7.5 0C11.64 0 15 3.36 15 7.5z'); + }); + + it('dashboard', () => { + assert.equal(new SVGPathData('M9 5H8V4h1v1zm4 3h-1v1h1V8zM6 5H5v1h1V5zM5 8H4v1h1V8zm11-5.5l-.5-.5L9 7c-.06-.02-1 0-1 0-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-.92l6-5.58zm-1.59 4.09c.19.61.3 1.25.3 1.91 0 3.42-2.78 6.2-6.2 6.2-3.42 0-6.21-2.78-6.21-6.2 0-3.42 2.78-6.2 6.2-6.2 1.2 0 2.31.34 3.27.94l.94-.94A7.459 7.459 0 008.51 1C4.36 1 1 4.36 1 8.5 1 12.64 4.36 16 8.5 16c4.14 0 7.5-3.36 7.5-7.5 0-1.03-.2-2.02-.59-2.91l-1 1z').toAbs().round(1000).encode(), 'M9 5H8V4H9V5zM13 8H12V9H13V8zM6 5H5V6H6V5zM5 8H4V9H5V8zM16 2.5L15.5 2L9 7C8.94 6.98 8 7 8 7C7.45 7 7 7.45 7 8V9C7 9.55 7.45 10 8 10H9C9.55 10 10 9.55 10 9V8.08L16 2.5zM14.41 6.59C14.6 7.2 14.71 7.84 14.71 8.5C14.71 11.92 11.93 14.7 8.51 14.7C5.09 14.7 2.3 11.92 2.3 8.5C2.3 5.08 5.08 2.3 8.5 2.3C9.7 2.3 10.81 2.64 11.77 3.24L12.71 2.3A7.459 7.459 0 0 0 8.51 1C4.36 1 1 4.36 1 8.5C1 12.64 4.36 16 8.5 16C12.64 16 16 12.64 16 8.5C16 7.47 15.8 6.48 15.41 5.59L14.41 6.59z'); + }); + + it('dependent', () => { + assert.equal(new SVGPathData('M1 1h7.5l2 2H9L8 2H1v12h10v-1h1v1c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1zm9 6h3v1h-3V7zm2 2h-2v1h2V9zM8.583 4h4.375L15 6v5.429a.58.58 0 01-.583.571H8.583A.58.58 0 018 11.429V10h1v1h5V6.5L12.5 5H9v1H8V4.571A.58.58 0 018.583 4zM9.5 7H6.667V5l-4 3 4 3V9H9.5V7z').toAbs().round(1000).encode(), 'M1 1H8.5L10.5 3H9L8 2H1V14H11V13H12V14C12 14.55 11.55 15 11 15H1C0.45 15 0 14.55 0 14V2C0 1.45 0.45 1 1 1zM10 7H13V8H10V7zM12 9H10V10H12V9zM8.583 4H12.958L15 6V11.429A0.58 0.58 0 0 1 14.417 12H8.583A0.58 0.58 0 0 1 8 11.429V10H9V11H14V6.5L12.5 5H9V6H8V4.571A0.58 0.58 0 0 1 8.583 4zM9.5 7H6.667V5L2.667 8L6.667 11V9H9.5V7z'); + }); + + it('kebab-vertical', () => { + assert.equal(new SVGPathData('M0 2.5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zm0 5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zM1.5 14a1.5 1.5 0 110-3 1.5 1.5 0 010 3z').toAbs().round(1000).encode(), 'M0 2.5A1.5 1.5 0 1 0 3 2.5A1.5 1.5 0 0 0 0 2.5zM0 7.5A1.5 1.5 0 1 0 3 7.5A1.5 1.5 0 0 0 0 7.5zM1.5 14A1.5 1.5 0 1 1 1.5 11A1.5 1.5 0 0 1 1.5 14z'); + }); + + it('of kaptinlin bug report unicons voicemail-rectangle', () => { + assert.equal(new SVGPathData('M20 4H4a3 3 0 00-3 3v10a3 3 0 003 3h16a3 3 0 003-3V7a3 3 0 00-3-3zm1 13a1 1 0 01-1 1H4a1 1 0 01-1-1V7a1 1 0 011-1h16a1 1 0 011 1zm-5-8a3 3 0 00-2.82 4h-2.36A3 3 0 108 15h8a3 3 0 000-6zm-8 4a1 1 0 111-1 1 1 0 01-1 1zm8 0a1 1 0 111-1 1 1 0 01-1 1z').toAbs().round(1000).encode(), 'M20 4H4A3 3 0 0 0 1 7V17A3 3 0 0 0 4 20H20A3 3 0 0 0 23 17V7A3 3 0 0 0 20 4zM21 17A1 1 0 0 1 20 18H4A1 1 0 0 1 3 17V7A1 1 0 0 1 4 6H20A1 1 0 0 1 21 7zM16 9A3 3 0 0 0 13.18 13H10.82A3 3 0 1 0 8 15H16A3 3 0 0 0 16 9zM8 13A1 1 0 1 1 9 12A1 1 0 0 1 8 13zM16 13A1 1 0 1 1 17 12A1 1 0 0 1 16 13z'); + }); + + it('of kaptinlin bug report unicons venus', () => { + assert.equal(new SVGPathData('M19 9a7 7 0 10-8 6.92V18h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2h-1v-2.08A7 7 0 0019 9zm-7 5a5 5 0 115-5 5 5 0 01-5 5z').toAbs().round(1000).encode(), 'M19 9A7 7 0 1 0 11 15.92V18H10A1 1 0 0 0 10 20H11V21A1 1 0 0 0 13 21V20H14A1 1 0 0 0 14 18H13V15.92A7 7 0 0 0 19 9zM12 14A5 5 0 1 1 17 9A5 5 0 0 1 12 14z'); + }); + + it('of kaptinlin bug report unicons vector-square', () => { + assert.equal(new SVGPathData('M20 16.18V7.82A3 3 0 1016.18 4H7.82A3 3 0 104 7.82v8.36A3 3 0 107.82 20h8.36A3 3 0 1020 16.18zM19 4a1 1 0 11-1 1 1 1 0 011-1zM5 4a1 1 0 11-1 1 1 1 0 011-1zm0 16a1 1 0 111-1 1 1 0 01-1 1zm11.18-2H7.82A3 3 0 006 16.18V7.82A3 3 0 007.82 6h8.36A3 3 0 0018 7.82v8.36A3 3 0 0016.18 18zM19 20a1 1 0 111-1 1 1 0 01-1 1z').toAbs().round(1000).encode(), 'M20 16.18V7.82A3 3 0 1 0 16.18 4H7.82A3 3 0 1 0 4 7.82V16.18A3 3 0 1 0 7.82 20H16.18A3 3 0 1 0 20 16.18zM19 4A1 1 0 1 1 18 5A1 1 0 0 1 19 4zM5 4A1 1 0 1 1 4 5A1 1 0 0 1 5 4zM5 20A1 1 0 1 1 6 19A1 1 0 0 1 5 20zM16.18 18H7.82A3 3 0 0 0 6 16.18V7.82A3 3 0 0 0 7.82 6H16.18A3 3 0 0 0 18 7.82V16.18A3 3 0 0 0 16.18 18zM19 20A1 1 0 1 1 20 19A1 1 0 0 1 19 20z'); + }); + + it('of kaptinlin bug report unicons user', () => { + assert.equal(new SVGPathData('M15.71 12.71a6 6 0 10-7.42 0 10 10 0 00-6.22 8.18 1 1 0 002 .22 8 8 0 0115.9 0 1 1 0 001 .89h.11a1 1 0 00.88-1.1 10 10 0 00-6.25-8.19zM12 12a4 4 0 114-4 4 4 0 01-4 4z').toAbs().round(1000).encode(), 'M15.71 12.71A6 6 0 1 0 8.29 12.71A10 10 0 0 0 2.07 20.89A1 1 0 0 0 4.07 21.11A8 8 0 0 1 19.97 21.11A1 1 0 0 0 20.97 22H21.08A1 1 0 0 0 21.96 20.9A10 10 0 0 0 15.71 12.71zM12 12A4 4 0 1 1 16 8A4 4 0 0 1 12 12z'); + }); + + it('of kaptinlin bug report unicons user-plus', () => { + assert.equal(new SVGPathData('M21 10.5h-1v-1a1 1 0 00-2 0v1h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2zm-7.7 1.72A4.92 4.92 0 0015 8.5a5 5 0 00-10 0 4.92 4.92 0 001.7 3.72A8 8 0 002 19.5a1 1 0 002 0 6 6 0 0112 0 1 1 0 002 0 8 8 0 00-4.7-7.28zM10 11.5a3 3 0 113-3 3 3 0 01-3 3z').toAbs().round(1000).encode(), 'M21 10.5H20V9.5A1 1 0 0 0 18 9.5V10.5H17A1 1 0 0 0 17 12.5H18V13.5A1 1 0 0 0 20 13.5V12.5H21A1 1 0 0 0 21 10.5zM13.3 12.22A4.92 4.92 0 0 0 15 8.5A5 5 0 0 0 5 8.5A4.92 4.92 0 0 0 6.7 12.22A8 8 0 0 0 2 19.5A1 1 0 0 0 4 19.5A6 6 0 0 1 16 19.5A1 1 0 0 0 18 19.5A8 8 0 0 0 13.3 12.22zM10 11.5A3 3 0 1 1 13 8.5A3 3 0 0 1 10 11.5z'); + }); + }); });