From cb7aefc89905a66c74f1fece8901ed876392488d Mon Sep 17 00:00:00 2001 From: Preet Shihn Date: Mon, 18 Jun 2018 15:32:41 -0700 Subject: [PATCH] some refactoring --- bin/path.js | 48 ++++++++++++++++++------------------- dist/rough.es5.js | 48 ++++++++++++++++++------------------- dist/rough.es5.min.js | 2 +- dist/rough.js | 48 ++++++++++++++++++------------------- dist/rough.min.js | 2 +- dist/rough.umd.es5.js | 48 ++++++++++++++++++------------------- dist/rough.umd.es5.min.js | 2 +- dist/rough.umd.js | 48 ++++++++++++++++++------------------- dist/rough.umd.min.js | 2 +- src/path.ts | 50 +++++++++++++++++++-------------------- 10 files changed, 149 insertions(+), 149 deletions(-) diff --git a/bin/path.js b/bin/path.js index 5ae57c5..30e3413 100644 --- a/bin/path.js +++ b/bin/path.js @@ -2,26 +2,26 @@ function isType(token, type) { return token.type === type; } const PARAMS = { - A: { length: 7 }, - a: { length: 7 }, - C: { length: 6 }, - c: { length: 6 }, - H: { length: 1 }, - h: { length: 1 }, - L: { length: 2 }, - l: { length: 2 }, - M: { length: 2 }, - m: { length: 2 }, - Q: { length: 4 }, - q: { length: 4 }, - S: { length: 4 }, - s: { length: 4 }, - T: { length: 4 }, - t: { length: 2 }, - V: { length: 1 }, - v: { length: 1 }, - Z: { length: 0 }, - z: { length: 0 } + A: 7, + a: 7, + C: 6, + c: 6, + H: 1, + h: 1, + L: 2, + l: 2, + M: 2, + m: 2, + Q: 4, + q: 4, + S: 4, + s: 4, + T: 4, + t: 2, + V: 1, + v: 1, + Z: 0, + z: 0 }; class ParsedPath { constructor(d) { @@ -66,7 +66,7 @@ class ParsedPath { if (mode === 'BOD') { if (token.text === 'M' || token.text === 'm') { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } else { @@ -76,11 +76,11 @@ class ParsedPath { } else { if (isType(token, this.NUMBER)) { - param_length = PARAMS[mode].length; + param_length = PARAMS[mode]; } else { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } } @@ -95,7 +95,7 @@ class ParsedPath { return; } } - if (PARAMS[mode]) { + if (typeof PARAMS[mode] === 'number') { const segment = { key: mode, data: params }; this.segments.push(segment); index += param_length; diff --git a/dist/rough.es5.js b/dist/rough.es5.js index 399d4ce..6ab7909 100644 --- a/dist/rough.es5.js +++ b/dist/rough.es5.js @@ -59,26 +59,26 @@ var rough = (function () { return token.type === type; } var PARAMS = { - A: { length: 7 }, - a: { length: 7 }, - C: { length: 6 }, - c: { length: 6 }, - H: { length: 1 }, - h: { length: 1 }, - L: { length: 2 }, - l: { length: 2 }, - M: { length: 2 }, - m: { length: 2 }, - Q: { length: 4 }, - q: { length: 4 }, - S: { length: 4 }, - s: { length: 4 }, - T: { length: 4 }, - t: { length: 2 }, - V: { length: 1 }, - v: { length: 1 }, - Z: { length: 0 }, - z: { length: 0 } + A: 7, + a: 7, + C: 6, + c: 6, + H: 1, + h: 1, + L: 2, + l: 2, + M: 2, + m: 2, + Q: 4, + q: 4, + S: 4, + s: 4, + T: 4, + t: 2, + V: 1, + v: 1, + Z: 0, + z: 0 }; var ParsedPath = function () { @@ -128,7 +128,7 @@ var rough = (function () { if (mode === 'BOD') { if (token.text === 'M' || token.text === 'm') { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } else { this.parseData('M0,0' + d); @@ -136,10 +136,10 @@ var rough = (function () { } } else { if (isType(token, this.NUMBER)) { - param_length = PARAMS[mode].length; + param_length = PARAMS[mode]; } else { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } } @@ -153,7 +153,7 @@ var rough = (function () { return; } } - if (PARAMS[mode]) { + if (typeof PARAMS[mode] === 'number') { var segment = { key: mode, data: params }; this.segments.push(segment); index += param_length; diff --git a/dist/rough.es5.min.js b/dist/rough.es5.min.js index 003de9a..a07f8f2 100644 --- a/dist/rough.es5.min.js +++ b/dist/rough.es5.min.js @@ -1 +1 @@ -var rough=function(){"use strict";function e(e,t){return e.type===t}function t(e,t){var l=t.fillStyle||"hachure";if(!T[l])switch(l){case"zigzag":T[l]||(T[l]=new S(e));break;case"cross-hatch":T[l]||(T[l]=new A(e));break;case"hachure":default:l="hachure",T[l]||(T[l]=new O(e));}return T[l]}function l(e){if(z&&E&&self&&self.workly&&e.async&&!e.noWorker){var t=e.worklyURL||"https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js";if(t){var l=URL.createObjectURL(new Blob(["importScripts('"+t+"', '"+E+"');\nworkly.expose(self.rough.createRenderer());"]));return self.workly.proxy(l)}}return new C}var a=Math.round,n=Math.max,s=Math.min,i=Math.pow,r=Math.floor,p=Math.sqrt,d=Math.cos,h=Math.sin,g=Math.abs,f=Math.PI,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var l,a=0;a_){var k=p(1-_/(this._rx*this._rx*this._ry*this._ry));this._rx*=k,this._ry*=k,v=0}else v=(i===o?-1:1)*p(_/(this._rx*this._rx*c*c+this._ry*this._ry*y*y));var s=v*this._rx*c/this._ry,x=-v*this._ry*y/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*s-this._sinPhi*x+(t[0]+l[0])/2,this._C[1]=this._sinPhi*s+this._cosPhi*x+(t[1]+l[1])/2,this._theta=this.calculateVectorAngle(1,0,(y-s)/this._rx,(c-x)/this._ry);var b=this.calculateVectorAngle((y-s)/this._rx,(c-x)/this._ry,(-y-s)/this._rx,(-c-x)/this._ry);!o&&0b&&(b+=2*f),this._numSegs=Math.ceil(g(b/(f/2))),this._delta=b/this._numSegs,this._T=8/3*h(this._delta/4)*h(this._delta/4)/h(this._delta/2)}}return y(e,[{key:"getNextSegment",value:function(){if(this._segIndex===this._numSegs)return null;var e=d(this._theta),t=h(this._theta),l=this._theta+this._delta,a=d(l),n=h(l),i=[this._cosPhi*this._rx*a-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*a+this._cosPhi*this._ry*n+this._C[1]],s=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[i[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*a),i[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*a)];return this._theta=l,this._from=[i[0],i[1]],this._segIndex++,{cp1:s,cp2:o,to:i}}},{key:"calculateVectorAngle",value:function(e,t,l,a){var n=Math.atan2,i=n(t,e),s=n(a,l);return s>=i?s-i:2*f-(i-s)}}]),e}(),m=function(){function e(t,l){u(this,e),this.sets=t,this.closed=l}return y(e,[{key:"fit",value:function(e){var t=[],l=!0,a=!1,n=void 0;try{for(var s,o=this.sets[Symbol.iterator]();!(l=(s=o.next()).done);l=!0){var p=s.value,h=p.length,g=r(e*h);if(5>g){if(5>=h)continue;g=5}t.push(this.reduce(p,g))}}catch(e){a=!0,n=e}finally{try{!l&&o.return&&o.return()}finally{if(a)throw n}}var f="",u=!0,y=!1,c=void 0;try{for(var v,_,k=t[Symbol.iterator]();!(u=(v=k.next()).done);u=!0){_=v.value;for(var x,b=0;b<_.length;b++)x=_[b],f+=0===b?"M"+x[0]+","+x[1]:"L"+x[0]+","+x[1];this.closed&&(f+="z ")}}catch(e){y=!0,c=e}finally{try{!u&&k.return&&k.return()}finally{if(y)throw c}}return f}},{key:"distance",value:function(e,t){return p(i(e[0]-t[0],2)+i(e[1]-t[1],2))}},{key:"reduce",value:function(e,t){if(e.length<=t)return e;for(var l=e.slice(0);l.length>t;){for(var n=-1,o=-1,r=1;rn||s=s(e.py1,e.py2)&&this.py1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=s(e.py1,e.py2)&&this.py2<=n(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+r,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===t?(this.xi=e.px1,this.yi=l*this.xi+o,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(p))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):l===i?o==r&&(this.px1>=s(e.px1,e.px2)&&this.px1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=s(e.px1,e.px2)&&this.px2<=n(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(r-o)/(l-i),this.yi=l*this.xi+o,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}]),e}(),P=function(){function e(t,l,a,n,i,s,o,r){u(this,e),this.deltaX=0,this.hGap=0,this.top=t,this.bottom=l,this.left=a,this.right=n,this.gap=i,this.sinAngle=s,this.tanAngle=r,1e-4>g(s)?this.pos=a+i:.9999g(this.sinAngle)){if(this.posthis.right&&l>this.right;)if(this.pos+=this.hGap,t=this.pos-this.deltaX/2,l=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;var i=new w([t,a],[l,n]);this.sLeft&&i.intersects(this.sLeft)&&(t=i.xi,a=i.yi),this.sRight&&i.intersects(this.sRight)&&(l=i.xi,n=i.yi),0v&&(v=4*l.strokeWidth),v=n(v,.1);for(var _=c%180*(f/180),k=d(_),x=h(_),b=t(_),m=new P(g-1,u+1,r-1,p+1,v,x,k,b),w=void 0,O=null;null!=(w=m.nextLine());)for(var S=this.getIntersectingLines(w,e),A=0;A=u&&(u=4*i.strokeWidth);var y=i.fillWeight;0>y&&(y=i.strokeWidth/2);for(var c=t(h%180*(f/180)),v=d/r,_=p(v*c*v*c+1),k=v*c/_,x=1/_,b=u/(r*d/p(d*x*(d*x)+r*k*(r*k))/r),m=p(r*r-(e-r+b)*(e-r+b)),w=null,P=e-r+b;P_;)_+=2*f,k+=2*f;k-_>2*f&&(_=0,k=2*f);var x=2*f/u.curveStepCount,b=s(x/2,(k-_)/2),m=this._arc(b,o,y,c,v,_,k,1,u),w=this._arc(b,o,y,c,v,_,k,1.5,u),P=m.concat(w);return r&&(p?(P=P.concat(this.doubleLine(o,y,o+c*d(_),y+v*h(_),u)),P=P.concat(this.doubleLine(o,y,o+c*d(k),y+v*h(k),u))):(P.push({op:"lineTo",data:[o,y]}),P.push({op:"lineTo",data:[o+c*d(_),y+v*h(_)]}))),{type:"path",ops:P}}},{key:"svgPath",value:function(e,t){e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");var l=new x(e);if(t.simplification){var a=new m(l.linearPoints,l.closed),n=a.fit(t.simplification);l=new x(n)}for(var o=[],r=l.segments||[],d=0;dy;)y+=2*f,c+=2*f;c-y>2*f&&(y=0,c=2*f);for(var v=(c-y)/s.curveStepCount,_=[],k=y;k<=c;k+=v)_.push([o+p*d(k),r+u*h(k)]);return _.push([o+p*d(c),r+u*h(c)]),_.push([o,r]),this.patternFillPolygon(_,s)}},{key:"getOffset",value:function(e,t,l){return l.roughness*(Math.random()*(t-e)+e)}},{key:"doubleLine",value:function(e,t,l,a,n){var i=this._line(e,t,l,a,n,!0,!1),s=this._line(e,t,l,a,n,!0,!0);return i.concat(s)}},{key:"_line",value:function(e,t,l,a,n,s,o){var r=i(e-l,2)+i(t-a,2),d=n.maxRandomnessOffset||0;100*(d*d)>r&&(d=p(r)/10);var h=d/2,g=.2+.2*Math.random(),f=n.bowing*n.maxRandomnessOffset*(a-t)/200,u=n.bowing*n.maxRandomnessOffset*(e-l)/200;f=this.getOffset(-f,f,n),u=this.getOffset(-u,u,n);var y=[];return s&&(o?y.push({op:"move",data:[e+this.getOffset(-h,h,n),t+this.getOffset(-h,h,n)]}):y.push({op:"move",data:[e+this.getOffset(-d,d,n),t+this.getOffset(-d,d,n)]})),o?y.push({op:"bcurveTo",data:[f+e+(l-e)*g+this.getOffset(-h,h,n),u+t+(a-t)*g+this.getOffset(-h,h,n),f+e+2*(l-e)*g+this.getOffset(-h,h,n),u+t+2*(a-t)*g+this.getOffset(-h,h,n),l+this.getOffset(-h,h,n),a+this.getOffset(-h,h,n)]}):y.push({op:"bcurveTo",data:[f+e+(l-e)*g+this.getOffset(-d,d,n),u+t+(a-t)*g+this.getOffset(-d,d,n),f+e+2*(l-e)*g+this.getOffset(-d,d,n),u+t+2*(a-t)*g+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),a+this.getOffset(-d,d,n)]}),y}},{key:"_curve",value:function(e,t,l){var a=e.length,n=[];if(3g;g++)0===g?o.push({op:"move",data:[r.x,r.y]}):o.push({op:"move",data:[r.x+this.getOffset(-d[0],d[0],p),r.y+this.getOffset(-d[0],d[0],p)]}),h=[n+this.getOffset(-d[g],d[g],p),s+this.getOffset(-d[g],d[g],p)],o.push({op:"bcurveTo",data:[e+this.getOffset(-d[g],d[g],p),t+this.getOffset(-d[g],d[g],p),l+this.getOffset(-d[g],d[g],p),a+this.getOffset(-d[g],d[g],p),h[0],h[1]]});return r.setPosition(h[0],h[1]),o}},{key:"_processSegment",value:function(e,t,l,a){var n=[];switch(t.key){case"M":case"m":{var s="m"===t.key;if(2<=t.data.length){var o=+t.data[0],r=+t.data[1];s&&(o+=e.x,r+=e.y);var p=1*(a.maxRandomnessOffset||0);o+=this.getOffset(-p,p,a),r+=this.getOffset(-p,p,a),e.setPosition(o,r),n.push({op:"move",data:[o,r]})}break}case"L":case"l":{var d="l"===t.key;if(2<=t.data.length){var h=+t.data[0],g=+t.data[1];d&&(h+=e.x,g+=e.y),n=n.concat(this.doubleLine(e.x,e.y,h,g,a)),e.setPosition(h,g)}break}case"H":case"h":{var u="h"===t.key;if(t.data.length){var c=+t.data[0];u&&(c+=e.x),n=n.concat(this.doubleLine(e.x,e.y,c,e.y,a)),e.setPosition(c,e.y)}break}case"V":case"v":{var v="v"===t.key;if(t.data.length){var _=+t.data[0];v&&(_+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,_,a)),e.setPosition(e.x,_)}break}case"Z":case"z":{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],a)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case"C":case"c":{var k="c"===t.key;if(6<=t.data.length){var m=+t.data[0],w=+t.data[1],P=+t.data[2],O=+t.data[3],S=+t.data[4],A=+t.data[5];k&&(m+=e.x,P+=e.x,S+=e.x,w+=e.y,O+=e.y,A+=e.y);var T=this._bezierTo(m,w,P,O,S,A,e,a);n=n.concat(T),e.bezierReflectionPoint=[S+(S-P),A+(A-O)]}break}case"S":case"s":{var C="s"===t.key;if(4<=t.data.length){var z=+t.data[0],E=+t.data[1],L=+t.data[2],R=+t.data[3];C&&(z+=e.x,L+=e.x,E+=e.y,R+=e.y);var W=z,N=E,D=l?l.key:"",B=null;("c"===D||"C"===D||"s"===D||"S"===D)&&(B=e.bezierReflectionPoint),B&&(W=B[0],N=B[1]);var F=this._bezierTo(W,N,z,E,L,R,e,a);n=n.concat(F),e.bezierReflectionPoint=[L+(L-z),R+(R-E)]}break}case"Q":case"q":{var M="q"===t.key;if(4<=t.data.length){var q=+t.data[0],U=+t.data[1],X=+t.data[2],V=+t.data[3];M&&(q+=e.x,X+=e.x,U+=e.y,V+=e.y);var G=1*(1+.2*a.roughness),I=1.5*(1+.22*a.roughness);n.push({op:"move",data:[e.x+this.getOffset(-G,G,a),e.y+this.getOffset(-G,G,a)]});var j=[X+this.getOffset(-G,G,a),V+this.getOffset(-G,G,a)];n.push({op:"qcurveTo",data:[q+this.getOffset(-G,G,a),U+this.getOffset(-G,G,a),j[0],j[1]]}),n.push({op:"move",data:[e.x+this.getOffset(-I,I,a),e.y+this.getOffset(-I,I,a)]}),j=[X+this.getOffset(-I,I,a),V+this.getOffset(-I,I,a)],n.push({op:"qcurveTo",data:[q+this.getOffset(-I,I,a),U+this.getOffset(-I,I,a),j[0],j[1]]}),e.setPosition(j[0],j[1]),e.quadReflectionPoint=[X+(X-q),V+(V-U)]}break}case"T":case"t":{var Q="t"===t.key;if(2<=t.data.length){var $=+t.data[0],Z=+t.data[1];Q&&($+=e.x,Z+=e.y);var H=$,J=Z,Y=l?l.key:"",K=null;("q"===Y||"Q"===Y||"t"===Y||"T"===Y)&&(K=e.quadReflectionPoint),K&&(H=K[0],J=K[1]);var ee=1*(1+.2*a.roughness),te=1.5*(1+.22*a.roughness);n.push({op:"move",data:[e.x+this.getOffset(-ee,ee,a),e.y+this.getOffset(-ee,ee,a)]});var le=[$+this.getOffset(-ee,ee,a),Z+this.getOffset(-ee,ee,a)];n.push({op:"qcurveTo",data:[H+this.getOffset(-ee,ee,a),J+this.getOffset(-ee,ee,a),le[0],le[1]]}),n.push({op:"move",data:[e.x+this.getOffset(-te,te,a),e.y+this.getOffset(-te,te,a)]}),le=[$+this.getOffset(-te,te,a),Z+this.getOffset(-te,te,a)],n.push({op:"qcurveTo",data:[H+this.getOffset(-te,te,a),J+this.getOffset(-te,te,a),le[0],le[1]]}),e.setPosition(le[0],le[1]),e.quadReflectionPoint=[$+($-H),Z+(Z-J)]}break}case"A":case"a":{var ae="a"===t.key;if(7<=t.data.length){var ne=+t.data[0],ie=+t.data[1],se=+t.data[2],oe=+t.data[3],re=+t.data[4],pe=+t.data[5],de=+t.data[6];if(ae&&(pe+=e.x,de+=e.y),pe===e.x&&de===e.y)break;if(0==ne||0==ie)n=n.concat(this.doubleLine(e.x,e.y,pe,de,a)),e.setPosition(pe,de);else for(var he=0;1>he;he++)for(var ge,fe=new b([e.x,e.y],[pe,de],[ne,ie],se,!!oe,!!re),ue=fe.getNextSegment();ue;)ge=this._bezierTo(ue.cp1[0],ue.cp1[1],ue.cp2[0],ue.cp2[1],ue.to[0],ue.to[1],e,a),n=n.concat(ge),ue=fe.getNextSegment()}break}default:}return n}}]),e}(),z="undefined"!=typeof self,E=z&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,L="undefined"!=typeof self,R=function(){function e(t,a){u(this,e),this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=t||{},this.surface=a,this.renderer=l(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}return y(e,[{key:"_options",value:function(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}},{key:"_drawable",value:function(e,t,l){return{shape:e,sets:t||[],options:l||this.defaultOptions}}},{key:"getCanvasSize",value:function(){var e=function(e){return e&&"object"===("undefined"==typeof e?"undefined":o(e))&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100};return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}},{key:"computePolygonSize",value:function(e){if(e.length){for(var t=e[0][0],l=e[0][0],a=e[0][1],o=e[0][1],r=1;rl&&(l=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||"none",strokeWidth:l,fill:"none"}}},{key:"opsToPath",value:function(e){var t="",l=!0,a=!1,n=void 0;try{for(var i,s=e.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case"move":t+="M"+r[0]+" "+r[1]+" ";break;case"bcurveTo":t+="C"+r[0]+" "+r[1]+", "+r[2]+" "+r[3]+", "+r[4]+" "+r[5]+" ";break;case"qcurveTo":t+="Q"+r[0]+" "+r[1]+", "+r[2]+" "+r[3]+" ";break;case"lineTo":t+="L"+r[0]+" "+r[1]+" ";}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}return t.trim()}},{key:"lib",get:function(){return this.renderer}}]),e}(),W="undefined"!=typeof document,N=function(){function e(t,l){u(this,e),this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new R(l||null,this.canvas)}return y(e,[{key:"line",value:function(e,t,l,a,n){var i=this.gen.line(e,t,l,a,n);return this.draw(i),i}},{key:"rectangle",value:function(e,t,l,a,n){var i=this.gen.rectangle(e,t,l,a,n);return this.draw(i),i}},{key:"ellipse",value:function(e,t,l,a,n){var i=this.gen.ellipse(e,t,l,a,n);return this.draw(i),i}},{key:"circle",value:function(e,t,l,a){var n=this.gen.circle(e,t,l,a);return this.draw(n),n}},{key:"linearPath",value:function(e,t){var l=this.gen.linearPath(e,t);return this.draw(l),l}},{key:"polygon",value:function(e,t){var l=this.gen.polygon(e,t);return this.draw(l),l}},{key:"arc",value:function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2),e.save(),e.strokeStyle=l.fill||"",e.lineWidth=a,this._drawToContext(e,t),e.restore()}},{key:"_drawToContext",value:function(e,t){e.beginPath();var l=!0,a=!1,n=void 0;try{for(var i,s=t.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case"move":e.moveTo(r[0],r[1]);break;case"bcurveTo":e.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"qcurveTo":e.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"lineTo":e.lineTo(r[0],r[1]);}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}"fillPath"===t.type?e.fill():e.stroke()}},{key:"generator",get:function(){return this.gen}}],[{key:"createRenderer",value:function(){return new C}}]),e}(),D=function(e){function t(){return u(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),y(t,[{key:"line",value:async function(e,t,l,a,n){var i=this._options(n);return this._drawable("line",[await this.lib.line(e,t,l,a,i)],i)}},{key:"rectangle",value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill){var o=[[e,t],[e+l,t],[e+l,t+a],[e,t+a]];"solid"===i.fillStyle?s.push((await this.lib.solidFillPolygon(o,i))):s.push((await this.lib.patternFillPolygon(o,i)))}return s.push((await this.lib.rectangle(e,t,l,a,i))),this._drawable("rectangle",s,i)}},{key:"ellipse",value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill)if("solid"===i.fillStyle){var o=await this.lib.ellipse(e,t,l,a,i);o.type="fillPath",s.push(o)}else s.push((await this.lib.patternFillEllipse(e,t,l,a,i)));return s.push((await this.lib.ellipse(e,t,l,a,i))),this._drawable("ellipse",s,i)}},{key:"circle",value:async function(e,t,l,a){var n=await this.ellipse(e,t,l,l,a);return n.shape="circle",n}},{key:"linearPath",value:async function(e,t){var l=this._options(t);return this._drawable("linearPath",[await this.lib.linearPath(e,!1,l)],l)}},{key:"arc",value:async function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2);var n=e.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",this.opsToPath(t)),n.style.stroke=l.fill,n.style.strokeWidth=a+"",n.style.fill="none",n}},{key:"generator",get:function(){return this.gen}},{key:"defs",get:function(){if(F&&!this._defs){var e=this.svg.ownerDocument||document,t=e.createElementNS("http://www.w3.org/2000/svg","defs");this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}}],[{key:"createRenderer",value:function(){return new C}}]),e}(),q=function(e){function t(e,l){u(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l));return a.genAsync=new D(l||null,a.svg),a}return c(t,e),y(t,[{key:"line",value:async function(e,t,l,a,n){var i=await this.genAsync.line(e,t,l,a,n);return this.draw(i)}},{key:"rectangle",value:async function(e,t,l,a,n){var i=await this.genAsync.rectangle(e,t,l,a,n);return this.draw(i)}},{key:"ellipse",value:async function(e,t,l,a,n){var i=await this.genAsync.ellipse(e,t,l,a,n);return this.draw(i)}},{key:"circle",value:async function(e,t,l,a){var n=await this.genAsync.circle(e,t,l,a);return this.draw(n)}},{key:"linearPath",value:async function(e,t){var l=await this.genAsync.linearPath(e,t);return this.draw(l)}},{key:"polygon",value:async function(e,t){var l=await this.genAsync.polygon(e,t);return this.draw(l)}},{key:"arc",value:async function(e,t,l,a,n,i){var s=!!(6_){var k=p(1-_/(this._rx*this._rx*this._ry*this._ry));this._rx*=k,this._ry*=k,v=0}else v=(i===o?-1:1)*p(_/(this._rx*this._rx*c*c+this._ry*this._ry*y*y));var s=v*this._rx*c/this._ry,x=-v*this._ry*y/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*s-this._sinPhi*x+(t[0]+l[0])/2,this._C[1]=this._sinPhi*s+this._cosPhi*x+(t[1]+l[1])/2,this._theta=this.calculateVectorAngle(1,0,(y-s)/this._rx,(c-x)/this._ry);var b=this.calculateVectorAngle((y-s)/this._rx,(c-x)/this._ry,(-y-s)/this._rx,(-c-x)/this._ry);!o&&0b&&(b+=2*h),this._numSegs=Math.ceil(u(b/(h/2))),this._delta=b/this._numSegs,this._T=8/3*f(this._delta/4)*f(this._delta/4)/f(this._delta/2)}}return y(e,[{key:"getNextSegment",value:function(){if(this._segIndex===this._numSegs)return null;var e=d(this._theta),t=f(this._theta),l=this._theta+this._delta,a=d(l),n=f(l),i=[this._cosPhi*this._rx*a-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*a+this._cosPhi*this._ry*n+this._C[1]],s=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[i[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*a),i[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*a)];return this._theta=l,this._from=[i[0],i[1]],this._segIndex++,{cp1:s,cp2:o,to:i}}},{key:"calculateVectorAngle",value:function(e,t,l,a){var n=Math.atan2,i=n(t,e),s=n(a,l);return s>=i?s-i:2*h-(i-s)}}]),e}(),m=function(){function e(t,l){g(this,e),this.sets=t,this.closed=l}return y(e,[{key:"fit",value:function(e){var t=[],l=!0,a=!1,n=void 0;try{for(var s,o=this.sets[Symbol.iterator]();!(l=(s=o.next()).done);l=!0){var p=s.value,f=p.length,u=r(e*f);if(5>u){if(5>=f)continue;u=5}t.push(this.reduce(p,u))}}catch(e){a=!0,n=e}finally{try{!l&&o.return&&o.return()}finally{if(a)throw n}}var h="",g=!0,y=!1,c=void 0;try{for(var v,_,k=t[Symbol.iterator]();!(g=(v=k.next()).done);g=!0){_=v.value;for(var x,b=0;b<_.length;b++)x=_[b],h+=0===b?"M"+x[0]+","+x[1]:"L"+x[0]+","+x[1];this.closed&&(h+="z ")}}catch(e){y=!0,c=e}finally{try{!g&&k.return&&k.return()}finally{if(y)throw c}}return h}},{key:"distance",value:function(e,t){return p(i(e[0]-t[0],2)+i(e[1]-t[1],2))}},{key:"reduce",value:function(e,t){if(e.length<=t)return e;for(var l=e.slice(0);l.length>t;){for(var n=-1,o=-1,r=1;rn||s=s(e.py1,e.py2)&&this.py1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=s(e.py1,e.py2)&&this.py2<=n(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+r,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>u(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===t?(this.xi=e.px1,this.yi=l*this.xi+o,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>u(p))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):l===i?o==r&&(this.px1>=s(e.px1,e.px2)&&this.px1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=s(e.px1,e.px2)&&this.px2<=n(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(r-o)/(l-i),this.yi=l*this.xi+o,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}]),e}(),P=function(){function e(t,l,a,n,i,s,o,r){g(this,e),this.deltaX=0,this.hGap=0,this.top=t,this.bottom=l,this.left=a,this.right=n,this.gap=i,this.sinAngle=s,this.tanAngle=r,1e-4>u(s)?this.pos=a+i:.9999u(this.sinAngle)){if(this.posthis.right&&l>this.right;)if(this.pos+=this.hGap,t=this.pos-this.deltaX/2,l=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;var i=new w([t,a],[l,n]);this.sLeft&&i.intersects(this.sLeft)&&(t=i.xi,a=i.yi),this.sRight&&i.intersects(this.sRight)&&(l=i.xi,n=i.yi),0v&&(v=4*l.strokeWidth),v=n(v,.1);for(var _=c%180*(h/180),k=d(_),x=f(_),b=t(_),m=new P(u-1,g+1,r-1,p+1,v,x,k,b),w=void 0,O=null;null!=(w=m.nextLine());)for(var S=this.getIntersectingLines(w,e),A=0;A=g&&(g=4*i.strokeWidth);var y=i.fillWeight;0>y&&(y=i.strokeWidth/2);for(var c=t(f%180*(h/180)),v=d/r,_=p(v*c*v*c+1),k=v*c/_,x=1/_,b=g/(r*d/p(d*x*(d*x)+r*k*(r*k))/r),m=p(r*r-(e-r+b)*(e-r+b)),w=null,P=e-r+b;P_;)_+=2*h,k+=2*h;k-_>2*h&&(_=0,k=2*h);var x=2*h/g.curveStepCount,b=s(x/2,(k-_)/2),m=this._arc(b,o,y,c,v,_,k,1,g),w=this._arc(b,o,y,c,v,_,k,1.5,g),P=m.concat(w);return r&&(p?(P=P.concat(this.doubleLine(o,y,o+c*d(_),y+v*f(_),g)),P=P.concat(this.doubleLine(o,y,o+c*d(k),y+v*f(k),g))):(P.push({op:"lineTo",data:[o,y]}),P.push({op:"lineTo",data:[o+c*d(_),y+v*f(_)]}))),{type:"path",ops:P}}},{key:"svgPath",value:function(e,t){e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");var l=new x(e);if(t.simplification){var a=new m(l.linearPoints,l.closed),n=a.fit(t.simplification);l=new x(n)}for(var o=[],r=l.segments||[],d=0;dy;)y+=2*h,c+=2*h;c-y>2*h&&(y=0,c=2*h);for(var v=(c-y)/s.curveStepCount,_=[],k=y;k<=c;k+=v)_.push([o+p*d(k),r+g*f(k)]);return _.push([o+p*d(c),r+g*f(c)]),_.push([o,r]),this.patternFillPolygon(_,s)}},{key:"getOffset",value:function(e,t,l){return l.roughness*(Math.random()*(t-e)+e)}},{key:"doubleLine",value:function(e,t,l,a,n){var i=this._line(e,t,l,a,n,!0,!1),s=this._line(e,t,l,a,n,!0,!0);return i.concat(s)}},{key:"_line",value:function(e,t,l,a,n,s,o){var r=i(e-l,2)+i(t-a,2),d=n.maxRandomnessOffset||0;100*(d*d)>r&&(d=p(r)/10);var f=d/2,u=.2+.2*Math.random(),h=n.bowing*n.maxRandomnessOffset*(a-t)/200,g=n.bowing*n.maxRandomnessOffset*(e-l)/200;h=this.getOffset(-h,h,n),g=this.getOffset(-g,g,n);var y=[];return s&&(o?y.push({op:"move",data:[e+this.getOffset(-f,f,n),t+this.getOffset(-f,f,n)]}):y.push({op:"move",data:[e+this.getOffset(-d,d,n),t+this.getOffset(-d,d,n)]})),o?y.push({op:"bcurveTo",data:[h+e+(l-e)*u+this.getOffset(-f,f,n),g+t+(a-t)*u+this.getOffset(-f,f,n),h+e+2*(l-e)*u+this.getOffset(-f,f,n),g+t+2*(a-t)*u+this.getOffset(-f,f,n),l+this.getOffset(-f,f,n),a+this.getOffset(-f,f,n)]}):y.push({op:"bcurveTo",data:[h+e+(l-e)*u+this.getOffset(-d,d,n),g+t+(a-t)*u+this.getOffset(-d,d,n),h+e+2*(l-e)*u+this.getOffset(-d,d,n),g+t+2*(a-t)*u+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),a+this.getOffset(-d,d,n)]}),y}},{key:"_curve",value:function(e,t,l){var a=e.length,n=[];if(3h;h++)0===h?o.push({op:"move",data:[r.x,r.y]}):o.push({op:"move",data:[r.x+this.getOffset(-d[0],d[0],p),r.y+this.getOffset(-d[0],d[0],p)]}),u=[n+this.getOffset(-d[h],d[h],p),s+this.getOffset(-d[h],d[h],p)],o.push({op:"bcurveTo",data:[e+this.getOffset(-d[h],d[h],p),t+this.getOffset(-d[h],d[h],p),l+this.getOffset(-d[h],d[h],p),a+this.getOffset(-d[h],d[h],p),u[0],u[1]]});return r.setPosition(u[0],u[1]),o}},{key:"_processSegment",value:function(e,t,l,a){var n=[];switch(t.key){case"M":case"m":{var s="m"===t.key;if(2<=t.data.length){var o=+t.data[0],r=+t.data[1];s&&(o+=e.x,r+=e.y);var p=1*(a.maxRandomnessOffset||0);o+=this.getOffset(-p,p,a),r+=this.getOffset(-p,p,a),e.setPosition(o,r),n.push({op:"move",data:[o,r]})}break}case"L":case"l":{var d="l"===t.key;if(2<=t.data.length){var u=+t.data[0],h=+t.data[1];d&&(u+=e.x,h+=e.y),n=n.concat(this.doubleLine(e.x,e.y,u,h,a)),e.setPosition(u,h)}break}case"H":case"h":{var g="h"===t.key;if(t.data.length){var c=+t.data[0];g&&(c+=e.x),n=n.concat(this.doubleLine(e.x,e.y,c,e.y,a)),e.setPosition(c,e.y)}break}case"V":case"v":{var v="v"===t.key;if(t.data.length){var _=+t.data[0];v&&(_+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,_,a)),e.setPosition(e.x,_)}break}case"Z":case"z":{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],a)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case"C":case"c":{var k="c"===t.key;if(6<=t.data.length){var m=+t.data[0],w=+t.data[1],P=+t.data[2],O=+t.data[3],S=+t.data[4],A=+t.data[5];k&&(m+=e.x,P+=e.x,S+=e.x,w+=e.y,O+=e.y,A+=e.y);var T=this._bezierTo(m,w,P,O,S,A,e,a);n=n.concat(T),e.bezierReflectionPoint=[S+(S-P),A+(A-O)]}break}case"S":case"s":{var C="s"===t.key;if(4<=t.data.length){var z=+t.data[0],E=+t.data[1],L=+t.data[2],R=+t.data[3];C&&(z+=e.x,L+=e.x,E+=e.y,R+=e.y);var W=z,N=E,D=l?l.key:"",B=null;("c"===D||"C"===D||"s"===D||"S"===D)&&(B=e.bezierReflectionPoint),B&&(W=B[0],N=B[1]);var F=this._bezierTo(W,N,z,E,L,R,e,a);n=n.concat(F),e.bezierReflectionPoint=[L+(L-z),R+(R-E)]}break}case"Q":case"q":{var M="q"===t.key;if(4<=t.data.length){var q=+t.data[0],U=+t.data[1],X=+t.data[2],V=+t.data[3];M&&(q+=e.x,X+=e.x,U+=e.y,V+=e.y);var G=1*(1+.2*a.roughness),I=1.5*(1+.22*a.roughness);n.push({op:"move",data:[e.x+this.getOffset(-G,G,a),e.y+this.getOffset(-G,G,a)]});var j=[X+this.getOffset(-G,G,a),V+this.getOffset(-G,G,a)];n.push({op:"qcurveTo",data:[q+this.getOffset(-G,G,a),U+this.getOffset(-G,G,a),j[0],j[1]]}),n.push({op:"move",data:[e.x+this.getOffset(-I,I,a),e.y+this.getOffset(-I,I,a)]}),j=[X+this.getOffset(-I,I,a),V+this.getOffset(-I,I,a)],n.push({op:"qcurveTo",data:[q+this.getOffset(-I,I,a),U+this.getOffset(-I,I,a),j[0],j[1]]}),e.setPosition(j[0],j[1]),e.quadReflectionPoint=[X+(X-q),V+(V-U)]}break}case"T":case"t":{var Q="t"===t.key;if(2<=t.data.length){var $=+t.data[0],Z=+t.data[1];Q&&($+=e.x,Z+=e.y);var H=$,J=Z,Y=l?l.key:"",K=null;("q"===Y||"Q"===Y||"t"===Y||"T"===Y)&&(K=e.quadReflectionPoint),K&&(H=K[0],J=K[1]);var ee=1*(1+.2*a.roughness),te=1.5*(1+.22*a.roughness);n.push({op:"move",data:[e.x+this.getOffset(-ee,ee,a),e.y+this.getOffset(-ee,ee,a)]});var le=[$+this.getOffset(-ee,ee,a),Z+this.getOffset(-ee,ee,a)];n.push({op:"qcurveTo",data:[H+this.getOffset(-ee,ee,a),J+this.getOffset(-ee,ee,a),le[0],le[1]]}),n.push({op:"move",data:[e.x+this.getOffset(-te,te,a),e.y+this.getOffset(-te,te,a)]}),le=[$+this.getOffset(-te,te,a),Z+this.getOffset(-te,te,a)],n.push({op:"qcurveTo",data:[H+this.getOffset(-te,te,a),J+this.getOffset(-te,te,a),le[0],le[1]]}),e.setPosition(le[0],le[1]),e.quadReflectionPoint=[$+($-H),Z+(Z-J)]}break}case"A":case"a":{var ae="a"===t.key;if(7<=t.data.length){var ne=+t.data[0],ie=+t.data[1],se=+t.data[2],oe=+t.data[3],re=+t.data[4],pe=+t.data[5],de=+t.data[6];if(ae&&(pe+=e.x,de+=e.y),pe===e.x&&de===e.y)break;if(0==ne||0==ie)n=n.concat(this.doubleLine(e.x,e.y,pe,de,a)),e.setPosition(pe,de);else for(var fe=0;1>fe;fe++)for(var ue,he=new b([e.x,e.y],[pe,de],[ne,ie],se,!!oe,!!re),ge=he.getNextSegment();ge;)ue=this._bezierTo(ge.cp1[0],ge.cp1[1],ge.cp2[0],ge.cp2[1],ge.to[0],ge.to[1],e,a),n=n.concat(ue),ge=he.getNextSegment()}break}default:}return n}}]),e}(),z="undefined"!=typeof self,E=z&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,L="undefined"!=typeof self,R=function(){function e(t,a){g(this,e),this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=t||{},this.surface=a,this.renderer=l(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}return y(e,[{key:"_options",value:function(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}},{key:"_drawable",value:function(e,t,l){return{shape:e,sets:t||[],options:l||this.defaultOptions}}},{key:"getCanvasSize",value:function(){var e=function(e){return e&&"object"===("undefined"==typeof e?"undefined":o(e))&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100};return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}},{key:"computePolygonSize",value:function(e){if(e.length){for(var t=e[0][0],l=e[0][0],a=e[0][1],o=e[0][1],r=1;rl&&(l=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||"none",strokeWidth:l,fill:"none"}}},{key:"opsToPath",value:function(e){var t="",l=!0,a=!1,n=void 0;try{for(var i,s=e.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case"move":t+="M"+r[0]+" "+r[1]+" ";break;case"bcurveTo":t+="C"+r[0]+" "+r[1]+", "+r[2]+" "+r[3]+", "+r[4]+" "+r[5]+" ";break;case"qcurveTo":t+="Q"+r[0]+" "+r[1]+", "+r[2]+" "+r[3]+" ";break;case"lineTo":t+="L"+r[0]+" "+r[1]+" ";}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}return t.trim()}},{key:"lib",get:function(){return this.renderer}}]),e}(),W="undefined"!=typeof document,N=function(){function e(t,l){g(this,e),this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new R(l||null,this.canvas)}return y(e,[{key:"line",value:function(e,t,l,a,n){var i=this.gen.line(e,t,l,a,n);return this.draw(i),i}},{key:"rectangle",value:function(e,t,l,a,n){var i=this.gen.rectangle(e,t,l,a,n);return this.draw(i),i}},{key:"ellipse",value:function(e,t,l,a,n){var i=this.gen.ellipse(e,t,l,a,n);return this.draw(i),i}},{key:"circle",value:function(e,t,l,a){var n=this.gen.circle(e,t,l,a);return this.draw(n),n}},{key:"linearPath",value:function(e,t){var l=this.gen.linearPath(e,t);return this.draw(l),l}},{key:"polygon",value:function(e,t){var l=this.gen.polygon(e,t);return this.draw(l),l}},{key:"arc",value:function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2),e.save(),e.strokeStyle=l.fill||"",e.lineWidth=a,this._drawToContext(e,t),e.restore()}},{key:"_drawToContext",value:function(e,t){e.beginPath();var l=!0,a=!1,n=void 0;try{for(var i,s=t.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case"move":e.moveTo(r[0],r[1]);break;case"bcurveTo":e.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"qcurveTo":e.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"lineTo":e.lineTo(r[0],r[1]);}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}"fillPath"===t.type?e.fill():e.stroke()}},{key:"generator",get:function(){return this.gen}}],[{key:"createRenderer",value:function(){return new C}}]),e}(),D=function(e){function t(){return g(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),y(t,[{key:"line",value:async function(e,t,l,a,n){var i=this._options(n);return this._drawable("line",[await this.lib.line(e,t,l,a,i)],i)}},{key:"rectangle",value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill){var o=[[e,t],[e+l,t],[e+l,t+a],[e,t+a]];"solid"===i.fillStyle?s.push((await this.lib.solidFillPolygon(o,i))):s.push((await this.lib.patternFillPolygon(o,i)))}return s.push((await this.lib.rectangle(e,t,l,a,i))),this._drawable("rectangle",s,i)}},{key:"ellipse",value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill)if("solid"===i.fillStyle){var o=await this.lib.ellipse(e,t,l,a,i);o.type="fillPath",s.push(o)}else s.push((await this.lib.patternFillEllipse(e,t,l,a,i)));return s.push((await this.lib.ellipse(e,t,l,a,i))),this._drawable("ellipse",s,i)}},{key:"circle",value:async function(e,t,l,a){var n=await this.ellipse(e,t,l,l,a);return n.shape="circle",n}},{key:"linearPath",value:async function(e,t){var l=this._options(t);return this._drawable("linearPath",[await this.lib.linearPath(e,!1,l)],l)}},{key:"arc",value:async function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2);var n=e.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",this.opsToPath(t)),n.style.stroke=l.fill,n.style.strokeWidth=a+"",n.style.fill="none",n}},{key:"generator",get:function(){return this.gen}},{key:"defs",get:function(){if(F&&!this._defs){var e=this.svg.ownerDocument||document,t=e.createElementNS("http://www.w3.org/2000/svg","defs");this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}}],[{key:"createRenderer",value:function(){return new C}}]),e}(),q=function(e){function t(e,l){g(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l));return a.genAsync=new D(l||null,a.svg),a}return c(t,e),y(t,[{key:"line",value:async function(e,t,l,a,n){var i=await this.genAsync.line(e,t,l,a,n);return this.draw(i)}},{key:"rectangle",value:async function(e,t,l,a,n){var i=await this.genAsync.rectangle(e,t,l,a,n);return this.draw(i)}},{key:"ellipse",value:async function(e,t,l,a,n){var i=await this.genAsync.ellipse(e,t,l,a,n);return this.draw(i)}},{key:"circle",value:async function(e,t,l,a){var n=await this.genAsync.circle(e,t,l,a);return this.draw(n)}},{key:"linearPath",value:async function(e,t){var l=await this.genAsync.linearPath(e,t);return this.draw(l)}},{key:"polygon",value:async function(e,t){var l=await this.genAsync.polygon(e,t);return this.draw(l)}},{key:"arc",value:async function(e,t,l,a,n,i){var s=!!(6u){const e=d(1-u/(this._rx*this._rx*this._ry*this._ry));this._rx*=e,this._ry*=e,r=0}else r=(s===a?-1:1)*d(u/(this._rx*this._rx*p*p+this._ry*this._ry*o*o));const y=r*this._rx*p/this._ry,_=-r*this._ry*o/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*y-this._sinPhi*_+(e[0]+t[0])/2,this._C[1]=this._sinPhi*y+this._cosPhi*_+(e[1]+t[1])/2,this._theta=this.calculateVectorAngle(1,0,(o-y)/this._rx,(p-_)/this._ry);let x=this.calculateVectorAngle((o-y)/this._rx,(p-_)/this._ry,(-o-y)/this._rx,(-p-_)/this._ry);!a&&0x&&(x+=2*c),this._numSegs=Math.ceil(g(x/(c/2))),this._delta=x/this._numSegs,this._T=8/3*f(this._delta/4)*f(this._delta/4)/f(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const e=h(this._theta),t=f(this._theta),i=this._theta+this._delta,n=h(i),s=f(i),a=[this._cosPhi*this._rx*n-this._sinPhi*this._ry*s+this._C[0],this._sinPhi*this._rx*n+this._cosPhi*this._ry*s+this._C[1]],l=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[a[0]+this._T*(this._cosPhi*this._rx*s+this._sinPhi*this._ry*n),a[1]+this._T*(this._sinPhi*this._rx*s-this._cosPhi*this._ry*n)];return this._theta=i,this._from=[a[0],a[1]],this._segIndex++,{cp1:l,cp2:o,to:a}}calculateVectorAngle(e,t,i,n){var s=Math.atan2;const a=s(t,e),l=s(n,i);return l>=a?l-a:2*c-(a-l)}}class x{constructor(e,t){this.sets=e,this.closed=t}fit(e){const t=[];for(const i of this.sets){const n=i.length;let s=r(e*n);if(5>s){if(5>=n)continue;s=5}t.push(this.reduce(i,s))}let n='';for(const s of t){for(let e=0;et;){let e=-1,t=-1;for(let l=1;le||s=p(e.py1,e.py2)&&this.py1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=p(e.py1,e.py2)&&this.py2<=l(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+s,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===o?(this.xi=e.px1,this.yi=t*this.xi+n,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(r))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):t===i?n==s&&(this.px1>=p(e.px1,e.px2)&&this.px1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=p(e.px1,e.px2)&&this.px2<=l(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(s-n)/(t-i),this.yi=t*this.xi+n,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}class m{constructor(e,t,i,n,s,a,l,o){this.deltaX=0,this.hGap=0,this.top=e,this.bottom=t,this.left=i,this.right=n,this.gap=s,this.sinAngle=a,this.tanAngle=o,1e-4>g(a)?this.pos=i+s:.9999g(this.sinAngle)){if(this.posthis.right&&t>this.right;)if(this.pos+=this.hGap,e=this.pos-this.deltaX/2,t=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const a=new w([e,i],[t,n]);this.sLeft&&a.intersects(this.sLeft)&&(e=a.xi,i=a.yi),this.sRight&&a.intersects(this.sRight)&&(t=a.xi,n=a.yi),0u&&(u=4*t.strokeWidth),u=l(u,.1);const y=i%180*(c/180),_=h(y),x=f(y),b=s(y),w=new m(d-1,g+1,o-1,r+1,u,x,_,b);for(let i,s=null;null!=(i=w.nextLine());){const l=this.getIntersectingLines(i,e);for(let e=0;e=f&&(f=4*a.strokeWidth);let u=a.fillWeight;0>u&&(u=a.strokeWidth/2);const y=s(h%180*(c/180)),_=r/p,x=d(_*y*_*y+1),b=_*y/x,w=1/x,m=f/(p*r/d(r*w*(r*w)+p*b*(p*b))/p);let O=d(p*p-(e-p+m)*(e-p+m)),P=null;for(let s=e-p+m;sx;)x+=2*c,b+=2*c;b-x>2*c&&(x=0,b=2*c);const w=2*c/d.curveStepCount,m=p(w/2,(b-x)/2),O=this._arc(m,o,u,y,_,x,b,1,d),P=this._arc(m,o,u,y,_,x,b,1.5,d);let v=O.concat(P);return l&&(r?(v=v.concat(this.doubleLine(o,u,o+y*h(x),u+_*f(x),d)),v=v.concat(this.doubleLine(o,u,o+y*h(b),u+_*f(b),d))):(v.push({op:'lineTo',data:[o,u]}),v.push({op:'lineTo',data:[o+y*h(x),u+_*f(x)]}))),{type:'path',ops:v}}svgPath(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');let n=new _(e);if(t.simplification){const e=new x(n.linearPoints,n.closed),i=e.fit(t.simplification);n=new _(i)}let a=[];const l=n.segments||[];for(let o=0;ou;)u+=2*c,y+=2*c;y-u>2*c&&(u=0,y=2*c);const _=(y-u)/l.curveStepCount,x=[];for(let g=u;g<=y;g+=_)x.push([o+r*h(g),p+d*f(g)]);return x.push([o+r*h(y),p+d*f(y)]),x.push([o,p]),this.patternFillPolygon(x,l)}getOffset(e,t,i){return i.roughness*(Math.random()*(t-e)+e)}doubleLine(e,t,i,n,s){const a=this._line(e,t,i,n,s,!0,!1),l=this._line(e,t,i,n,s,!0,!0);return a.concat(l)}_line(e,t,i,n,s,l,o){const p=a(e-i,2)+a(t-n,2);let r=s.maxRandomnessOffset||0;100*(r*r)>p&&(r=d(p)/10);const h=r/2,f=.2+.2*Math.random();let g=s.bowing*s.maxRandomnessOffset*(n-t)/200,c=s.bowing*s.maxRandomnessOffset*(e-i)/200;g=this.getOffset(-g,g,s),c=this.getOffset(-c,c,s);const u=[];return l&&(o?u.push({op:'move',data:[e+this.getOffset(-h,h,s),t+this.getOffset(-h,h,s)]}):u.push({op:'move',data:[e+this.getOffset(-r,r,s),t+this.getOffset(-r,r,s)]})),o?u.push({op:'bcurveTo',data:[g+e+(i-e)*f+this.getOffset(-h,h,s),c+t+(n-t)*f+this.getOffset(-h,h,s),g+e+2*(i-e)*f+this.getOffset(-h,h,s),c+t+2*(n-t)*f+this.getOffset(-h,h,s),i+this.getOffset(-h,h,s),n+this.getOffset(-h,h,s)]}):u.push({op:'bcurveTo',data:[g+e+(i-e)*f+this.getOffset(-r,r,s),c+t+(n-t)*f+this.getOffset(-r,r,s),g+e+2*(i-e)*f+this.getOffset(-r,r,s),c+t+2*(n-t)*f+this.getOffset(-r,r,s),i+this.getOffset(-r,r,s),n+this.getOffset(-r,r,s)]}),u}_curve(e,t,i){const n=e.length;let a=[];if(3f;f++)0===f?o.push({op:'move',data:[p.x,p.y]}):o.push({op:'move',data:[p.x+this.getOffset(-d[0],d[0],r),p.y+this.getOffset(-d[0],d[0],r)]}),h=[a+this.getOffset(-d[f],d[f],r),l+this.getOffset(-d[f],d[f],r)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[f],d[f],r),t+this.getOffset(-d[f],d[f],r),n+this.getOffset(-d[f],d[f],r),s+this.getOffset(-d[f],d[f],r),h[0],h[1]]});return p.setPosition(h[0],h[1]),o}_processSegment(e,t,i,n){let s=[];switch(t.key){case'M':case'm':{const i='m'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y);const o=1*(n.maxRandomnessOffset||0);a+=this.getOffset(-o,o,n),l+=this.getOffset(-o,o,n),e.setPosition(a,l),s.push({op:'move',data:[a,l]})}break}case'L':case'l':{const i='l'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y),s=s.concat(this.doubleLine(e.x,e.y,a,l,n)),e.setPosition(a,l)}break}case'H':case'h':{const i='h'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.x),s=s.concat(this.doubleLine(e.x,e.y,a,e.y,n)),e.setPosition(a,e.y)}break}case'V':case'v':{const i='v'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.y),s=s.concat(this.doubleLine(e.x,e.y,e.x,a,n)),e.setPosition(e.x,a)}break}case'Z':case'z':{e.first&&(s=s.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],n)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{const i='c'===t.key;if(6<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4],d=+t.data[5];i&&(a+=e.x,o+=e.x,r+=e.x,l+=e.y,p+=e.y,d+=e.y);const h=this._bezierTo(a,l,o,p,r,d,e,n);s=s.concat(h),e.bezierReflectionPoint=[r+(r-o),d+(d-p)]}break}case'S':case's':{const a='s'===t.key;if(4<=t.data.length){let l=+t.data[0],o=+t.data[1],p=+t.data[2],r=+t.data[3];a&&(l+=e.x,p+=e.x,o+=e.y,r+=e.y);let d=l,h=o;const f=i?i.key:'';let g=null;('c'===f||'C'===f||'s'===f||'S'===f)&&(g=e.bezierReflectionPoint),g&&(d=g[0],h=g[1]);const c=this._bezierTo(d,h,l,o,p,r,e,n);s=s.concat(c),e.bezierReflectionPoint=[p+(p-l),r+(r-o)]}break}case'Q':case'q':{const i='q'===t.key;if(4<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3];i&&(a+=e.x,o+=e.x,l+=e.y,p+=e.y);const r=1*(1+.2*n.roughness),d=1.5*(1+.22*n.roughness);s.push({op:'move',data:[e.x+this.getOffset(-r,r,n),e.y+this.getOffset(-r,r,n)]});let h=[o+this.getOffset(-r,r,n),p+this.getOffset(-r,r,n)];s.push({op:'qcurveTo',data:[a+this.getOffset(-r,r,n),l+this.getOffset(-r,r,n),h[0],h[1]]}),s.push({op:'move',data:[e.x+this.getOffset(-d,d,n),e.y+this.getOffset(-d,d,n)]}),h=[o+this.getOffset(-d,d,n),p+this.getOffset(-d,d,n)],s.push({op:'qcurveTo',data:[a+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),h[0],h[1]]}),e.setPosition(h[0],h[1]),e.quadReflectionPoint=[o+(o-a),p+(p-l)]}break}case'T':case't':{const a='t'===t.key;if(2<=t.data.length){let l=+t.data[0],o=+t.data[1];a&&(l+=e.x,o+=e.y);let p=l,r=o;const d=i?i.key:'';let h=null;('q'===d||'Q'===d||'t'===d||'T'===d)&&(h=e.quadReflectionPoint),h&&(p=h[0],r=h[1]);const g=1*(1+.2*n.roughness),c=1.5*(1+.22*n.roughness);s.push({op:'move',data:[e.x+this.getOffset(-g,g,n),e.y+this.getOffset(-g,g,n)]});let u=[l+this.getOffset(-g,g,n),o+this.getOffset(-g,g,n)];s.push({op:'qcurveTo',data:[p+this.getOffset(-g,g,n),r+this.getOffset(-g,g,n),u[0],u[1]]}),s.push({op:'move',data:[e.x+this.getOffset(-c,c,n),e.y+this.getOffset(-c,c,n)]}),u=[l+this.getOffset(-c,c,n),o+this.getOffset(-c,c,n)],s.push({op:'qcurveTo',data:[p+this.getOffset(-c,c,n),r+this.getOffset(-c,c,n),u[0],u[1]]}),e.setPosition(u[0],u[1]),e.quadReflectionPoint=[l+(l-p),o+(o-r)]}break}case'A':case'a':{const i='a'===t.key;if(7<=t.data.length){const a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4];let d=+t.data[5],h=+t.data[6];if(i&&(d+=e.x,h+=e.y),d===e.x&&h===e.y)break;if(0==a||0==l)s=s.concat(this.doubleLine(e.x,e.y,d,h,n)),e.setPosition(d,h);else for(let t=0;1>t;t++){const t=new b([e.x,e.y],[d,h],[a,l],o,!!p,!!r);for(let i=t.getNextSegment();i;){const a=this._bezierTo(i.cp1[0],i.cp1[1],i.cp2[0],i.cp2[1],i.to[0],i.to[1],e,n);s=s.concat(a),i=t.getNextSegment()}}}break}default:}return s}}const S='undefined'!=typeof self,T=S&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,C='undefined'!=typeof self;class z{constructor(e,t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=e||{},this.surface=t,this.renderer=i(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}_options(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_drawable(e,t,i){return{shape:e,sets:t||[],options:i||this.defaultOptions}}get lib(){return this.renderer}getCanvasSize(){const e=e=>e&&'object'==typeof e&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100;return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}computePolygonSize(e){if(e.length){let t=e[0][0],n=e[0][0],s=e[0][1],a=e[0][1];for(let o=1;oi&&(i=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:i,fill:'none'}}opsToPath(e){let t='';for(const i of e.ops){const e=i.data;switch(i.op){case'move':t+=`M${e[0]} ${e[1]} `;break;case'bcurveTo':t+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case'qcurveTo':t+=`Q${e[0]} ${e[1]}, ${e[2]} ${e[3]} `;break;case'lineTo':t+=`L${e[0]} ${e[1]} `;}}return t.trim()}}const E='undefined'!=typeof document;class W{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext('2d'),this.gen=new z(t||null,this.canvas)}get generator(){return this.gen}static createRenderer(){return new A}line(e,t,i,n,s){const a=this.gen.line(e,t,i,n,s);return this.draw(a),a}rectangle(e,t,i,n,s){const a=this.gen.rectangle(e,t,i,n,s);return this.draw(a),a}ellipse(e,t,i,n,s){const a=this.gen.ellipse(e,t,i,n,s);return this.draw(a),a}circle(e,t,i,n){const s=this.gen.circle(e,t,i,n);return this.draw(s),s}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i),i}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i),i}arc(e,t,i,n,s,a,l=!1,o){const p=this.gen.arc(e,t,i,n,s,a,l,o);return this.draw(p),p}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i),i}path(e,t){const i=this.gen.path(e,t);return this.draw(i),i}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,n=this.ctx;for(const s of t)switch(s.type){case'path':n.save(),n.strokeStyle=i.stroke,n.lineWidth=i.strokeWidth,this._drawToContext(n,s),n.restore();break;case'fillPath':n.save(),n.fillStyle=i.fill||'',this._drawToContext(n,s),n.restore();break;case'fillSketch':this.fillSketch(n,s,i);break;case'path2Dfill':{this.ctx.save(),this.ctx.fillStyle=i.fill||'';const e=new Path2D(s.path);this.ctx.fill(e),this.ctx.restore();break}case'path2Dpattern':{if(E){const e=s.size,t=document.createElement('canvas'),n=t.getContext('2d'),a=this.computeBBox(s.path);a&&(a.width||a.height)?(t.width=this.canvas.width,t.height=this.canvas.height,n.translate(a.x||0,a.y||0)):(t.width=e[0],t.height=e[1]),this.fillSketch(n,s,i),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(t,'repeat');const l=new Path2D(s.path);this.ctx.fill(l),this.ctx.restore()}break}}}computeBBox(e){if(E)try{const t=document.createElementNS('http://www.w3.org/2000/svg','svg');t.setAttribute('width','0'),t.setAttribute('height','0');const i=self.document.createElementNS('http://www.w3.org/2000/svg','path');i.setAttribute('d',e),t.appendChild(i),document.body.appendChild(t);const n=i.getBBox();return document.body.removeChild(t),n}catch(e){}return null}fillSketch(e,t,i){let n=i.fillWeight;0>n&&(n=i.strokeWidth/2),e.save(),e.strokeStyle=i.fill||'',e.lineWidth=n,this._drawToContext(e,t),e.restore()}_drawToContext(e,t){e.beginPath();for(const i of t.ops){const t=i.data;switch(i.op){case'move':e.moveTo(t[0],t[1]);break;case'bcurveTo':e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case'qcurveTo':e.quadraticCurveTo(t[0],t[1],t[2],t[3]);break;case'lineTo':e.lineTo(t[0],t[1]);}}'fillPath'===t.type?e.fill():e.stroke()}}class L extends z{async line(e,t,i,n,s){const a=this._options(s);return this._drawable('line',[await this.lib.line(e,t,i,n,a)],a)}async rectangle(e,t,i,n,s){const a=this._options(s),l=[];if(a.fill){const s=[[e,t],[e+i,t],[e+i,t+n],[e,t+n]];'solid'===a.fillStyle?l.push((await this.lib.solidFillPolygon(s,a))):l.push((await this.lib.patternFillPolygon(s,a)))}return l.push((await this.lib.rectangle(e,t,i,n,a))),this._drawable('rectangle',l,a)}async ellipse(e,t,i,n,s){const a=this._options(s),l=[];if(a.fill)if('solid'===a.fillStyle){const s=await this.lib.ellipse(e,t,i,n,a);s.type='fillPath',l.push(s)}else l.push((await this.lib.patternFillEllipse(e,t,i,n,a)));return l.push((await this.lib.ellipse(e,t,i,n,a))),this._drawable('ellipse',l,a)}async circle(e,t,i,n){const s=await this.ellipse(e,t,i,i,n);return s.shape='circle',s}async linearPath(e,t){const i=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,i)],i)}async arc(e,t,i,n,s,a,l=!1,p){const r=this._options(p),o=[];if(l&&r.fill)if('solid'===r.fillStyle){const l=await this.lib.arc(e,t,i,n,s,a,!0,!1,r);l.type='fillPath',o.push(l)}else o.push((await this.lib.patternFillArc(e,t,i,n,s,a,r)));return o.push((await this.lib.arc(e,t,i,n,s,a,l,!0,r))),this._drawable('arc',o,r)}async curve(e,t){const i=this._options(t);return this._drawable('curve',[await this.lib.curve(e,i)],i)}async polygon(e,t){const i=this._options(t),n=[];if(i.fill)if('solid'===i.fillStyle)n.push((await this.lib.solidFillPolygon(e,i)));else{const t=this.computePolygonSize(e),s=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(s,i);a.type='path2Dpattern',a.size=t,a.path=this.polygonPath(e),n.push(a)}return n.push((await this.lib.linearPath(e,!0,i))),this._drawable('polygon',n,i)}async path(e,t){const i=this._options(t),n=[];if(!e)return this._drawable('path',n,i);if(i.fill)if('solid'===i.fillStyle){n.push({type:'path2Dfill',path:e,ops:[]})}else{const t=this.computePathSize(e),s=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(s,i);a.type='path2Dpattern',a.size=t,a.path=e,n.push(a)}return n.push((await this.lib.svgPath(e,i))),this._drawable('path',n,i)}}class N extends W{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.canvas)}get generator(){return this.genAsync}async line(e,t,i,n,s){const a=await this.genAsync.line(e,t,i,n,s);return this.draw(a),a}async rectangle(e,t,i,n,s){const a=await this.genAsync.rectangle(e,t,i,n,s);return this.draw(a),a}async ellipse(e,t,i,n,s){const a=await this.genAsync.ellipse(e,t,i,n,s);return this.draw(a),a}async circle(e,t,i,n){const s=await this.genAsync.circle(e,t,i,n);return this.draw(s),s}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i),i}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i),i}async arc(e,t,i,n,s,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,n,s,a,l,o);return this.draw(p),p}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i),i}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i),i}}const R='undefined'!=typeof document;class D{constructor(e,t){this.svg=e,this.gen=new z(t||null,this.svg)}get generator(){return this.gen}static createRenderer(){return new A}get defs(){if(R&&!this._defs){const e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}line(e,t,i,n,s){const a=this.gen.line(e,t,i,n,s);return this.draw(a)}rectangle(e,t,i,n,s){const a=this.gen.rectangle(e,t,i,n,s);return this.draw(a)}ellipse(e,t,i,n,s){const a=this.gen.ellipse(e,t,i,n,s);return this.draw(a)}circle(e,t,i,n){const s=this.gen.circle(e,t,i,n);return this.draw(s)}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i)}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i)}arc(e,t,i,n,s,a,l=!1,o){const p=this.gen.arc(e,t,i,n,s,a,l,o);return this.draw(p)}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i)}path(e,t){const i=this.gen.path(e,t);return this.draw(i)}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,s=this.svg.ownerDocument||R&&document,a=s.createElementNS('http://www.w3.org/2000/svg','g');for(const l of t){let e=null;switch(l.type){case'path':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke=i.stroke,e.style.strokeWidth=i.strokeWidth+'',e.style.fill='none';break}case'fillPath':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'fillSketch':{e=this.fillSketch(s,l,i);break}case'path2Dfill':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'path2Dpattern':{const t=l.size,a=s.createElementNS('http://www.w3.org/2000/svg','pattern'),o=`rough-${r(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;a.setAttribute('id',o),a.setAttribute('x','0'),a.setAttribute('y','0'),a.setAttribute('width','1'),a.setAttribute('height','1'),a.setAttribute('height','1'),a.setAttribute('viewBox',`0 0 ${n(t[0])} ${n(t[1])}`),a.setAttribute('patternUnits','objectBoundingBox');const p=this.fillSketch(s,l,i);a.appendChild(p),this.defs.appendChild(a),e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=`url(#${o})`;break}}e&&a.appendChild(e)}return a}opsToPath(e){return this.gen.opsToPath(e)}fillSketch(e,t,i){let n=i.fillWeight;0>n&&(n=i.strokeWidth/2);const s=e.createElementNS('http://www.w3.org/2000/svg','path');return s.setAttribute('d',this.opsToPath(t)),s.style.stroke=i.fill,s.style.strokeWidth=n+'',s.style.fill='none',s}}class B extends D{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.svg)}get generator(){return this.genAsync}async line(e,t,i,n,s){const a=await this.genAsync.line(e,t,i,n,s);return this.draw(a)}async rectangle(e,t,i,n,s){const a=await this.genAsync.rectangle(e,t,i,n,s);return this.draw(a)}async ellipse(e,t,i,n,s){const a=await this.genAsync.ellipse(e,t,i,n,s);return this.draw(a)}async circle(e,t,i,n){const s=await this.genAsync.circle(e,t,i,n);return this.draw(s)}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i)}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i)}async arc(e,t,i,n,s,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,n,s,a,l,o);return this.draw(p)}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i)}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i)}}var M={canvas(e,t){return t&&t.async?new N(e,t):new W(e,t)},svg(e,t){return t&&t.async?new B(e,t):new D(e,t)},createRenderer(){return W.createRenderer()},generator(e,t){return e&&e.async?new L(e,t):new z(e,t)}};return M}(); +var rough=function(){'use strict';function e(e,t){return e.type===t}function t(e,t){let i=t.fillStyle||'hachure';if(!k[i])switch(i){case'zigzag':k[i]||(k[i]=new P(e));break;case'cross-hatch':k[i]||(k[i]=new v(e));break;case'hachure':default:i='hachure',k[i]||(k[i]=new O(e));}return k[i]}function i(e){if(S&&T&&self&&self.workly&&e.async&&!e.noWorker){const t=e.worklyURL||'https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js';if(t){const e=`importScripts('${t}', '${T}');\nworkly.expose(self.rough.createRenderer());`,i=URL.createObjectURL(new Blob([e]));return self.workly.proxy(i)}}return new A}var s=Math.round,n=Math.tan,l=Math.max,p=Math.min,o=Number.MAX_VALUE,a=Math.pow,r=Math.floor,d=Math.sqrt,f=Math.cos,h=Math.sin,g=Math.abs,c=Math.PI;const u={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:4,t:2,V:1,v:1,Z:0,z:0};class y{constructor(e){this.COMMAND=0,this.NUMBER=1,this.EOD=2,this.segments=[],this.parseData(e),this.processPoints()}tokenize(e){const t=[];for(;''!==e;)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:this.COMMAND,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:this.NUMBER,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return console.error('Unrecognized segment command: '+e),[];return t[t.length]={type:this.EOD,text:''},t}parseData(t){const s=this.tokenize(t);let n=0,i=s[n],a='BOD';for(this.segments=[];!e(i,this.EOD);){let l;const o=[];if(!('BOD'===a))e(i,this.NUMBER)?l=u[a]:(n++,l=u[i.text],a=i.text);else if('M'===i.text||'m'===i.text)n++,l=u[i.text],a=i.text;else return void this.parseData('M0,0'+t);if(n+lu){const e=d(1-u/(this._rx*this._rx*this._ry*this._ry));this._rx*=e,this._ry*=e,r=0}else r=(n===a?-1:1)*d(u/(this._rx*this._rx*p*p+this._ry*this._ry*o*o));const y=r*this._rx*p/this._ry,_=-r*this._ry*o/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*y-this._sinPhi*_+(e[0]+t[0])/2,this._C[1]=this._sinPhi*y+this._cosPhi*_+(e[1]+t[1])/2,this._theta=this.calculateVectorAngle(1,0,(o-y)/this._rx,(p-_)/this._ry);let x=this.calculateVectorAngle((o-y)/this._rx,(p-_)/this._ry,(-o-y)/this._rx,(-p-_)/this._ry);!a&&0x&&(x+=2*c),this._numSegs=Math.ceil(g(x/(c/2))),this._delta=x/this._numSegs,this._T=8/3*h(this._delta/4)*h(this._delta/4)/h(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const e=f(this._theta),t=h(this._theta),i=this._theta+this._delta,s=f(i),n=h(i),a=[this._cosPhi*this._rx*s-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*s+this._cosPhi*this._ry*n+this._C[1]],l=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[a[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*s),a[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*s)];return this._theta=i,this._from=[a[0],a[1]],this._segIndex++,{cp1:l,cp2:o,to:a}}calculateVectorAngle(e,t,i,s){var n=Math.atan2;const a=n(t,e),l=n(s,i);return l>=a?l-a:2*c-(a-l)}}class x{constructor(e,t){this.sets=e,this.closed=t}fit(e){const t=[];for(const i of this.sets){const s=i.length;let n=r(e*s);if(5>n){if(5>=s)continue;n=5}t.push(this.reduce(i,n))}let s='';for(const n of t){for(let e=0;et;){let e=-1,t=-1;for(let l=1;le||s=p(e.py1,e.py2)&&this.py1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=p(e.py1,e.py2)&&this.py2<=l(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+n,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===o?(this.xi=e.px1,this.yi=t*this.xi+s,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(r))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):t===i?s==n&&(this.px1>=p(e.px1,e.px2)&&this.px1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=p(e.px1,e.px2)&&this.px2<=l(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(n-s)/(t-i),this.yi=t*this.xi+s,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}class m{constructor(e,t,i,s,n,a,l,o){this.deltaX=0,this.hGap=0,this.top=e,this.bottom=t,this.left=i,this.right=s,this.gap=n,this.sinAngle=a,this.tanAngle=o,1e-4>g(a)?this.pos=i+n:.9999g(this.sinAngle)){if(this.posthis.right&&t>this.right;)if(this.pos+=this.hGap,e=this.pos-this.deltaX/2,t=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const a=new w([e,i],[t,n]);this.sLeft&&a.intersects(this.sLeft)&&(e=a.xi,i=a.yi),this.sRight&&a.intersects(this.sRight)&&(t=a.xi,n=a.yi),0u&&(u=4*t.strokeWidth),u=l(u,.1);const y=i%180*(c/180),_=f(y),x=h(y),b=n(y),w=new m(d-1,g+1,o-1,r+1,u,x,_,b);for(let i,n=null;null!=(i=w.nextLine());){const l=this.getIntersectingLines(i,e);for(let e=0;e=h&&(h=4*a.strokeWidth);let u=a.fillWeight;0>u&&(u=a.strokeWidth/2);const y=n(f%180*(c/180)),_=r/p,x=d(_*y*_*y+1),b=_*y/x,w=1/x,m=h/(p*r/d(r*w*(r*w)+p*b*(p*b))/p);let O=d(p*p-(e-p+m)*(e-p+m)),P=null;for(let n=e-p+m;nx;)x+=2*c,b+=2*c;b-x>2*c&&(x=0,b=2*c);const w=2*c/d.curveStepCount,m=p(w/2,(b-x)/2),O=this._arc(m,o,u,y,_,x,b,1,d),P=this._arc(m,o,u,y,_,x,b,1.5,d);let v=O.concat(P);return l&&(r?(v=v.concat(this.doubleLine(o,u,o+y*f(x),u+_*h(x),d)),v=v.concat(this.doubleLine(o,u,o+y*f(b),u+_*h(b),d))):(v.push({op:'lineTo',data:[o,u]}),v.push({op:'lineTo',data:[o+y*f(x),u+_*h(x)]}))),{type:'path',ops:v}}svgPath(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');let n=new _(e);if(t.simplification){const e=new x(n.linearPoints,n.closed),i=e.fit(t.simplification);n=new _(i)}let a=[];const l=n.segments||[];for(let o=0;ou;)u+=2*c,y+=2*c;y-u>2*c&&(u=0,y=2*c);const _=(y-u)/l.curveStepCount,x=[];for(let g=u;g<=y;g+=_)x.push([o+r*f(g),p+d*h(g)]);return x.push([o+r*f(y),p+d*h(y)]),x.push([o,p]),this.patternFillPolygon(x,l)}getOffset(e,t,i){return i.roughness*(Math.random()*(t-e)+e)}doubleLine(e,t,i,s,n){const a=this._line(e,t,i,s,n,!0,!1),l=this._line(e,t,i,s,n,!0,!0);return a.concat(l)}_line(e,t,i,s,n,l,o){const p=a(e-i,2)+a(t-s,2);let r=n.maxRandomnessOffset||0;100*(r*r)>p&&(r=d(p)/10);const f=r/2,h=.2+.2*Math.random();let g=n.bowing*n.maxRandomnessOffset*(s-t)/200,c=n.bowing*n.maxRandomnessOffset*(e-i)/200;g=this.getOffset(-g,g,n),c=this.getOffset(-c,c,n);const u=[];return l&&(o?u.push({op:'move',data:[e+this.getOffset(-f,f,n),t+this.getOffset(-f,f,n)]}):u.push({op:'move',data:[e+this.getOffset(-r,r,n),t+this.getOffset(-r,r,n)]})),o?u.push({op:'bcurveTo',data:[g+e+(i-e)*h+this.getOffset(-f,f,n),c+t+(s-t)*h+this.getOffset(-f,f,n),g+e+2*(i-e)*h+this.getOffset(-f,f,n),c+t+2*(s-t)*h+this.getOffset(-f,f,n),i+this.getOffset(-f,f,n),s+this.getOffset(-f,f,n)]}):u.push({op:'bcurveTo',data:[g+e+(i-e)*h+this.getOffset(-r,r,n),c+t+(s-t)*h+this.getOffset(-r,r,n),g+e+2*(i-e)*h+this.getOffset(-r,r,n),c+t+2*(s-t)*h+this.getOffset(-r,r,n),i+this.getOffset(-r,r,n),s+this.getOffset(-r,r,n)]}),u}_curve(e,t,i){const n=e.length;let a=[];if(3f;f++)0===f?o.push({op:'move',data:[p.x,p.y]}):o.push({op:'move',data:[p.x+this.getOffset(-d[0],d[0],r),p.y+this.getOffset(-d[0],d[0],r)]}),h=[a+this.getOffset(-d[f],d[f],r),l+this.getOffset(-d[f],d[f],r)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[f],d[f],r),t+this.getOffset(-d[f],d[f],r),s+this.getOffset(-d[f],d[f],r),n+this.getOffset(-d[f],d[f],r),h[0],h[1]]});return p.setPosition(h[0],h[1]),o}_processSegment(e,t,i,s){let n=[];switch(t.key){case'M':case'm':{const i='m'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y);const o=1*(s.maxRandomnessOffset||0);a+=this.getOffset(-o,o,s),l+=this.getOffset(-o,o,s),e.setPosition(a,l),n.push({op:'move',data:[a,l]})}break}case'L':case'l':{const i='l'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y),n=n.concat(this.doubleLine(e.x,e.y,a,l,s)),e.setPosition(a,l)}break}case'H':case'h':{const i='h'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.x),n=n.concat(this.doubleLine(e.x,e.y,a,e.y,s)),e.setPosition(a,e.y)}break}case'V':case'v':{const i='v'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,a,s)),e.setPosition(e.x,a)}break}case'Z':case'z':{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],s)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{const i='c'===t.key;if(6<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4],d=+t.data[5];i&&(a+=e.x,o+=e.x,r+=e.x,l+=e.y,p+=e.y,d+=e.y);const f=this._bezierTo(a,l,o,p,r,d,e,s);n=n.concat(f),e.bezierReflectionPoint=[r+(r-o),d+(d-p)]}break}case'S':case's':{const a='s'===t.key;if(4<=t.data.length){let l=+t.data[0],o=+t.data[1],p=+t.data[2],r=+t.data[3];a&&(l+=e.x,p+=e.x,o+=e.y,r+=e.y);let d=l,f=o;const h=i?i.key:'';let g=null;('c'===h||'C'===h||'s'===h||'S'===h)&&(g=e.bezierReflectionPoint),g&&(d=g[0],f=g[1]);const c=this._bezierTo(d,f,l,o,p,r,e,s);n=n.concat(c),e.bezierReflectionPoint=[p+(p-l),r+(r-o)]}break}case'Q':case'q':{const i='q'===t.key;if(4<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3];i&&(a+=e.x,o+=e.x,l+=e.y,p+=e.y);const r=1*(1+.2*s.roughness),d=1.5*(1+.22*s.roughness);n.push({op:'move',data:[e.x+this.getOffset(-r,r,s),e.y+this.getOffset(-r,r,s)]});let h=[o+this.getOffset(-r,r,s),p+this.getOffset(-r,r,s)];n.push({op:'qcurveTo',data:[a+this.getOffset(-r,r,s),l+this.getOffset(-r,r,s),h[0],h[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-d,d,s),e.y+this.getOffset(-d,d,s)]}),h=[o+this.getOffset(-d,d,s),p+this.getOffset(-d,d,s)],n.push({op:'qcurveTo',data:[a+this.getOffset(-d,d,s),l+this.getOffset(-d,d,s),h[0],h[1]]}),e.setPosition(h[0],h[1]),e.quadReflectionPoint=[o+(o-a),p+(p-l)]}break}case'T':case't':{const a='t'===t.key;if(2<=t.data.length){let l=+t.data[0],o=+t.data[1];a&&(l+=e.x,o+=e.y);let p=l,r=o;const d=i?i.key:'';let h=null;('q'===d||'Q'===d||'t'===d||'T'===d)&&(h=e.quadReflectionPoint),h&&(p=h[0],r=h[1]);const g=1*(1+.2*s.roughness),c=1.5*(1+.22*s.roughness);n.push({op:'move',data:[e.x+this.getOffset(-g,g,s),e.y+this.getOffset(-g,g,s)]});let u=[l+this.getOffset(-g,g,s),o+this.getOffset(-g,g,s)];n.push({op:'qcurveTo',data:[p+this.getOffset(-g,g,s),r+this.getOffset(-g,g,s),u[0],u[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-c,c,s),e.y+this.getOffset(-c,c,s)]}),u=[l+this.getOffset(-c,c,s),o+this.getOffset(-c,c,s)],n.push({op:'qcurveTo',data:[p+this.getOffset(-c,c,s),r+this.getOffset(-c,c,s),u[0],u[1]]}),e.setPosition(u[0],u[1]),e.quadReflectionPoint=[l+(l-p),o+(o-r)]}break}case'A':case'a':{const i='a'===t.key;if(7<=t.data.length){const a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4];let d=+t.data[5],f=+t.data[6];if(i&&(d+=e.x,f+=e.y),d===e.x&&f===e.y)break;if(0==a||0==l)n=n.concat(this.doubleLine(e.x,e.y,d,f,s)),e.setPosition(d,f);else for(let t=0;1>t;t++){const t=new b([e.x,e.y],[d,f],[a,l],o,!!p,!!r);for(let i=t.getNextSegment();i;){const a=this._bezierTo(i.cp1[0],i.cp1[1],i.cp2[0],i.cp2[1],i.to[0],i.to[1],e,s);n=n.concat(a),i=t.getNextSegment()}}}break}default:}return n}}const S='undefined'!=typeof self,T=S&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,C='undefined'!=typeof self;class z{constructor(e,t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=e||{},this.surface=t,this.renderer=i(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}_options(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_drawable(e,t,i){return{shape:e,sets:t||[],options:i||this.defaultOptions}}get lib(){return this.renderer}getCanvasSize(){const e=e=>e&&'object'==typeof e&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100;return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}computePolygonSize(e){if(e.length){let t=e[0][0],s=e[0][0],n=e[0][1],a=e[0][1];for(let o=1;oi&&(i=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:i,fill:'none'}}opsToPath(e){let t='';for(const i of e.ops){const e=i.data;switch(i.op){case'move':t+=`M${e[0]} ${e[1]} `;break;case'bcurveTo':t+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case'qcurveTo':t+=`Q${e[0]} ${e[1]}, ${e[2]} ${e[3]} `;break;case'lineTo':t+=`L${e[0]} ${e[1]} `;}}return t.trim()}}const E='undefined'!=typeof document;class W{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext('2d'),this.gen=new z(t||null,this.canvas)}get generator(){return this.gen}static createRenderer(){return new A}line(e,t,i,s,n){const a=this.gen.line(e,t,i,s,n);return this.draw(a),a}rectangle(e,t,i,s,n){const a=this.gen.rectangle(e,t,i,s,n);return this.draw(a),a}ellipse(e,t,i,s,n){const a=this.gen.ellipse(e,t,i,s,n);return this.draw(a),a}circle(e,t,i,s){const n=this.gen.circle(e,t,i,s);return this.draw(n),n}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i),i}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i),i}arc(e,t,i,s,n,a,l=!1,o){const p=this.gen.arc(e,t,i,s,n,a,l,o);return this.draw(p),p}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i),i}path(e,t){const i=this.gen.path(e,t);return this.draw(i),i}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,s=this.ctx;for(const n of t)switch(n.type){case'path':s.save(),s.strokeStyle=i.stroke,s.lineWidth=i.strokeWidth,this._drawToContext(s,n),s.restore();break;case'fillPath':s.save(),s.fillStyle=i.fill||'',this._drawToContext(s,n),s.restore();break;case'fillSketch':this.fillSketch(s,n,i);break;case'path2Dfill':{this.ctx.save(),this.ctx.fillStyle=i.fill||'';const e=new Path2D(n.path);this.ctx.fill(e),this.ctx.restore();break}case'path2Dpattern':{if(E){const e=n.size,t=document.createElement('canvas'),s=t.getContext('2d'),a=this.computeBBox(n.path);a&&(a.width||a.height)?(t.width=this.canvas.width,t.height=this.canvas.height,s.translate(a.x||0,a.y||0)):(t.width=e[0],t.height=e[1]),this.fillSketch(s,n,i),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(t,'repeat');const l=new Path2D(n.path);this.ctx.fill(l),this.ctx.restore()}break}}}computeBBox(e){if(E)try{const t=document.createElementNS('http://www.w3.org/2000/svg','svg');t.setAttribute('width','0'),t.setAttribute('height','0');const i=self.document.createElementNS('http://www.w3.org/2000/svg','path');i.setAttribute('d',e),t.appendChild(i),document.body.appendChild(t);const s=i.getBBox();return document.body.removeChild(t),s}catch(e){}return null}fillSketch(e,t,i){let s=i.fillWeight;0>s&&(s=i.strokeWidth/2),e.save(),e.strokeStyle=i.fill||'',e.lineWidth=s,this._drawToContext(e,t),e.restore()}_drawToContext(e,t){e.beginPath();for(const i of t.ops){const t=i.data;switch(i.op){case'move':e.moveTo(t[0],t[1]);break;case'bcurveTo':e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case'qcurveTo':e.quadraticCurveTo(t[0],t[1],t[2],t[3]);break;case'lineTo':e.lineTo(t[0],t[1]);}}'fillPath'===t.type?e.fill():e.stroke()}}class L extends z{async line(e,t,i,s,n){const a=this._options(n);return this._drawable('line',[await this.lib.line(e,t,i,s,a)],a)}async rectangle(e,t,i,s,n){const a=this._options(n),l=[];if(a.fill){const n=[[e,t],[e+i,t],[e+i,t+s],[e,t+s]];'solid'===a.fillStyle?l.push((await this.lib.solidFillPolygon(n,a))):l.push((await this.lib.patternFillPolygon(n,a)))}return l.push((await this.lib.rectangle(e,t,i,s,a))),this._drawable('rectangle',l,a)}async ellipse(e,t,i,s,n){const a=this._options(n),l=[];if(a.fill)if('solid'===a.fillStyle){const n=await this.lib.ellipse(e,t,i,s,a);n.type='fillPath',l.push(n)}else l.push((await this.lib.patternFillEllipse(e,t,i,s,a)));return l.push((await this.lib.ellipse(e,t,i,s,a))),this._drawable('ellipse',l,a)}async circle(e,t,i,s){const n=await this.ellipse(e,t,i,i,s);return n.shape='circle',n}async linearPath(e,t){const i=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,i)],i)}async arc(e,t,i,s,n,a,l=!1,p){const r=this._options(p),o=[];if(l&&r.fill)if('solid'===r.fillStyle){const l=await this.lib.arc(e,t,i,s,n,a,!0,!1,r);l.type='fillPath',o.push(l)}else o.push((await this.lib.patternFillArc(e,t,i,s,n,a,r)));return o.push((await this.lib.arc(e,t,i,s,n,a,l,!0,r))),this._drawable('arc',o,r)}async curve(e,t){const i=this._options(t);return this._drawable('curve',[await this.lib.curve(e,i)],i)}async polygon(e,t){const i=this._options(t),s=[];if(i.fill)if('solid'===i.fillStyle)s.push((await this.lib.solidFillPolygon(e,i)));else{const t=this.computePolygonSize(e),n=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(n,i);a.type='path2Dpattern',a.size=t,a.path=this.polygonPath(e),s.push(a)}return s.push((await this.lib.linearPath(e,!0,i))),this._drawable('polygon',s,i)}async path(e,t){const i=this._options(t),s=[];if(!e)return this._drawable('path',s,i);if(i.fill)if('solid'===i.fillStyle){s.push({type:'path2Dfill',path:e,ops:[]})}else{const t=this.computePathSize(e),n=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(n,i);a.type='path2Dpattern',a.size=t,a.path=e,s.push(a)}return s.push((await this.lib.svgPath(e,i))),this._drawable('path',s,i)}}class N extends W{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.canvas)}get generator(){return this.genAsync}async line(e,t,i,s,n){const a=await this.genAsync.line(e,t,i,s,n);return this.draw(a),a}async rectangle(e,t,i,s,n){const a=await this.genAsync.rectangle(e,t,i,s,n);return this.draw(a),a}async ellipse(e,t,i,s,n){const a=await this.genAsync.ellipse(e,t,i,s,n);return this.draw(a),a}async circle(e,t,i,s){const n=await this.genAsync.circle(e,t,i,s);return this.draw(n),n}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i),i}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i),i}async arc(e,t,i,s,n,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,s,n,a,l,o);return this.draw(p),p}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i),i}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i),i}}const R='undefined'!=typeof document;class D{constructor(e,t){this.svg=e,this.gen=new z(t||null,this.svg)}get generator(){return this.gen}static createRenderer(){return new A}get defs(){if(R&&!this._defs){const e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}line(e,t,i,s,n){const a=this.gen.line(e,t,i,s,n);return this.draw(a)}rectangle(e,t,i,s,n){const a=this.gen.rectangle(e,t,i,s,n);return this.draw(a)}ellipse(e,t,i,s,n){const a=this.gen.ellipse(e,t,i,s,n);return this.draw(a)}circle(e,t,i,s){const n=this.gen.circle(e,t,i,s);return this.draw(n)}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i)}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i)}arc(e,t,i,s,n,a,l=!1,o){const p=this.gen.arc(e,t,i,s,n,a,l,o);return this.draw(p)}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i)}path(e,t){const i=this.gen.path(e,t);return this.draw(i)}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,n=this.svg.ownerDocument||R&&document,a=n.createElementNS('http://www.w3.org/2000/svg','g');for(const l of t){let e=null;switch(l.type){case'path':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke=i.stroke,e.style.strokeWidth=i.strokeWidth+'',e.style.fill='none';break}case'fillPath':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'fillSketch':{e=this.fillSketch(n,l,i);break}case'path2Dfill':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'path2Dpattern':{const t=l.size,a=n.createElementNS('http://www.w3.org/2000/svg','pattern'),o=`rough-${r(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;a.setAttribute('id',o),a.setAttribute('x','0'),a.setAttribute('y','0'),a.setAttribute('width','1'),a.setAttribute('height','1'),a.setAttribute('height','1'),a.setAttribute('viewBox',`0 0 ${s(t[0])} ${s(t[1])}`),a.setAttribute('patternUnits','objectBoundingBox');const p=this.fillSketch(n,l,i);a.appendChild(p),this.defs.appendChild(a),e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=`url(#${o})`;break}}e&&a.appendChild(e)}return a}opsToPath(e){return this.gen.opsToPath(e)}fillSketch(e,t,i){let s=i.fillWeight;0>s&&(s=i.strokeWidth/2);const n=e.createElementNS('http://www.w3.org/2000/svg','path');return n.setAttribute('d',this.opsToPath(t)),n.style.stroke=i.fill,n.style.strokeWidth=s+'',n.style.fill='none',n}}class B extends D{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.svg)}get generator(){return this.genAsync}async line(e,t,i,s,n){const a=await this.genAsync.line(e,t,i,s,n);return this.draw(a)}async rectangle(e,t,i,s,n){const a=await this.genAsync.rectangle(e,t,i,s,n);return this.draw(a)}async ellipse(e,t,i,s,n){const a=await this.genAsync.ellipse(e,t,i,s,n);return this.draw(a)}async circle(e,t,i,s){const n=await this.genAsync.circle(e,t,i,s);return this.draw(n)}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i)}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i)}async arc(e,t,i,s,n,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,s,n,a,l,o);return this.draw(p)}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i)}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i)}}var M={canvas(e,t){return t&&t.async?new N(e,t):new W(e,t)},svg(e,t){return t&&t.async?new B(e,t):new D(e,t)},createRenderer(){return W.createRenderer()},generator(e,t){return e&&e.async?new L(e,t):new z(e,t)}};return M}(); diff --git a/dist/rough.umd.es5.js b/dist/rough.umd.es5.js index c483f16..5e589d3 100644 --- a/dist/rough.umd.es5.js +++ b/dist/rough.umd.es5.js @@ -62,26 +62,26 @@ return token.type === type; } var PARAMS = { - A: { length: 7 }, - a: { length: 7 }, - C: { length: 6 }, - c: { length: 6 }, - H: { length: 1 }, - h: { length: 1 }, - L: { length: 2 }, - l: { length: 2 }, - M: { length: 2 }, - m: { length: 2 }, - Q: { length: 4 }, - q: { length: 4 }, - S: { length: 4 }, - s: { length: 4 }, - T: { length: 4 }, - t: { length: 2 }, - V: { length: 1 }, - v: { length: 1 }, - Z: { length: 0 }, - z: { length: 0 } + A: 7, + a: 7, + C: 6, + c: 6, + H: 1, + h: 1, + L: 2, + l: 2, + M: 2, + m: 2, + Q: 4, + q: 4, + S: 4, + s: 4, + T: 4, + t: 2, + V: 1, + v: 1, + Z: 0, + z: 0 }; var ParsedPath = function () { @@ -131,7 +131,7 @@ if (mode === 'BOD') { if (token.text === 'M' || token.text === 'm') { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } else { this.parseData('M0,0' + d); @@ -139,10 +139,10 @@ } } else { if (isType(token, this.NUMBER)) { - param_length = PARAMS[mode].length; + param_length = PARAMS[mode]; } else { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } } @@ -156,7 +156,7 @@ return; } } - if (PARAMS[mode]) { + if (typeof PARAMS[mode] === 'number') { var segment = { key: mode, data: params }; this.segments.push(segment); index += param_length; diff --git a/dist/rough.umd.es5.min.js b/dist/rough.umd.es5.min.js index 0b5bdb3..06ca91d 100644 --- a/dist/rough.umd.es5.min.js +++ b/dist/rough.umd.es5.min.js @@ -1 +1 @@ -(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.rough=t()})(this,function(){'use strict';function e(e,t){return e.type===t}function t(e,t){var l=t.fillStyle||'hachure';if(!T[l])switch(l){case'zigzag':T[l]||(T[l]=new S(e));break;case'cross-hatch':T[l]||(T[l]=new A(e));break;case'hachure':default:l='hachure',T[l]||(T[l]=new O(e));}return T[l]}function l(e){if(z&&E&&self&&self.workly&&e.async&&!e.noWorker){var t=e.worklyURL||'https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js';if(t){var l=URL.createObjectURL(new Blob(['importScripts(\''+t+'\', \''+E+'\');\nworkly.expose(self.rough.createRenderer());']));return self.workly.proxy(l)}}return new C}var a=Math.round,n=Math.max,s=Math.min,i=Math.pow,r=Math.floor,p=Math.sqrt,d=Math.cos,h=Math.sin,g=Math.abs,f=Math.PI,o='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},u=function(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')},y=function(){function e(e,t){for(var l,a=0;a_){var k=p(1-_/(this._rx*this._rx*this._ry*this._ry));this._rx*=k,this._ry*=k,v=0}else v=(i===o?-1:1)*p(_/(this._rx*this._rx*c*c+this._ry*this._ry*y*y));var s=v*this._rx*c/this._ry,x=-v*this._ry*y/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*s-this._sinPhi*x+(t[0]+l[0])/2,this._C[1]=this._sinPhi*s+this._cosPhi*x+(t[1]+l[1])/2,this._theta=this.calculateVectorAngle(1,0,(y-s)/this._rx,(c-x)/this._ry);var b=this.calculateVectorAngle((y-s)/this._rx,(c-x)/this._ry,(-y-s)/this._rx,(-c-x)/this._ry);!o&&0b&&(b+=2*f),this._numSegs=Math.ceil(g(b/(f/2))),this._delta=b/this._numSegs,this._T=8/3*h(this._delta/4)*h(this._delta/4)/h(this._delta/2)}}return y(e,[{key:'getNextSegment',value:function(){if(this._segIndex===this._numSegs)return null;var e=d(this._theta),t=h(this._theta),l=this._theta+this._delta,a=d(l),n=h(l),i=[this._cosPhi*this._rx*a-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*a+this._cosPhi*this._ry*n+this._C[1]],s=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[i[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*a),i[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*a)];return this._theta=l,this._from=[i[0],i[1]],this._segIndex++,{cp1:s,cp2:o,to:i}}},{key:'calculateVectorAngle',value:function(e,t,l,a){var n=Math.atan2,i=n(t,e),s=n(a,l);return s>=i?s-i:2*f-(i-s)}}]),e}(),m=function(){function e(t,l){u(this,e),this.sets=t,this.closed=l}return y(e,[{key:'fit',value:function(e){var t=[],l=!0,a=!1,n=void 0;try{for(var s,o=this.sets[Symbol.iterator]();!(l=(s=o.next()).done);l=!0){var p=s.value,h=p.length,g=r(e*h);if(5>g){if(5>=h)continue;g=5}t.push(this.reduce(p,g))}}catch(e){a=!0,n=e}finally{try{!l&&o.return&&o.return()}finally{if(a)throw n}}var f='',u=!0,y=!1,c=void 0;try{for(var v,_,k=t[Symbol.iterator]();!(u=(v=k.next()).done);u=!0){_=v.value;for(var x,b=0;b<_.length;b++)x=_[b],f+=0===b?'M'+x[0]+','+x[1]:'L'+x[0]+','+x[1];this.closed&&(f+='z ')}}catch(e){y=!0,c=e}finally{try{!u&&k.return&&k.return()}finally{if(y)throw c}}return f}},{key:'distance',value:function(e,t){return p(i(e[0]-t[0],2)+i(e[1]-t[1],2))}},{key:'reduce',value:function(e,t){if(e.length<=t)return e;for(var l=e.slice(0);l.length>t;){for(var n=-1,o=-1,r=1;rn||s=s(e.py1,e.py2)&&this.py1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=s(e.py1,e.py2)&&this.py2<=n(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+r,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===t?(this.xi=e.px1,this.yi=l*this.xi+o,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(p))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):l===i?o==r&&(this.px1>=s(e.px1,e.px2)&&this.px1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=s(e.px1,e.px2)&&this.px2<=n(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(r-o)/(l-i),this.yi=l*this.xi+o,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}]),e}(),P=function(){function e(t,l,a,n,i,s,o,r){u(this,e),this.deltaX=0,this.hGap=0,this.top=t,this.bottom=l,this.left=a,this.right=n,this.gap=i,this.sinAngle=s,this.tanAngle=r,1e-4>g(s)?this.pos=a+i:.9999g(this.sinAngle)){if(this.posthis.right&&l>this.right;)if(this.pos+=this.hGap,t=this.pos-this.deltaX/2,l=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;var i=new w([t,a],[l,n]);this.sLeft&&i.intersects(this.sLeft)&&(t=i.xi,a=i.yi),this.sRight&&i.intersects(this.sRight)&&(l=i.xi,n=i.yi),0v&&(v=4*l.strokeWidth),v=n(v,.1);for(var _=c%180*(f/180),k=d(_),x=h(_),b=t(_),m=new P(g-1,u+1,r-1,p+1,v,x,k,b),w=void 0,O=null;null!=(w=m.nextLine());)for(var S=this.getIntersectingLines(w,e),A=0;A=u&&(u=4*i.strokeWidth);var y=i.fillWeight;0>y&&(y=i.strokeWidth/2);for(var c=t(h%180*(f/180)),v=d/r,_=p(v*c*v*c+1),k=v*c/_,x=1/_,b=u/(r*d/p(d*x*(d*x)+r*k*(r*k))/r),m=p(r*r-(e-r+b)*(e-r+b)),w=null,P=e-r+b;P_;)_+=2*f,k+=2*f;k-_>2*f&&(_=0,k=2*f);var x=2*f/u.curveStepCount,b=s(x/2,(k-_)/2),m=this._arc(b,o,y,c,v,_,k,1,u),w=this._arc(b,o,y,c,v,_,k,1.5,u),P=m.concat(w);return r&&(p?(P=P.concat(this.doubleLine(o,y,o+c*d(_),y+v*h(_),u)),P=P.concat(this.doubleLine(o,y,o+c*d(k),y+v*h(k),u))):(P.push({op:'lineTo',data:[o,y]}),P.push({op:'lineTo',data:[o+c*d(_),y+v*h(_)]}))),{type:'path',ops:P}}},{key:'svgPath',value:function(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');var l=new x(e);if(t.simplification){var a=new m(l.linearPoints,l.closed),n=a.fit(t.simplification);l=new x(n)}for(var o=[],r=l.segments||[],d=0;dy;)y+=2*f,c+=2*f;c-y>2*f&&(y=0,c=2*f);for(var v=(c-y)/s.curveStepCount,_=[],k=y;k<=c;k+=v)_.push([o+p*d(k),r+u*h(k)]);return _.push([o+p*d(c),r+u*h(c)]),_.push([o,r]),this.patternFillPolygon(_,s)}},{key:'getOffset',value:function(e,t,l){return l.roughness*(Math.random()*(t-e)+e)}},{key:'doubleLine',value:function(e,t,l,a,n){var i=this._line(e,t,l,a,n,!0,!1),s=this._line(e,t,l,a,n,!0,!0);return i.concat(s)}},{key:'_line',value:function(e,t,l,a,n,s,o){var r=i(e-l,2)+i(t-a,2),d=n.maxRandomnessOffset||0;100*(d*d)>r&&(d=p(r)/10);var h=d/2,g=.2+.2*Math.random(),f=n.bowing*n.maxRandomnessOffset*(a-t)/200,u=n.bowing*n.maxRandomnessOffset*(e-l)/200;f=this.getOffset(-f,f,n),u=this.getOffset(-u,u,n);var y=[];return s&&(o?y.push({op:'move',data:[e+this.getOffset(-h,h,n),t+this.getOffset(-h,h,n)]}):y.push({op:'move',data:[e+this.getOffset(-d,d,n),t+this.getOffset(-d,d,n)]})),o?y.push({op:'bcurveTo',data:[f+e+(l-e)*g+this.getOffset(-h,h,n),u+t+(a-t)*g+this.getOffset(-h,h,n),f+e+2*(l-e)*g+this.getOffset(-h,h,n),u+t+2*(a-t)*g+this.getOffset(-h,h,n),l+this.getOffset(-h,h,n),a+this.getOffset(-h,h,n)]}):y.push({op:'bcurveTo',data:[f+e+(l-e)*g+this.getOffset(-d,d,n),u+t+(a-t)*g+this.getOffset(-d,d,n),f+e+2*(l-e)*g+this.getOffset(-d,d,n),u+t+2*(a-t)*g+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),a+this.getOffset(-d,d,n)]}),y}},{key:'_curve',value:function(e,t,l){var a=e.length,n=[];if(3g;g++)0===g?o.push({op:'move',data:[r.x,r.y]}):o.push({op:'move',data:[r.x+this.getOffset(-d[0],d[0],p),r.y+this.getOffset(-d[0],d[0],p)]}),h=[n+this.getOffset(-d[g],d[g],p),s+this.getOffset(-d[g],d[g],p)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[g],d[g],p),t+this.getOffset(-d[g],d[g],p),l+this.getOffset(-d[g],d[g],p),a+this.getOffset(-d[g],d[g],p),h[0],h[1]]});return r.setPosition(h[0],h[1]),o}},{key:'_processSegment',value:function(e,t,l,a){var n=[];switch(t.key){case'M':case'm':{var s='m'===t.key;if(2<=t.data.length){var o=+t.data[0],r=+t.data[1];s&&(o+=e.x,r+=e.y);var p=1*(a.maxRandomnessOffset||0);o+=this.getOffset(-p,p,a),r+=this.getOffset(-p,p,a),e.setPosition(o,r),n.push({op:'move',data:[o,r]})}break}case'L':case'l':{var d='l'===t.key;if(2<=t.data.length){var h=+t.data[0],g=+t.data[1];d&&(h+=e.x,g+=e.y),n=n.concat(this.doubleLine(e.x,e.y,h,g,a)),e.setPosition(h,g)}break}case'H':case'h':{var u='h'===t.key;if(t.data.length){var c=+t.data[0];u&&(c+=e.x),n=n.concat(this.doubleLine(e.x,e.y,c,e.y,a)),e.setPosition(c,e.y)}break}case'V':case'v':{var v='v'===t.key;if(t.data.length){var _=+t.data[0];v&&(_+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,_,a)),e.setPosition(e.x,_)}break}case'Z':case'z':{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],a)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{var k='c'===t.key;if(6<=t.data.length){var m=+t.data[0],w=+t.data[1],P=+t.data[2],O=+t.data[3],S=+t.data[4],A=+t.data[5];k&&(m+=e.x,P+=e.x,S+=e.x,w+=e.y,O+=e.y,A+=e.y);var T=this._bezierTo(m,w,P,O,S,A,e,a);n=n.concat(T),e.bezierReflectionPoint=[S+(S-P),A+(A-O)]}break}case'S':case's':{var C='s'===t.key;if(4<=t.data.length){var z=+t.data[0],E=+t.data[1],L=+t.data[2],R=+t.data[3];C&&(z+=e.x,L+=e.x,E+=e.y,R+=e.y);var W=z,N=E,D=l?l.key:'',B=null;('c'===D||'C'===D||'s'===D||'S'===D)&&(B=e.bezierReflectionPoint),B&&(W=B[0],N=B[1]);var F=this._bezierTo(W,N,z,E,L,R,e,a);n=n.concat(F),e.bezierReflectionPoint=[L+(L-z),R+(R-E)]}break}case'Q':case'q':{var M='q'===t.key;if(4<=t.data.length){var q=+t.data[0],U=+t.data[1],X=+t.data[2],V=+t.data[3];M&&(q+=e.x,X+=e.x,U+=e.y,V+=e.y);var G=1*(1+.2*a.roughness),j=1.5*(1+.22*a.roughness);n.push({op:'move',data:[e.x+this.getOffset(-G,G,a),e.y+this.getOffset(-G,G,a)]});var I=[X+this.getOffset(-G,G,a),V+this.getOffset(-G,G,a)];n.push({op:'qcurveTo',data:[q+this.getOffset(-G,G,a),U+this.getOffset(-G,G,a),I[0],I[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-j,j,a),e.y+this.getOffset(-j,j,a)]}),I=[X+this.getOffset(-j,j,a),V+this.getOffset(-j,j,a)],n.push({op:'qcurveTo',data:[q+this.getOffset(-j,j,a),U+this.getOffset(-j,j,a),I[0],I[1]]}),e.setPosition(I[0],I[1]),e.quadReflectionPoint=[X+(X-q),V+(V-U)]}break}case'T':case't':{var Q='t'===t.key;if(2<=t.data.length){var $=+t.data[0],Z=+t.data[1];Q&&($+=e.x,Z+=e.y);var H=$,J=Z,Y=l?l.key:'',K=null;('q'===Y||'Q'===Y||'t'===Y||'T'===Y)&&(K=e.quadReflectionPoint),K&&(H=K[0],J=K[1]);var ee=1*(1+.2*a.roughness),te=1.5*(1+.22*a.roughness);n.push({op:'move',data:[e.x+this.getOffset(-ee,ee,a),e.y+this.getOffset(-ee,ee,a)]});var le=[$+this.getOffset(-ee,ee,a),Z+this.getOffset(-ee,ee,a)];n.push({op:'qcurveTo',data:[H+this.getOffset(-ee,ee,a),J+this.getOffset(-ee,ee,a),le[0],le[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-te,te,a),e.y+this.getOffset(-te,te,a)]}),le=[$+this.getOffset(-te,te,a),Z+this.getOffset(-te,te,a)],n.push({op:'qcurveTo',data:[H+this.getOffset(-te,te,a),J+this.getOffset(-te,te,a),le[0],le[1]]}),e.setPosition(le[0],le[1]),e.quadReflectionPoint=[$+($-H),Z+(Z-J)]}break}case'A':case'a':{var ae='a'===t.key;if(7<=t.data.length){var ne=+t.data[0],ie=+t.data[1],se=+t.data[2],oe=+t.data[3],re=+t.data[4],pe=+t.data[5],de=+t.data[6];if(ae&&(pe+=e.x,de+=e.y),pe===e.x&&de===e.y)break;if(0==ne||0==ie)n=n.concat(this.doubleLine(e.x,e.y,pe,de,a)),e.setPosition(pe,de);else for(var he=0;1>he;he++)for(var ge,fe=new b([e.x,e.y],[pe,de],[ne,ie],se,!!oe,!!re),ue=fe.getNextSegment();ue;)ge=this._bezierTo(ue.cp1[0],ue.cp1[1],ue.cp2[0],ue.cp2[1],ue.to[0],ue.to[1],e,a),n=n.concat(ge),ue=fe.getNextSegment()}break}default:}return n}}]),e}(),z='undefined'!=typeof self,E=z&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,L='undefined'!=typeof self,R=function(){function e(t,a){u(this,e),this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=t||{},this.surface=a,this.renderer=l(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}return y(e,[{key:'_options',value:function(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}},{key:'_drawable',value:function(e,t,l){return{shape:e,sets:t||[],options:l||this.defaultOptions}}},{key:'getCanvasSize',value:function(){var e=function(e){return e&&'object'===('undefined'==typeof e?'undefined':o(e))&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100};return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}},{key:'computePolygonSize',value:function(e){if(e.length){for(var t=e[0][0],l=e[0][0],a=e[0][1],o=e[0][1],r=1;rl&&(l=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:l,fill:'none'}}},{key:'opsToPath',value:function(e){var t='',l=!0,a=!1,n=void 0;try{for(var i,s=e.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case'move':t+='M'+r[0]+' '+r[1]+' ';break;case'bcurveTo':t+='C'+r[0]+' '+r[1]+', '+r[2]+' '+r[3]+', '+r[4]+' '+r[5]+' ';break;case'qcurveTo':t+='Q'+r[0]+' '+r[1]+', '+r[2]+' '+r[3]+' ';break;case'lineTo':t+='L'+r[0]+' '+r[1]+' ';}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}return t.trim()}},{key:'lib',get:function(){return this.renderer}}]),e}(),W='undefined'!=typeof document,N=function(){function e(t,l){u(this,e),this.canvas=t,this.ctx=this.canvas.getContext('2d'),this.gen=new R(l||null,this.canvas)}return y(e,[{key:'line',value:function(e,t,l,a,n){var i=this.gen.line(e,t,l,a,n);return this.draw(i),i}},{key:'rectangle',value:function(e,t,l,a,n){var i=this.gen.rectangle(e,t,l,a,n);return this.draw(i),i}},{key:'ellipse',value:function(e,t,l,a,n){var i=this.gen.ellipse(e,t,l,a,n);return this.draw(i),i}},{key:'circle',value:function(e,t,l,a){var n=this.gen.circle(e,t,l,a);return this.draw(n),n}},{key:'linearPath',value:function(e,t){var l=this.gen.linearPath(e,t);return this.draw(l),l}},{key:'polygon',value:function(e,t){var l=this.gen.polygon(e,t);return this.draw(l),l}},{key:'arc',value:function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2),e.save(),e.strokeStyle=l.fill||'',e.lineWidth=a,this._drawToContext(e,t),e.restore()}},{key:'_drawToContext',value:function(e,t){e.beginPath();var l=!0,a=!1,n=void 0;try{for(var i,s=t.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case'move':e.moveTo(r[0],r[1]);break;case'bcurveTo':e.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case'qcurveTo':e.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case'lineTo':e.lineTo(r[0],r[1]);}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}'fillPath'===t.type?e.fill():e.stroke()}},{key:'generator',get:function(){return this.gen}}],[{key:'createRenderer',value:function(){return new C}}]),e}(),D=function(e){function t(){return u(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),y(t,[{key:'line',value:async function(e,t,l,a,n){var i=this._options(n);return this._drawable('line',[await this.lib.line(e,t,l,a,i)],i)}},{key:'rectangle',value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill){var o=[[e,t],[e+l,t],[e+l,t+a],[e,t+a]];'solid'===i.fillStyle?s.push((await this.lib.solidFillPolygon(o,i))):s.push((await this.lib.patternFillPolygon(o,i)))}return s.push((await this.lib.rectangle(e,t,l,a,i))),this._drawable('rectangle',s,i)}},{key:'ellipse',value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill)if('solid'===i.fillStyle){var o=await this.lib.ellipse(e,t,l,a,i);o.type='fillPath',s.push(o)}else s.push((await this.lib.patternFillEllipse(e,t,l,a,i)));return s.push((await this.lib.ellipse(e,t,l,a,i))),this._drawable('ellipse',s,i)}},{key:'circle',value:async function(e,t,l,a){var n=await this.ellipse(e,t,l,l,a);return n.shape='circle',n}},{key:'linearPath',value:async function(e,t){var l=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,l)],l)}},{key:'arc',value:async function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2);var n=e.createElementNS('http://www.w3.org/2000/svg','path');return n.setAttribute('d',this.opsToPath(t)),n.style.stroke=l.fill,n.style.strokeWidth=a+'',n.style.fill='none',n}},{key:'generator',get:function(){return this.gen}},{key:'defs',get:function(){if(F&&!this._defs){var e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}}],[{key:'createRenderer',value:function(){return new C}}]),e}(),q=function(e){function t(e,l){u(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l));return a.genAsync=new D(l||null,a.svg),a}return c(t,e),y(t,[{key:'line',value:async function(e,t,l,a,n){var i=await this.genAsync.line(e,t,l,a,n);return this.draw(i)}},{key:'rectangle',value:async function(e,t,l,a,n){var i=await this.genAsync.rectangle(e,t,l,a,n);return this.draw(i)}},{key:'ellipse',value:async function(e,t,l,a,n){var i=await this.genAsync.ellipse(e,t,l,a,n);return this.draw(i)}},{key:'circle',value:async function(e,t,l,a){var n=await this.genAsync.circle(e,t,l,a);return this.draw(n)}},{key:'linearPath',value:async function(e,t){var l=await this.genAsync.linearPath(e,t);return this.draw(l)}},{key:'polygon',value:async function(e,t){var l=await this.genAsync.polygon(e,t);return this.draw(l)}},{key:'arc',value:async function(e,t,l,a,n,i){var s=!!(6_){var k=p(1-_/(this._rx*this._rx*this._ry*this._ry));this._rx*=k,this._ry*=k,v=0}else v=(i===o?-1:1)*p(_/(this._rx*this._rx*c*c+this._ry*this._ry*y*y));var s=v*this._rx*c/this._ry,x=-v*this._ry*y/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*s-this._sinPhi*x+(t[0]+l[0])/2,this._C[1]=this._sinPhi*s+this._cosPhi*x+(t[1]+l[1])/2,this._theta=this.calculateVectorAngle(1,0,(y-s)/this._rx,(c-x)/this._ry);var b=this.calculateVectorAngle((y-s)/this._rx,(c-x)/this._ry,(-y-s)/this._rx,(-c-x)/this._ry);!o&&0b&&(b+=2*h),this._numSegs=Math.ceil(u(b/(h/2))),this._delta=b/this._numSegs,this._T=8/3*f(this._delta/4)*f(this._delta/4)/f(this._delta/2)}}return y(e,[{key:'getNextSegment',value:function(){if(this._segIndex===this._numSegs)return null;var e=d(this._theta),t=f(this._theta),l=this._theta+this._delta,a=d(l),n=f(l),i=[this._cosPhi*this._rx*a-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*a+this._cosPhi*this._ry*n+this._C[1]],s=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[i[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*a),i[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*a)];return this._theta=l,this._from=[i[0],i[1]],this._segIndex++,{cp1:s,cp2:o,to:i}}},{key:'calculateVectorAngle',value:function(e,t,l,a){var n=Math.atan2,i=n(t,e),s=n(a,l);return s>=i?s-i:2*h-(i-s)}}]),e}(),m=function(){function e(t,l){g(this,e),this.sets=t,this.closed=l}return y(e,[{key:'fit',value:function(e){var t=[],l=!0,a=!1,n=void 0;try{for(var s,o=this.sets[Symbol.iterator]();!(l=(s=o.next()).done);l=!0){var p=s.value,f=p.length,u=r(e*f);if(5>u){if(5>=f)continue;u=5}t.push(this.reduce(p,u))}}catch(e){a=!0,n=e}finally{try{!l&&o.return&&o.return()}finally{if(a)throw n}}var h='',g=!0,y=!1,c=void 0;try{for(var v,_,k=t[Symbol.iterator]();!(g=(v=k.next()).done);g=!0){_=v.value;for(var x,b=0;b<_.length;b++)x=_[b],h+=0===b?'M'+x[0]+','+x[1]:'L'+x[0]+','+x[1];this.closed&&(h+='z ')}}catch(e){y=!0,c=e}finally{try{!g&&k.return&&k.return()}finally{if(y)throw c}}return h}},{key:'distance',value:function(e,t){return p(i(e[0]-t[0],2)+i(e[1]-t[1],2))}},{key:'reduce',value:function(e,t){if(e.length<=t)return e;for(var l=e.slice(0);l.length>t;){for(var n=-1,o=-1,r=1;rn||s=s(e.py1,e.py2)&&this.py1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=s(e.py1,e.py2)&&this.py2<=n(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+r,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>u(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===t?(this.xi=e.px1,this.yi=l*this.xi+o,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>u(p))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):l===i?o==r&&(this.px1>=s(e.px1,e.px2)&&this.px1<=n(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=s(e.px1,e.px2)&&this.px2<=n(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(r-o)/(l-i),this.yi=l*this.xi+o,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}]),e}(),P=function(){function e(t,l,a,n,i,s,o,r){g(this,e),this.deltaX=0,this.hGap=0,this.top=t,this.bottom=l,this.left=a,this.right=n,this.gap=i,this.sinAngle=s,this.tanAngle=r,1e-4>u(s)?this.pos=a+i:.9999u(this.sinAngle)){if(this.posthis.right&&l>this.right;)if(this.pos+=this.hGap,t=this.pos-this.deltaX/2,l=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;var i=new w([t,a],[l,n]);this.sLeft&&i.intersects(this.sLeft)&&(t=i.xi,a=i.yi),this.sRight&&i.intersects(this.sRight)&&(l=i.xi,n=i.yi),0v&&(v=4*l.strokeWidth),v=n(v,.1);for(var _=c%180*(h/180),k=d(_),x=f(_),b=t(_),m=new P(u-1,g+1,r-1,p+1,v,x,k,b),w=void 0,O=null;null!=(w=m.nextLine());)for(var S=this.getIntersectingLines(w,e),A=0;A=g&&(g=4*i.strokeWidth);var y=i.fillWeight;0>y&&(y=i.strokeWidth/2);for(var c=t(f%180*(h/180)),v=d/r,_=p(v*c*v*c+1),k=v*c/_,x=1/_,b=g/(r*d/p(d*x*(d*x)+r*k*(r*k))/r),m=p(r*r-(e-r+b)*(e-r+b)),w=null,P=e-r+b;P_;)_+=2*h,k+=2*h;k-_>2*h&&(_=0,k=2*h);var x=2*h/g.curveStepCount,b=s(x/2,(k-_)/2),m=this._arc(b,o,y,c,v,_,k,1,g),w=this._arc(b,o,y,c,v,_,k,1.5,g),P=m.concat(w);return r&&(p?(P=P.concat(this.doubleLine(o,y,o+c*d(_),y+v*f(_),g)),P=P.concat(this.doubleLine(o,y,o+c*d(k),y+v*f(k),g))):(P.push({op:'lineTo',data:[o,y]}),P.push({op:'lineTo',data:[o+c*d(_),y+v*f(_)]}))),{type:'path',ops:P}}},{key:'svgPath',value:function(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');var l=new x(e);if(t.simplification){var a=new m(l.linearPoints,l.closed),n=a.fit(t.simplification);l=new x(n)}for(var o=[],r=l.segments||[],d=0;dy;)y+=2*h,c+=2*h;c-y>2*h&&(y=0,c=2*h);for(var v=(c-y)/s.curveStepCount,_=[],k=y;k<=c;k+=v)_.push([o+p*d(k),r+g*f(k)]);return _.push([o+p*d(c),r+g*f(c)]),_.push([o,r]),this.patternFillPolygon(_,s)}},{key:'getOffset',value:function(e,t,l){return l.roughness*(Math.random()*(t-e)+e)}},{key:'doubleLine',value:function(e,t,l,a,n){var i=this._line(e,t,l,a,n,!0,!1),s=this._line(e,t,l,a,n,!0,!0);return i.concat(s)}},{key:'_line',value:function(e,t,l,a,n,s,o){var r=i(e-l,2)+i(t-a,2),d=n.maxRandomnessOffset||0;100*(d*d)>r&&(d=p(r)/10);var f=d/2,u=.2+.2*Math.random(),h=n.bowing*n.maxRandomnessOffset*(a-t)/200,g=n.bowing*n.maxRandomnessOffset*(e-l)/200;h=this.getOffset(-h,h,n),g=this.getOffset(-g,g,n);var y=[];return s&&(o?y.push({op:'move',data:[e+this.getOffset(-f,f,n),t+this.getOffset(-f,f,n)]}):y.push({op:'move',data:[e+this.getOffset(-d,d,n),t+this.getOffset(-d,d,n)]})),o?y.push({op:'bcurveTo',data:[h+e+(l-e)*u+this.getOffset(-f,f,n),g+t+(a-t)*u+this.getOffset(-f,f,n),h+e+2*(l-e)*u+this.getOffset(-f,f,n),g+t+2*(a-t)*u+this.getOffset(-f,f,n),l+this.getOffset(-f,f,n),a+this.getOffset(-f,f,n)]}):y.push({op:'bcurveTo',data:[h+e+(l-e)*u+this.getOffset(-d,d,n),g+t+(a-t)*u+this.getOffset(-d,d,n),h+e+2*(l-e)*u+this.getOffset(-d,d,n),g+t+2*(a-t)*u+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),a+this.getOffset(-d,d,n)]}),y}},{key:'_curve',value:function(e,t,l){var a=e.length,n=[];if(3h;h++)0===h?o.push({op:'move',data:[r.x,r.y]}):o.push({op:'move',data:[r.x+this.getOffset(-d[0],d[0],p),r.y+this.getOffset(-d[0],d[0],p)]}),u=[n+this.getOffset(-d[h],d[h],p),s+this.getOffset(-d[h],d[h],p)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[h],d[h],p),t+this.getOffset(-d[h],d[h],p),l+this.getOffset(-d[h],d[h],p),a+this.getOffset(-d[h],d[h],p),u[0],u[1]]});return r.setPosition(u[0],u[1]),o}},{key:'_processSegment',value:function(e,t,l,a){var n=[];switch(t.key){case'M':case'm':{var s='m'===t.key;if(2<=t.data.length){var o=+t.data[0],r=+t.data[1];s&&(o+=e.x,r+=e.y);var p=1*(a.maxRandomnessOffset||0);o+=this.getOffset(-p,p,a),r+=this.getOffset(-p,p,a),e.setPosition(o,r),n.push({op:'move',data:[o,r]})}break}case'L':case'l':{var d='l'===t.key;if(2<=t.data.length){var u=+t.data[0],h=+t.data[1];d&&(u+=e.x,h+=e.y),n=n.concat(this.doubleLine(e.x,e.y,u,h,a)),e.setPosition(u,h)}break}case'H':case'h':{var g='h'===t.key;if(t.data.length){var c=+t.data[0];g&&(c+=e.x),n=n.concat(this.doubleLine(e.x,e.y,c,e.y,a)),e.setPosition(c,e.y)}break}case'V':case'v':{var v='v'===t.key;if(t.data.length){var _=+t.data[0];v&&(_+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,_,a)),e.setPosition(e.x,_)}break}case'Z':case'z':{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],a)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{var k='c'===t.key;if(6<=t.data.length){var m=+t.data[0],w=+t.data[1],P=+t.data[2],O=+t.data[3],S=+t.data[4],A=+t.data[5];k&&(m+=e.x,P+=e.x,S+=e.x,w+=e.y,O+=e.y,A+=e.y);var T=this._bezierTo(m,w,P,O,S,A,e,a);n=n.concat(T),e.bezierReflectionPoint=[S+(S-P),A+(A-O)]}break}case'S':case's':{var C='s'===t.key;if(4<=t.data.length){var z=+t.data[0],E=+t.data[1],L=+t.data[2],R=+t.data[3];C&&(z+=e.x,L+=e.x,E+=e.y,R+=e.y);var W=z,N=E,D=l?l.key:'',B=null;('c'===D||'C'===D||'s'===D||'S'===D)&&(B=e.bezierReflectionPoint),B&&(W=B[0],N=B[1]);var F=this._bezierTo(W,N,z,E,L,R,e,a);n=n.concat(F),e.bezierReflectionPoint=[L+(L-z),R+(R-E)]}break}case'Q':case'q':{var M='q'===t.key;if(4<=t.data.length){var q=+t.data[0],U=+t.data[1],X=+t.data[2],V=+t.data[3];M&&(q+=e.x,X+=e.x,U+=e.y,V+=e.y);var G=1*(1+.2*a.roughness),j=1.5*(1+.22*a.roughness);n.push({op:'move',data:[e.x+this.getOffset(-G,G,a),e.y+this.getOffset(-G,G,a)]});var I=[X+this.getOffset(-G,G,a),V+this.getOffset(-G,G,a)];n.push({op:'qcurveTo',data:[q+this.getOffset(-G,G,a),U+this.getOffset(-G,G,a),I[0],I[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-j,j,a),e.y+this.getOffset(-j,j,a)]}),I=[X+this.getOffset(-j,j,a),V+this.getOffset(-j,j,a)],n.push({op:'qcurveTo',data:[q+this.getOffset(-j,j,a),U+this.getOffset(-j,j,a),I[0],I[1]]}),e.setPosition(I[0],I[1]),e.quadReflectionPoint=[X+(X-q),V+(V-U)]}break}case'T':case't':{var Q='t'===t.key;if(2<=t.data.length){var $=+t.data[0],Z=+t.data[1];Q&&($+=e.x,Z+=e.y);var H=$,J=Z,Y=l?l.key:'',K=null;('q'===Y||'Q'===Y||'t'===Y||'T'===Y)&&(K=e.quadReflectionPoint),K&&(H=K[0],J=K[1]);var ee=1*(1+.2*a.roughness),te=1.5*(1+.22*a.roughness);n.push({op:'move',data:[e.x+this.getOffset(-ee,ee,a),e.y+this.getOffset(-ee,ee,a)]});var le=[$+this.getOffset(-ee,ee,a),Z+this.getOffset(-ee,ee,a)];n.push({op:'qcurveTo',data:[H+this.getOffset(-ee,ee,a),J+this.getOffset(-ee,ee,a),le[0],le[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-te,te,a),e.y+this.getOffset(-te,te,a)]}),le=[$+this.getOffset(-te,te,a),Z+this.getOffset(-te,te,a)],n.push({op:'qcurveTo',data:[H+this.getOffset(-te,te,a),J+this.getOffset(-te,te,a),le[0],le[1]]}),e.setPosition(le[0],le[1]),e.quadReflectionPoint=[$+($-H),Z+(Z-J)]}break}case'A':case'a':{var ae='a'===t.key;if(7<=t.data.length){var ne=+t.data[0],ie=+t.data[1],se=+t.data[2],oe=+t.data[3],re=+t.data[4],pe=+t.data[5],de=+t.data[6];if(ae&&(pe+=e.x,de+=e.y),pe===e.x&&de===e.y)break;if(0==ne||0==ie)n=n.concat(this.doubleLine(e.x,e.y,pe,de,a)),e.setPosition(pe,de);else for(var fe=0;1>fe;fe++)for(var ue,he=new b([e.x,e.y],[pe,de],[ne,ie],se,!!oe,!!re),ge=he.getNextSegment();ge;)ue=this._bezierTo(ge.cp1[0],ge.cp1[1],ge.cp2[0],ge.cp2[1],ge.to[0],ge.to[1],e,a),n=n.concat(ue),ge=he.getNextSegment()}break}default:}return n}}]),e}(),z='undefined'!=typeof self,E=z&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,L='undefined'!=typeof self,R=function(){function e(t,a){g(this,e),this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=t||{},this.surface=a,this.renderer=l(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}return y(e,[{key:'_options',value:function(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}},{key:'_drawable',value:function(e,t,l){return{shape:e,sets:t||[],options:l||this.defaultOptions}}},{key:'getCanvasSize',value:function(){var e=function(e){return e&&'object'===('undefined'==typeof e?'undefined':o(e))&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100};return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}},{key:'computePolygonSize',value:function(e){if(e.length){for(var t=e[0][0],l=e[0][0],a=e[0][1],o=e[0][1],r=1;rl&&(l=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:l,fill:'none'}}},{key:'opsToPath',value:function(e){var t='',l=!0,a=!1,n=void 0;try{for(var i,s=e.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case'move':t+='M'+r[0]+' '+r[1]+' ';break;case'bcurveTo':t+='C'+r[0]+' '+r[1]+', '+r[2]+' '+r[3]+', '+r[4]+' '+r[5]+' ';break;case'qcurveTo':t+='Q'+r[0]+' '+r[1]+', '+r[2]+' '+r[3]+' ';break;case'lineTo':t+='L'+r[0]+' '+r[1]+' ';}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}return t.trim()}},{key:'lib',get:function(){return this.renderer}}]),e}(),W='undefined'!=typeof document,N=function(){function e(t,l){g(this,e),this.canvas=t,this.ctx=this.canvas.getContext('2d'),this.gen=new R(l||null,this.canvas)}return y(e,[{key:'line',value:function(e,t,l,a,n){var i=this.gen.line(e,t,l,a,n);return this.draw(i),i}},{key:'rectangle',value:function(e,t,l,a,n){var i=this.gen.rectangle(e,t,l,a,n);return this.draw(i),i}},{key:'ellipse',value:function(e,t,l,a,n){var i=this.gen.ellipse(e,t,l,a,n);return this.draw(i),i}},{key:'circle',value:function(e,t,l,a){var n=this.gen.circle(e,t,l,a);return this.draw(n),n}},{key:'linearPath',value:function(e,t){var l=this.gen.linearPath(e,t);return this.draw(l),l}},{key:'polygon',value:function(e,t){var l=this.gen.polygon(e,t);return this.draw(l),l}},{key:'arc',value:function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2),e.save(),e.strokeStyle=l.fill||'',e.lineWidth=a,this._drawToContext(e,t),e.restore()}},{key:'_drawToContext',value:function(e,t){e.beginPath();var l=!0,a=!1,n=void 0;try{for(var i,s=t.ops[Symbol.iterator]();!(l=(i=s.next()).done);l=!0){var o=i.value,r=o.data;switch(o.op){case'move':e.moveTo(r[0],r[1]);break;case'bcurveTo':e.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case'qcurveTo':e.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case'lineTo':e.lineTo(r[0],r[1]);}}}catch(e){a=!0,n=e}finally{try{!l&&s.return&&s.return()}finally{if(a)throw n}}'fillPath'===t.type?e.fill():e.stroke()}},{key:'generator',get:function(){return this.gen}}],[{key:'createRenderer',value:function(){return new C}}]),e}(),D=function(e){function t(){return g(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),y(t,[{key:'line',value:async function(e,t,l,a,n){var i=this._options(n);return this._drawable('line',[await this.lib.line(e,t,l,a,i)],i)}},{key:'rectangle',value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill){var o=[[e,t],[e+l,t],[e+l,t+a],[e,t+a]];'solid'===i.fillStyle?s.push((await this.lib.solidFillPolygon(o,i))):s.push((await this.lib.patternFillPolygon(o,i)))}return s.push((await this.lib.rectangle(e,t,l,a,i))),this._drawable('rectangle',s,i)}},{key:'ellipse',value:async function(e,t,l,a,n){var i=this._options(n),s=[];if(i.fill)if('solid'===i.fillStyle){var o=await this.lib.ellipse(e,t,l,a,i);o.type='fillPath',s.push(o)}else s.push((await this.lib.patternFillEllipse(e,t,l,a,i)));return s.push((await this.lib.ellipse(e,t,l,a,i))),this._drawable('ellipse',s,i)}},{key:'circle',value:async function(e,t,l,a){var n=await this.ellipse(e,t,l,l,a);return n.shape='circle',n}},{key:'linearPath',value:async function(e,t){var l=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,l)],l)}},{key:'arc',value:async function(e,t,l,a,n,i){var s=!!(6a&&(a=l.strokeWidth/2);var n=e.createElementNS('http://www.w3.org/2000/svg','path');return n.setAttribute('d',this.opsToPath(t)),n.style.stroke=l.fill,n.style.strokeWidth=a+'',n.style.fill='none',n}},{key:'generator',get:function(){return this.gen}},{key:'defs',get:function(){if(F&&!this._defs){var e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}}],[{key:'createRenderer',value:function(){return new C}}]),e}(),q=function(e){function t(e,l){g(this,t);var a=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l));return a.genAsync=new D(l||null,a.svg),a}return c(t,e),y(t,[{key:'line',value:async function(e,t,l,a,n){var i=await this.genAsync.line(e,t,l,a,n);return this.draw(i)}},{key:'rectangle',value:async function(e,t,l,a,n){var i=await this.genAsync.rectangle(e,t,l,a,n);return this.draw(i)}},{key:'ellipse',value:async function(e,t,l,a,n){var i=await this.genAsync.ellipse(e,t,l,a,n);return this.draw(i)}},{key:'circle',value:async function(e,t,l,a){var n=await this.genAsync.circle(e,t,l,a);return this.draw(n)}},{key:'linearPath',value:async function(e,t){var l=await this.genAsync.linearPath(e,t);return this.draw(l)}},{key:'polygon',value:async function(e,t){var l=await this.genAsync.polygon(e,t);return this.draw(l)}},{key:'arc',value:async function(e,t,l,a,n,i){var s=!!(6u){const e=d(1-u/(this._rx*this._rx*this._ry*this._ry));this._rx*=e,this._ry*=e,r=0}else r=(s===a?-1:1)*d(u/(this._rx*this._rx*p*p+this._ry*this._ry*o*o));const y=r*this._rx*p/this._ry,_=-r*this._ry*o/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*y-this._sinPhi*_+(e[0]+t[0])/2,this._C[1]=this._sinPhi*y+this._cosPhi*_+(e[1]+t[1])/2,this._theta=this.calculateVectorAngle(1,0,(o-y)/this._rx,(p-_)/this._ry);let x=this.calculateVectorAngle((o-y)/this._rx,(p-_)/this._ry,(-o-y)/this._rx,(-p-_)/this._ry);!a&&0x&&(x+=2*c),this._numSegs=Math.ceil(g(x/(c/2))),this._delta=x/this._numSegs,this._T=8/3*f(this._delta/4)*f(this._delta/4)/f(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const e=h(this._theta),t=f(this._theta),i=this._theta+this._delta,n=h(i),s=f(i),a=[this._cosPhi*this._rx*n-this._sinPhi*this._ry*s+this._C[0],this._sinPhi*this._rx*n+this._cosPhi*this._ry*s+this._C[1]],l=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[a[0]+this._T*(this._cosPhi*this._rx*s+this._sinPhi*this._ry*n),a[1]+this._T*(this._sinPhi*this._rx*s-this._cosPhi*this._ry*n)];return this._theta=i,this._from=[a[0],a[1]],this._segIndex++,{cp1:l,cp2:o,to:a}}calculateVectorAngle(e,t,i,n){var s=Math.atan2;const a=s(t,e),l=s(n,i);return l>=a?l-a:2*c-(a-l)}}class x{constructor(e,t){this.sets=e,this.closed=t}fit(e){const t=[];for(const i of this.sets){const n=i.length;let s=r(e*n);if(5>s){if(5>=n)continue;s=5}t.push(this.reduce(i,s))}let n='';for(const s of t){for(let e=0;et;){let e=-1,t=-1;for(let l=1;le||s=p(e.py1,e.py2)&&this.py1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=p(e.py1,e.py2)&&this.py2<=l(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+s,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===o?(this.xi=e.px1,this.yi=t*this.xi+n,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(r))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):t===i?n==s&&(this.px1>=p(e.px1,e.px2)&&this.px1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=p(e.px1,e.px2)&&this.px2<=l(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(s-n)/(t-i),this.yi=t*this.xi+n,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}class m{constructor(e,t,i,n,s,a,l,o){this.deltaX=0,this.hGap=0,this.top=e,this.bottom=t,this.left=i,this.right=n,this.gap=s,this.sinAngle=a,this.tanAngle=o,1e-4>g(a)?this.pos=i+s:.9999g(this.sinAngle)){if(this.posthis.right&&t>this.right;)if(this.pos+=this.hGap,e=this.pos-this.deltaX/2,t=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const a=new w([e,i],[t,n]);this.sLeft&&a.intersects(this.sLeft)&&(e=a.xi,i=a.yi),this.sRight&&a.intersects(this.sRight)&&(t=a.xi,n=a.yi),0u&&(u=4*t.strokeWidth),u=l(u,.1);const y=i%180*(c/180),_=h(y),x=f(y),b=s(y),w=new m(d-1,g+1,o-1,r+1,u,x,_,b);for(let i,s=null;null!=(i=w.nextLine());){const l=this.getIntersectingLines(i,e);for(let e=0;e=f&&(f=4*a.strokeWidth);let u=a.fillWeight;0>u&&(u=a.strokeWidth/2);const y=s(h%180*(c/180)),_=r/p,x=d(_*y*_*y+1),b=_*y/x,w=1/x,m=f/(p*r/d(r*w*(r*w)+p*b*(p*b))/p);let O=d(p*p-(e-p+m)*(e-p+m)),P=null;for(let s=e-p+m;sx;)x+=2*c,b+=2*c;b-x>2*c&&(x=0,b=2*c);const w=2*c/d.curveStepCount,m=p(w/2,(b-x)/2),O=this._arc(m,o,u,y,_,x,b,1,d),P=this._arc(m,o,u,y,_,x,b,1.5,d);let v=O.concat(P);return l&&(r?(v=v.concat(this.doubleLine(o,u,o+y*h(x),u+_*f(x),d)),v=v.concat(this.doubleLine(o,u,o+y*h(b),u+_*f(b),d))):(v.push({op:'lineTo',data:[o,u]}),v.push({op:'lineTo',data:[o+y*h(x),u+_*f(x)]}))),{type:'path',ops:v}}svgPath(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');let n=new _(e);if(t.simplification){const e=new x(n.linearPoints,n.closed),i=e.fit(t.simplification);n=new _(i)}let a=[];const l=n.segments||[];for(let o=0;ou;)u+=2*c,y+=2*c;y-u>2*c&&(u=0,y=2*c);const _=(y-u)/l.curveStepCount,x=[];for(let g=u;g<=y;g+=_)x.push([o+r*h(g),p+d*f(g)]);return x.push([o+r*h(y),p+d*f(y)]),x.push([o,p]),this.patternFillPolygon(x,l)}getOffset(e,t,i){return i.roughness*(Math.random()*(t-e)+e)}doubleLine(e,t,i,n,s){const a=this._line(e,t,i,n,s,!0,!1),l=this._line(e,t,i,n,s,!0,!0);return a.concat(l)}_line(e,t,i,n,s,l,o){const p=a(e-i,2)+a(t-n,2);let r=s.maxRandomnessOffset||0;100*(r*r)>p&&(r=d(p)/10);const h=r/2,f=.2+.2*Math.random();let g=s.bowing*s.maxRandomnessOffset*(n-t)/200,c=s.bowing*s.maxRandomnessOffset*(e-i)/200;g=this.getOffset(-g,g,s),c=this.getOffset(-c,c,s);const u=[];return l&&(o?u.push({op:'move',data:[e+this.getOffset(-h,h,s),t+this.getOffset(-h,h,s)]}):u.push({op:'move',data:[e+this.getOffset(-r,r,s),t+this.getOffset(-r,r,s)]})),o?u.push({op:'bcurveTo',data:[g+e+(i-e)*f+this.getOffset(-h,h,s),c+t+(n-t)*f+this.getOffset(-h,h,s),g+e+2*(i-e)*f+this.getOffset(-h,h,s),c+t+2*(n-t)*f+this.getOffset(-h,h,s),i+this.getOffset(-h,h,s),n+this.getOffset(-h,h,s)]}):u.push({op:'bcurveTo',data:[g+e+(i-e)*f+this.getOffset(-r,r,s),c+t+(n-t)*f+this.getOffset(-r,r,s),g+e+2*(i-e)*f+this.getOffset(-r,r,s),c+t+2*(n-t)*f+this.getOffset(-r,r,s),i+this.getOffset(-r,r,s),n+this.getOffset(-r,r,s)]}),u}_curve(e,t,i){const n=e.length;let a=[];if(3f;f++)0===f?o.push({op:'move',data:[p.x,p.y]}):o.push({op:'move',data:[p.x+this.getOffset(-d[0],d[0],r),p.y+this.getOffset(-d[0],d[0],r)]}),h=[a+this.getOffset(-d[f],d[f],r),l+this.getOffset(-d[f],d[f],r)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[f],d[f],r),t+this.getOffset(-d[f],d[f],r),n+this.getOffset(-d[f],d[f],r),s+this.getOffset(-d[f],d[f],r),h[0],h[1]]});return p.setPosition(h[0],h[1]),o}_processSegment(e,t,i,n){let s=[];switch(t.key){case'M':case'm':{const i='m'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y);const o=1*(n.maxRandomnessOffset||0);a+=this.getOffset(-o,o,n),l+=this.getOffset(-o,o,n),e.setPosition(a,l),s.push({op:'move',data:[a,l]})}break}case'L':case'l':{const i='l'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y),s=s.concat(this.doubleLine(e.x,e.y,a,l,n)),e.setPosition(a,l)}break}case'H':case'h':{const i='h'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.x),s=s.concat(this.doubleLine(e.x,e.y,a,e.y,n)),e.setPosition(a,e.y)}break}case'V':case'v':{const i='v'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.y),s=s.concat(this.doubleLine(e.x,e.y,e.x,a,n)),e.setPosition(e.x,a)}break}case'Z':case'z':{e.first&&(s=s.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],n)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{const i='c'===t.key;if(6<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4],d=+t.data[5];i&&(a+=e.x,o+=e.x,r+=e.x,l+=e.y,p+=e.y,d+=e.y);const h=this._bezierTo(a,l,o,p,r,d,e,n);s=s.concat(h),e.bezierReflectionPoint=[r+(r-o),d+(d-p)]}break}case'S':case's':{const a='s'===t.key;if(4<=t.data.length){let l=+t.data[0],o=+t.data[1],p=+t.data[2],r=+t.data[3];a&&(l+=e.x,p+=e.x,o+=e.y,r+=e.y);let d=l,h=o;const f=i?i.key:'';let g=null;('c'===f||'C'===f||'s'===f||'S'===f)&&(g=e.bezierReflectionPoint),g&&(d=g[0],h=g[1]);const c=this._bezierTo(d,h,l,o,p,r,e,n);s=s.concat(c),e.bezierReflectionPoint=[p+(p-l),r+(r-o)]}break}case'Q':case'q':{const i='q'===t.key;if(4<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3];i&&(a+=e.x,o+=e.x,l+=e.y,p+=e.y);const r=1*(1+.2*n.roughness),d=1.5*(1+.22*n.roughness);s.push({op:'move',data:[e.x+this.getOffset(-r,r,n),e.y+this.getOffset(-r,r,n)]});let h=[o+this.getOffset(-r,r,n),p+this.getOffset(-r,r,n)];s.push({op:'qcurveTo',data:[a+this.getOffset(-r,r,n),l+this.getOffset(-r,r,n),h[0],h[1]]}),s.push({op:'move',data:[e.x+this.getOffset(-d,d,n),e.y+this.getOffset(-d,d,n)]}),h=[o+this.getOffset(-d,d,n),p+this.getOffset(-d,d,n)],s.push({op:'qcurveTo',data:[a+this.getOffset(-d,d,n),l+this.getOffset(-d,d,n),h[0],h[1]]}),e.setPosition(h[0],h[1]),e.quadReflectionPoint=[o+(o-a),p+(p-l)]}break}case'T':case't':{const a='t'===t.key;if(2<=t.data.length){let l=+t.data[0],o=+t.data[1];a&&(l+=e.x,o+=e.y);let p=l,r=o;const d=i?i.key:'';let h=null;('q'===d||'Q'===d||'t'===d||'T'===d)&&(h=e.quadReflectionPoint),h&&(p=h[0],r=h[1]);const g=1*(1+.2*n.roughness),c=1.5*(1+.22*n.roughness);s.push({op:'move',data:[e.x+this.getOffset(-g,g,n),e.y+this.getOffset(-g,g,n)]});let u=[l+this.getOffset(-g,g,n),o+this.getOffset(-g,g,n)];s.push({op:'qcurveTo',data:[p+this.getOffset(-g,g,n),r+this.getOffset(-g,g,n),u[0],u[1]]}),s.push({op:'move',data:[e.x+this.getOffset(-c,c,n),e.y+this.getOffset(-c,c,n)]}),u=[l+this.getOffset(-c,c,n),o+this.getOffset(-c,c,n)],s.push({op:'qcurveTo',data:[p+this.getOffset(-c,c,n),r+this.getOffset(-c,c,n),u[0],u[1]]}),e.setPosition(u[0],u[1]),e.quadReflectionPoint=[l+(l-p),o+(o-r)]}break}case'A':case'a':{const i='a'===t.key;if(7<=t.data.length){const a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4];let d=+t.data[5],h=+t.data[6];if(i&&(d+=e.x,h+=e.y),d===e.x&&h===e.y)break;if(0==a||0==l)s=s.concat(this.doubleLine(e.x,e.y,d,h,n)),e.setPosition(d,h);else for(let t=0;1>t;t++){const t=new b([e.x,e.y],[d,h],[a,l],o,!!p,!!r);for(let i=t.getNextSegment();i;){const a=this._bezierTo(i.cp1[0],i.cp1[1],i.cp2[0],i.cp2[1],i.to[0],i.to[1],e,n);s=s.concat(a),i=t.getNextSegment()}}}break}default:}return s}}const S='undefined'!=typeof self,T=S&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,C='undefined'!=typeof self;class z{constructor(e,t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=e||{},this.surface=t,this.renderer=i(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}_options(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_drawable(e,t,i){return{shape:e,sets:t||[],options:i||this.defaultOptions}}get lib(){return this.renderer}getCanvasSize(){const e=e=>e&&'object'==typeof e&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100;return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}computePolygonSize(e){if(e.length){let t=e[0][0],n=e[0][0],s=e[0][1],a=e[0][1];for(let o=1;oi&&(i=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:i,fill:'none'}}opsToPath(e){let t='';for(const i of e.ops){const e=i.data;switch(i.op){case'move':t+=`M${e[0]} ${e[1]} `;break;case'bcurveTo':t+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case'qcurveTo':t+=`Q${e[0]} ${e[1]}, ${e[2]} ${e[3]} `;break;case'lineTo':t+=`L${e[0]} ${e[1]} `;}}return t.trim()}}const E='undefined'!=typeof document;class W{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext('2d'),this.gen=new z(t||null,this.canvas)}get generator(){return this.gen}static createRenderer(){return new A}line(e,t,i,n,s){const a=this.gen.line(e,t,i,n,s);return this.draw(a),a}rectangle(e,t,i,n,s){const a=this.gen.rectangle(e,t,i,n,s);return this.draw(a),a}ellipse(e,t,i,n,s){const a=this.gen.ellipse(e,t,i,n,s);return this.draw(a),a}circle(e,t,i,n){const s=this.gen.circle(e,t,i,n);return this.draw(s),s}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i),i}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i),i}arc(e,t,i,n,s,a,l=!1,o){const p=this.gen.arc(e,t,i,n,s,a,l,o);return this.draw(p),p}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i),i}path(e,t){const i=this.gen.path(e,t);return this.draw(i),i}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,n=this.ctx;for(const s of t)switch(s.type){case'path':n.save(),n.strokeStyle=i.stroke,n.lineWidth=i.strokeWidth,this._drawToContext(n,s),n.restore();break;case'fillPath':n.save(),n.fillStyle=i.fill||'',this._drawToContext(n,s),n.restore();break;case'fillSketch':this.fillSketch(n,s,i);break;case'path2Dfill':{this.ctx.save(),this.ctx.fillStyle=i.fill||'';const e=new Path2D(s.path);this.ctx.fill(e),this.ctx.restore();break}case'path2Dpattern':{if(E){const e=s.size,t=document.createElement('canvas'),n=t.getContext('2d'),a=this.computeBBox(s.path);a&&(a.width||a.height)?(t.width=this.canvas.width,t.height=this.canvas.height,n.translate(a.x||0,a.y||0)):(t.width=e[0],t.height=e[1]),this.fillSketch(n,s,i),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(t,'repeat');const l=new Path2D(s.path);this.ctx.fill(l),this.ctx.restore()}break}}}computeBBox(e){if(E)try{const t=document.createElementNS('http://www.w3.org/2000/svg','svg');t.setAttribute('width','0'),t.setAttribute('height','0');const i=self.document.createElementNS('http://www.w3.org/2000/svg','path');i.setAttribute('d',e),t.appendChild(i),document.body.appendChild(t);const n=i.getBBox();return document.body.removeChild(t),n}catch(e){}return null}fillSketch(e,t,i){let n=i.fillWeight;0>n&&(n=i.strokeWidth/2),e.save(),e.strokeStyle=i.fill||'',e.lineWidth=n,this._drawToContext(e,t),e.restore()}_drawToContext(e,t){e.beginPath();for(const i of t.ops){const t=i.data;switch(i.op){case'move':e.moveTo(t[0],t[1]);break;case'bcurveTo':e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case'qcurveTo':e.quadraticCurveTo(t[0],t[1],t[2],t[3]);break;case'lineTo':e.lineTo(t[0],t[1]);}}'fillPath'===t.type?e.fill():e.stroke()}}class L extends z{async line(e,t,i,n,s){const a=this._options(s);return this._drawable('line',[await this.lib.line(e,t,i,n,a)],a)}async rectangle(e,t,i,n,s){const a=this._options(s),l=[];if(a.fill){const s=[[e,t],[e+i,t],[e+i,t+n],[e,t+n]];'solid'===a.fillStyle?l.push((await this.lib.solidFillPolygon(s,a))):l.push((await this.lib.patternFillPolygon(s,a)))}return l.push((await this.lib.rectangle(e,t,i,n,a))),this._drawable('rectangle',l,a)}async ellipse(e,t,i,n,s){const a=this._options(s),l=[];if(a.fill)if('solid'===a.fillStyle){const s=await this.lib.ellipse(e,t,i,n,a);s.type='fillPath',l.push(s)}else l.push((await this.lib.patternFillEllipse(e,t,i,n,a)));return l.push((await this.lib.ellipse(e,t,i,n,a))),this._drawable('ellipse',l,a)}async circle(e,t,i,n){const s=await this.ellipse(e,t,i,i,n);return s.shape='circle',s}async linearPath(e,t){const i=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,i)],i)}async arc(e,t,i,n,s,a,l=!1,p){const r=this._options(p),o=[];if(l&&r.fill)if('solid'===r.fillStyle){const l=await this.lib.arc(e,t,i,n,s,a,!0,!1,r);l.type='fillPath',o.push(l)}else o.push((await this.lib.patternFillArc(e,t,i,n,s,a,r)));return o.push((await this.lib.arc(e,t,i,n,s,a,l,!0,r))),this._drawable('arc',o,r)}async curve(e,t){const i=this._options(t);return this._drawable('curve',[await this.lib.curve(e,i)],i)}async polygon(e,t){const i=this._options(t),n=[];if(i.fill)if('solid'===i.fillStyle)n.push((await this.lib.solidFillPolygon(e,i)));else{const t=this.computePolygonSize(e),s=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(s,i);a.type='path2Dpattern',a.size=t,a.path=this.polygonPath(e),n.push(a)}return n.push((await this.lib.linearPath(e,!0,i))),this._drawable('polygon',n,i)}async path(e,t){const i=this._options(t),n=[];if(!e)return this._drawable('path',n,i);if(i.fill)if('solid'===i.fillStyle){n.push({type:'path2Dfill',path:e,ops:[]})}else{const t=this.computePathSize(e),s=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(s,i);a.type='path2Dpattern',a.size=t,a.path=e,n.push(a)}return n.push((await this.lib.svgPath(e,i))),this._drawable('path',n,i)}}class N extends W{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.canvas)}get generator(){return this.genAsync}async line(e,t,i,n,s){const a=await this.genAsync.line(e,t,i,n,s);return this.draw(a),a}async rectangle(e,t,i,n,s){const a=await this.genAsync.rectangle(e,t,i,n,s);return this.draw(a),a}async ellipse(e,t,i,n,s){const a=await this.genAsync.ellipse(e,t,i,n,s);return this.draw(a),a}async circle(e,t,i,n){const s=await this.genAsync.circle(e,t,i,n);return this.draw(s),s}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i),i}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i),i}async arc(e,t,i,n,s,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,n,s,a,l,o);return this.draw(p),p}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i),i}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i),i}}const R='undefined'!=typeof document;class D{constructor(e,t){this.svg=e,this.gen=new z(t||null,this.svg)}get generator(){return this.gen}static createRenderer(){return new A}get defs(){if(R&&!this._defs){const e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}line(e,t,i,n,s){const a=this.gen.line(e,t,i,n,s);return this.draw(a)}rectangle(e,t,i,n,s){const a=this.gen.rectangle(e,t,i,n,s);return this.draw(a)}ellipse(e,t,i,n,s){const a=this.gen.ellipse(e,t,i,n,s);return this.draw(a)}circle(e,t,i,n){const s=this.gen.circle(e,t,i,n);return this.draw(s)}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i)}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i)}arc(e,t,i,n,s,a,l=!1,o){const p=this.gen.arc(e,t,i,n,s,a,l,o);return this.draw(p)}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i)}path(e,t){const i=this.gen.path(e,t);return this.draw(i)}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,s=this.svg.ownerDocument||R&&document,a=s.createElementNS('http://www.w3.org/2000/svg','g');for(const l of t){let e=null;switch(l.type){case'path':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke=i.stroke,e.style.strokeWidth=i.strokeWidth+'',e.style.fill='none';break}case'fillPath':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'fillSketch':{e=this.fillSketch(s,l,i);break}case'path2Dfill':{e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'path2Dpattern':{const t=l.size,a=s.createElementNS('http://www.w3.org/2000/svg','pattern'),o=`rough-${r(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;a.setAttribute('id',o),a.setAttribute('x','0'),a.setAttribute('y','0'),a.setAttribute('width','1'),a.setAttribute('height','1'),a.setAttribute('height','1'),a.setAttribute('viewBox',`0 0 ${n(t[0])} ${n(t[1])}`),a.setAttribute('patternUnits','objectBoundingBox');const p=this.fillSketch(s,l,i);a.appendChild(p),this.defs.appendChild(a),e=s.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=`url(#${o})`;break}}e&&a.appendChild(e)}return a}opsToPath(e){return this.gen.opsToPath(e)}fillSketch(e,t,i){let n=i.fillWeight;0>n&&(n=i.strokeWidth/2);const s=e.createElementNS('http://www.w3.org/2000/svg','path');return s.setAttribute('d',this.opsToPath(t)),s.style.stroke=i.fill,s.style.strokeWidth=n+'',s.style.fill='none',s}}class B extends D{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.svg)}get generator(){return this.genAsync}async line(e,t,i,n,s){const a=await this.genAsync.line(e,t,i,n,s);return this.draw(a)}async rectangle(e,t,i,n,s){const a=await this.genAsync.rectangle(e,t,i,n,s);return this.draw(a)}async ellipse(e,t,i,n,s){const a=await this.genAsync.ellipse(e,t,i,n,s);return this.draw(a)}async circle(e,t,i,n){const s=await this.genAsync.circle(e,t,i,n);return this.draw(s)}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i)}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i)}async arc(e,t,i,n,s,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,n,s,a,l,o);return this.draw(p)}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i)}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i)}}var M={canvas(e,t){return t&&t.async?new N(e,t):new W(e,t)},svg(e,t){return t&&t.async?new B(e,t):new D(e,t)},createRenderer(){return W.createRenderer()},generator(e,t){return e&&e.async?new L(e,t):new z(e,t)}};return M}); +(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.rough=t()})(this,function(){'use strict';function e(e,t){return e.type===t}function t(e,t){let i=t.fillStyle||'hachure';if(!k[i])switch(i){case'zigzag':k[i]||(k[i]=new P(e));break;case'cross-hatch':k[i]||(k[i]=new v(e));break;case'hachure':default:i='hachure',k[i]||(k[i]=new O(e));}return k[i]}function i(e){if(S&&T&&self&&self.workly&&e.async&&!e.noWorker){const t=e.worklyURL||'https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js';if(t){const e=`importScripts('${t}', '${T}');\nworkly.expose(self.rough.createRenderer());`,i=URL.createObjectURL(new Blob([e]));return self.workly.proxy(i)}}return new A}var s=Math.round,n=Math.tan,l=Math.max,p=Math.min,o=Number.MAX_VALUE,a=Math.pow,r=Math.floor,d=Math.sqrt,f=Math.cos,h=Math.sin,g=Math.abs,c=Math.PI;const u={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:4,t:2,V:1,v:1,Z:0,z:0};class y{constructor(e){this.COMMAND=0,this.NUMBER=1,this.EOD=2,this.segments=[],this.parseData(e),this.processPoints()}tokenize(e){const t=[];for(;''!==e;)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:this.COMMAND,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:this.NUMBER,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return console.error('Unrecognized segment command: '+e),[];return t[t.length]={type:this.EOD,text:''},t}parseData(t){const s=this.tokenize(t);let n=0,i=s[n],a='BOD';for(this.segments=[];!e(i,this.EOD);){let l;const o=[];if(!('BOD'===a))e(i,this.NUMBER)?l=u[a]:(n++,l=u[i.text],a=i.text);else if('M'===i.text||'m'===i.text)n++,l=u[i.text],a=i.text;else return void this.parseData('M0,0'+t);if(n+lu){const e=d(1-u/(this._rx*this._rx*this._ry*this._ry));this._rx*=e,this._ry*=e,r=0}else r=(n===a?-1:1)*d(u/(this._rx*this._rx*p*p+this._ry*this._ry*o*o));const y=r*this._rx*p/this._ry,_=-r*this._ry*o/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*y-this._sinPhi*_+(e[0]+t[0])/2,this._C[1]=this._sinPhi*y+this._cosPhi*_+(e[1]+t[1])/2,this._theta=this.calculateVectorAngle(1,0,(o-y)/this._rx,(p-_)/this._ry);let x=this.calculateVectorAngle((o-y)/this._rx,(p-_)/this._ry,(-o-y)/this._rx,(-p-_)/this._ry);!a&&0x&&(x+=2*c),this._numSegs=Math.ceil(g(x/(c/2))),this._delta=x/this._numSegs,this._T=8/3*h(this._delta/4)*h(this._delta/4)/h(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const e=f(this._theta),t=h(this._theta),i=this._theta+this._delta,s=f(i),n=h(i),a=[this._cosPhi*this._rx*s-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*s+this._cosPhi*this._ry*n+this._C[1]],l=[this._from[0]+this._T*(-this._cosPhi*this._rx*t-this._sinPhi*this._ry*e),this._from[1]+this._T*(-this._sinPhi*this._rx*t+this._cosPhi*this._ry*e)],o=[a[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*s),a[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*s)];return this._theta=i,this._from=[a[0],a[1]],this._segIndex++,{cp1:l,cp2:o,to:a}}calculateVectorAngle(e,t,i,s){var n=Math.atan2;const a=n(t,e),l=n(s,i);return l>=a?l-a:2*c-(a-l)}}class x{constructor(e,t){this.sets=e,this.closed=t}fit(e){const t=[];for(const i of this.sets){const s=i.length;let n=r(e*s);if(5>n){if(5>=s)continue;n=5}t.push(this.reduce(i,n))}let s='';for(const n of t){for(let e=0;et;){let e=-1,t=-1;for(let l=1;le||s=p(e.py1,e.py2)&&this.py1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.py2>=p(e.py1,e.py2)&&this.py2<=l(e.py1,e.py2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=i*this.xi+n,!(-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(e.py1-this.yi)*(this.yi-e.py2))&&(!(1e-5>g(e.a))||!(-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))):i===o?(this.xi=e.px1,this.yi=t*this.xi+s,!(-1e-5>(e.py1-this.yi)*(this.yi-e.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2))&&(!(1e-5>g(r))||!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)))):t===i?s==n&&(this.px1>=p(e.px1,e.px2)&&this.px1<=l(e.py1,e.py2)?(this.xi=this.px1,this.yi=this.py1,!0):!!(this.px2>=p(e.px1,e.px2)&&this.px2<=l(e.px1,e.px2))&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(n-s)/(t-i),this.yi=t*this.xi+s,!(-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(e.px1-this.xi)*(this.xi-e.px2)))}}class m{constructor(e,t,i,s,n,a,l,o){this.deltaX=0,this.hGap=0,this.top=e,this.bottom=t,this.left=i,this.right=s,this.gap=n,this.sinAngle=a,this.tanAngle=o,1e-4>g(a)?this.pos=i+n:.9999g(this.sinAngle)){if(this.posthis.right&&t>this.right;)if(this.pos+=this.hGap,e=this.pos-this.deltaX/2,t=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const a=new w([e,i],[t,n]);this.sLeft&&a.intersects(this.sLeft)&&(e=a.xi,i=a.yi),this.sRight&&a.intersects(this.sRight)&&(t=a.xi,n=a.yi),0u&&(u=4*t.strokeWidth),u=l(u,.1);const y=i%180*(c/180),_=f(y),x=h(y),b=n(y),w=new m(d-1,g+1,o-1,r+1,u,x,_,b);for(let i,n=null;null!=(i=w.nextLine());){const l=this.getIntersectingLines(i,e);for(let e=0;e=h&&(h=4*a.strokeWidth);let u=a.fillWeight;0>u&&(u=a.strokeWidth/2);const y=n(f%180*(c/180)),_=r/p,x=d(_*y*_*y+1),b=_*y/x,w=1/x,m=h/(p*r/d(r*w*(r*w)+p*b*(p*b))/p);let O=d(p*p-(e-p+m)*(e-p+m)),P=null;for(let n=e-p+m;nx;)x+=2*c,b+=2*c;b-x>2*c&&(x=0,b=2*c);const w=2*c/d.curveStepCount,m=p(w/2,(b-x)/2),O=this._arc(m,o,u,y,_,x,b,1,d),P=this._arc(m,o,u,y,_,x,b,1.5,d);let v=O.concat(P);return l&&(r?(v=v.concat(this.doubleLine(o,u,o+y*f(x),u+_*h(x),d)),v=v.concat(this.doubleLine(o,u,o+y*f(b),u+_*h(b),d))):(v.push({op:'lineTo',data:[o,u]}),v.push({op:'lineTo',data:[o+y*f(x),u+_*h(x)]}))),{type:'path',ops:v}}svgPath(e,t){e=(e||'').replace(/\n/g,' ').replace(/(-\s)/g,'-').replace('/(ss)/g',' ');let n=new _(e);if(t.simplification){const e=new x(n.linearPoints,n.closed),i=e.fit(t.simplification);n=new _(i)}let a=[];const l=n.segments||[];for(let o=0;ou;)u+=2*c,y+=2*c;y-u>2*c&&(u=0,y=2*c);const _=(y-u)/l.curveStepCount,x=[];for(let g=u;g<=y;g+=_)x.push([o+r*f(g),p+d*h(g)]);return x.push([o+r*f(y),p+d*h(y)]),x.push([o,p]),this.patternFillPolygon(x,l)}getOffset(e,t,i){return i.roughness*(Math.random()*(t-e)+e)}doubleLine(e,t,i,s,n){const a=this._line(e,t,i,s,n,!0,!1),l=this._line(e,t,i,s,n,!0,!0);return a.concat(l)}_line(e,t,i,s,n,l,o){const p=a(e-i,2)+a(t-s,2);let r=n.maxRandomnessOffset||0;100*(r*r)>p&&(r=d(p)/10);const f=r/2,h=.2+.2*Math.random();let g=n.bowing*n.maxRandomnessOffset*(s-t)/200,c=n.bowing*n.maxRandomnessOffset*(e-i)/200;g=this.getOffset(-g,g,n),c=this.getOffset(-c,c,n);const u=[];return l&&(o?u.push({op:'move',data:[e+this.getOffset(-f,f,n),t+this.getOffset(-f,f,n)]}):u.push({op:'move',data:[e+this.getOffset(-r,r,n),t+this.getOffset(-r,r,n)]})),o?u.push({op:'bcurveTo',data:[g+e+(i-e)*h+this.getOffset(-f,f,n),c+t+(s-t)*h+this.getOffset(-f,f,n),g+e+2*(i-e)*h+this.getOffset(-f,f,n),c+t+2*(s-t)*h+this.getOffset(-f,f,n),i+this.getOffset(-f,f,n),s+this.getOffset(-f,f,n)]}):u.push({op:'bcurveTo',data:[g+e+(i-e)*h+this.getOffset(-r,r,n),c+t+(s-t)*h+this.getOffset(-r,r,n),g+e+2*(i-e)*h+this.getOffset(-r,r,n),c+t+2*(s-t)*h+this.getOffset(-r,r,n),i+this.getOffset(-r,r,n),s+this.getOffset(-r,r,n)]}),u}_curve(e,t,i){const n=e.length;let a=[];if(3f;f++)0===f?o.push({op:'move',data:[p.x,p.y]}):o.push({op:'move',data:[p.x+this.getOffset(-d[0],d[0],r),p.y+this.getOffset(-d[0],d[0],r)]}),h=[a+this.getOffset(-d[f],d[f],r),l+this.getOffset(-d[f],d[f],r)],o.push({op:'bcurveTo',data:[e+this.getOffset(-d[f],d[f],r),t+this.getOffset(-d[f],d[f],r),s+this.getOffset(-d[f],d[f],r),n+this.getOffset(-d[f],d[f],r),h[0],h[1]]});return p.setPosition(h[0],h[1]),o}_processSegment(e,t,i,s){let n=[];switch(t.key){case'M':case'm':{const i='m'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y);const o=1*(s.maxRandomnessOffset||0);a+=this.getOffset(-o,o,s),l+=this.getOffset(-o,o,s),e.setPosition(a,l),n.push({op:'move',data:[a,l]})}break}case'L':case'l':{const i='l'===t.key;if(2<=t.data.length){let a=+t.data[0],l=+t.data[1];i&&(a+=e.x,l+=e.y),n=n.concat(this.doubleLine(e.x,e.y,a,l,s)),e.setPosition(a,l)}break}case'H':case'h':{const i='h'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.x),n=n.concat(this.doubleLine(e.x,e.y,a,e.y,s)),e.setPosition(a,e.y)}break}case'V':case'v':{const i='v'===t.key;if(t.data.length){let a=+t.data[0];i&&(a+=e.y),n=n.concat(this.doubleLine(e.x,e.y,e.x,a,s)),e.setPosition(e.x,a)}break}case'Z':case'z':{e.first&&(n=n.concat(this.doubleLine(e.x,e.y,e.first[0],e.first[1],s)),e.setPosition(e.first[0],e.first[1]),e.first=null);break}case'C':case'c':{const i='c'===t.key;if(6<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4],d=+t.data[5];i&&(a+=e.x,o+=e.x,r+=e.x,l+=e.y,p+=e.y,d+=e.y);const f=this._bezierTo(a,l,o,p,r,d,e,s);n=n.concat(f),e.bezierReflectionPoint=[r+(r-o),d+(d-p)]}break}case'S':case's':{const a='s'===t.key;if(4<=t.data.length){let l=+t.data[0],o=+t.data[1],p=+t.data[2],r=+t.data[3];a&&(l+=e.x,p+=e.x,o+=e.y,r+=e.y);let d=l,f=o;const h=i?i.key:'';let g=null;('c'===h||'C'===h||'s'===h||'S'===h)&&(g=e.bezierReflectionPoint),g&&(d=g[0],f=g[1]);const c=this._bezierTo(d,f,l,o,p,r,e,s);n=n.concat(c),e.bezierReflectionPoint=[p+(p-l),r+(r-o)]}break}case'Q':case'q':{const i='q'===t.key;if(4<=t.data.length){let a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3];i&&(a+=e.x,o+=e.x,l+=e.y,p+=e.y);const r=1*(1+.2*s.roughness),d=1.5*(1+.22*s.roughness);n.push({op:'move',data:[e.x+this.getOffset(-r,r,s),e.y+this.getOffset(-r,r,s)]});let h=[o+this.getOffset(-r,r,s),p+this.getOffset(-r,r,s)];n.push({op:'qcurveTo',data:[a+this.getOffset(-r,r,s),l+this.getOffset(-r,r,s),h[0],h[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-d,d,s),e.y+this.getOffset(-d,d,s)]}),h=[o+this.getOffset(-d,d,s),p+this.getOffset(-d,d,s)],n.push({op:'qcurveTo',data:[a+this.getOffset(-d,d,s),l+this.getOffset(-d,d,s),h[0],h[1]]}),e.setPosition(h[0],h[1]),e.quadReflectionPoint=[o+(o-a),p+(p-l)]}break}case'T':case't':{const a='t'===t.key;if(2<=t.data.length){let l=+t.data[0],o=+t.data[1];a&&(l+=e.x,o+=e.y);let p=l,r=o;const d=i?i.key:'';let h=null;('q'===d||'Q'===d||'t'===d||'T'===d)&&(h=e.quadReflectionPoint),h&&(p=h[0],r=h[1]);const g=1*(1+.2*s.roughness),c=1.5*(1+.22*s.roughness);n.push({op:'move',data:[e.x+this.getOffset(-g,g,s),e.y+this.getOffset(-g,g,s)]});let u=[l+this.getOffset(-g,g,s),o+this.getOffset(-g,g,s)];n.push({op:'qcurveTo',data:[p+this.getOffset(-g,g,s),r+this.getOffset(-g,g,s),u[0],u[1]]}),n.push({op:'move',data:[e.x+this.getOffset(-c,c,s),e.y+this.getOffset(-c,c,s)]}),u=[l+this.getOffset(-c,c,s),o+this.getOffset(-c,c,s)],n.push({op:'qcurveTo',data:[p+this.getOffset(-c,c,s),r+this.getOffset(-c,c,s),u[0],u[1]]}),e.setPosition(u[0],u[1]),e.quadReflectionPoint=[l+(l-p),o+(o-r)]}break}case'A':case'a':{const i='a'===t.key;if(7<=t.data.length){const a=+t.data[0],l=+t.data[1],o=+t.data[2],p=+t.data[3],r=+t.data[4];let d=+t.data[5],f=+t.data[6];if(i&&(d+=e.x,f+=e.y),d===e.x&&f===e.y)break;if(0==a||0==l)n=n.concat(this.doubleLine(e.x,e.y,d,f,s)),e.setPosition(d,f);else for(let t=0;1>t;t++){const t=new b([e.x,e.y],[d,f],[a,l],o,!!p,!!r);for(let i=t.getNextSegment();i;){const a=this._bezierTo(i.cp1[0],i.cp1[1],i.cp2[0],i.cp2[1],i.to[0],i.to[1],e,s);n=n.concat(a),i=t.getNextSegment()}}}break}default:}return n}}const S='undefined'!=typeof self,T=S&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src,C='undefined'!=typeof self;class z{constructor(e,t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:'#000',strokeWidth:1,curveTightness:0,curveStepCount:9,fill:null,fillStyle:'hachure',fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=e||{},this.surface=t,this.renderer=i(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}_options(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_drawable(e,t,i){return{shape:e,sets:t||[],options:i||this.defaultOptions}}get lib(){return this.renderer}getCanvasSize(){const e=e=>e&&'object'==typeof e&&e.baseVal&&e.baseVal.value?e.baseVal.value:e||100;return this.surface?[e(this.surface.width),e(this.surface.height)]:[100,100]}computePolygonSize(e){if(e.length){let t=e[0][0],s=e[0][0],n=e[0][1],a=e[0][1];for(let o=1;oi&&(i=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||'none',strokeWidth:i,fill:'none'}}opsToPath(e){let t='';for(const i of e.ops){const e=i.data;switch(i.op){case'move':t+=`M${e[0]} ${e[1]} `;break;case'bcurveTo':t+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case'qcurveTo':t+=`Q${e[0]} ${e[1]}, ${e[2]} ${e[3]} `;break;case'lineTo':t+=`L${e[0]} ${e[1]} `;}}return t.trim()}}const E='undefined'!=typeof document;class W{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext('2d'),this.gen=new z(t||null,this.canvas)}get generator(){return this.gen}static createRenderer(){return new A}line(e,t,i,s,n){const a=this.gen.line(e,t,i,s,n);return this.draw(a),a}rectangle(e,t,i,s,n){const a=this.gen.rectangle(e,t,i,s,n);return this.draw(a),a}ellipse(e,t,i,s,n){const a=this.gen.ellipse(e,t,i,s,n);return this.draw(a),a}circle(e,t,i,s){const n=this.gen.circle(e,t,i,s);return this.draw(n),n}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i),i}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i),i}arc(e,t,i,s,n,a,l=!1,o){const p=this.gen.arc(e,t,i,s,n,a,l,o);return this.draw(p),p}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i),i}path(e,t){const i=this.gen.path(e,t);return this.draw(i),i}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,s=this.ctx;for(const n of t)switch(n.type){case'path':s.save(),s.strokeStyle=i.stroke,s.lineWidth=i.strokeWidth,this._drawToContext(s,n),s.restore();break;case'fillPath':s.save(),s.fillStyle=i.fill||'',this._drawToContext(s,n),s.restore();break;case'fillSketch':this.fillSketch(s,n,i);break;case'path2Dfill':{this.ctx.save(),this.ctx.fillStyle=i.fill||'';const e=new Path2D(n.path);this.ctx.fill(e),this.ctx.restore();break}case'path2Dpattern':{if(E){const e=n.size,t=document.createElement('canvas'),s=t.getContext('2d'),a=this.computeBBox(n.path);a&&(a.width||a.height)?(t.width=this.canvas.width,t.height=this.canvas.height,s.translate(a.x||0,a.y||0)):(t.width=e[0],t.height=e[1]),this.fillSketch(s,n,i),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(t,'repeat');const l=new Path2D(n.path);this.ctx.fill(l),this.ctx.restore()}break}}}computeBBox(e){if(E)try{const t=document.createElementNS('http://www.w3.org/2000/svg','svg');t.setAttribute('width','0'),t.setAttribute('height','0');const i=self.document.createElementNS('http://www.w3.org/2000/svg','path');i.setAttribute('d',e),t.appendChild(i),document.body.appendChild(t);const s=i.getBBox();return document.body.removeChild(t),s}catch(e){}return null}fillSketch(e,t,i){let s=i.fillWeight;0>s&&(s=i.strokeWidth/2),e.save(),e.strokeStyle=i.fill||'',e.lineWidth=s,this._drawToContext(e,t),e.restore()}_drawToContext(e,t){e.beginPath();for(const i of t.ops){const t=i.data;switch(i.op){case'move':e.moveTo(t[0],t[1]);break;case'bcurveTo':e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case'qcurveTo':e.quadraticCurveTo(t[0],t[1],t[2],t[3]);break;case'lineTo':e.lineTo(t[0],t[1]);}}'fillPath'===t.type?e.fill():e.stroke()}}class L extends z{async line(e,t,i,s,n){const a=this._options(n);return this._drawable('line',[await this.lib.line(e,t,i,s,a)],a)}async rectangle(e,t,i,s,n){const a=this._options(n),l=[];if(a.fill){const n=[[e,t],[e+i,t],[e+i,t+s],[e,t+s]];'solid'===a.fillStyle?l.push((await this.lib.solidFillPolygon(n,a))):l.push((await this.lib.patternFillPolygon(n,a)))}return l.push((await this.lib.rectangle(e,t,i,s,a))),this._drawable('rectangle',l,a)}async ellipse(e,t,i,s,n){const a=this._options(n),l=[];if(a.fill)if('solid'===a.fillStyle){const n=await this.lib.ellipse(e,t,i,s,a);n.type='fillPath',l.push(n)}else l.push((await this.lib.patternFillEllipse(e,t,i,s,a)));return l.push((await this.lib.ellipse(e,t,i,s,a))),this._drawable('ellipse',l,a)}async circle(e,t,i,s){const n=await this.ellipse(e,t,i,i,s);return n.shape='circle',n}async linearPath(e,t){const i=this._options(t);return this._drawable('linearPath',[await this.lib.linearPath(e,!1,i)],i)}async arc(e,t,i,s,n,a,l=!1,p){const r=this._options(p),o=[];if(l&&r.fill)if('solid'===r.fillStyle){const l=await this.lib.arc(e,t,i,s,n,a,!0,!1,r);l.type='fillPath',o.push(l)}else o.push((await this.lib.patternFillArc(e,t,i,s,n,a,r)));return o.push((await this.lib.arc(e,t,i,s,n,a,l,!0,r))),this._drawable('arc',o,r)}async curve(e,t){const i=this._options(t);return this._drawable('curve',[await this.lib.curve(e,i)],i)}async polygon(e,t){const i=this._options(t),s=[];if(i.fill)if('solid'===i.fillStyle)s.push((await this.lib.solidFillPolygon(e,i)));else{const t=this.computePolygonSize(e),n=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(n,i);a.type='path2Dpattern',a.size=t,a.path=this.polygonPath(e),s.push(a)}return s.push((await this.lib.linearPath(e,!0,i))),this._drawable('polygon',s,i)}async path(e,t){const i=this._options(t),s=[];if(!e)return this._drawable('path',s,i);if(i.fill)if('solid'===i.fillStyle){s.push({type:'path2Dfill',path:e,ops:[]})}else{const t=this.computePathSize(e),n=[[0,0],[t[0],0],[t[0],t[1]],[0,t[1]]],a=await this.lib.patternFillPolygon(n,i);a.type='path2Dpattern',a.size=t,a.path=e,s.push(a)}return s.push((await this.lib.svgPath(e,i))),this._drawable('path',s,i)}}class N extends W{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.canvas)}get generator(){return this.genAsync}async line(e,t,i,s,n){const a=await this.genAsync.line(e,t,i,s,n);return this.draw(a),a}async rectangle(e,t,i,s,n){const a=await this.genAsync.rectangle(e,t,i,s,n);return this.draw(a),a}async ellipse(e,t,i,s,n){const a=await this.genAsync.ellipse(e,t,i,s,n);return this.draw(a),a}async circle(e,t,i,s){const n=await this.genAsync.circle(e,t,i,s);return this.draw(n),n}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i),i}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i),i}async arc(e,t,i,s,n,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,s,n,a,l,o);return this.draw(p),p}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i),i}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i),i}}const R='undefined'!=typeof document;class D{constructor(e,t){this.svg=e,this.gen=new z(t||null,this.svg)}get generator(){return this.gen}static createRenderer(){return new A}get defs(){if(R&&!this._defs){const e=this.svg.ownerDocument||document,t=e.createElementNS('http://www.w3.org/2000/svg','defs');this.svg.firstChild?this.svg.insertBefore(t,this.svg.firstChild):this.svg.appendChild(t),this._defs=t}return this._defs||null}line(e,t,i,s,n){const a=this.gen.line(e,t,i,s,n);return this.draw(a)}rectangle(e,t,i,s,n){const a=this.gen.rectangle(e,t,i,s,n);return this.draw(a)}ellipse(e,t,i,s,n){const a=this.gen.ellipse(e,t,i,s,n);return this.draw(a)}circle(e,t,i,s){const n=this.gen.circle(e,t,i,s);return this.draw(n)}linearPath(e,t){const i=this.gen.linearPath(e,t);return this.draw(i)}polygon(e,t){const i=this.gen.polygon(e,t);return this.draw(i)}arc(e,t,i,s,n,a,l=!1,o){const p=this.gen.arc(e,t,i,s,n,a,l,o);return this.draw(p)}curve(e,t){const i=this.gen.curve(e,t);return this.draw(i)}path(e,t){const i=this.gen.path(e,t);return this.draw(i)}draw(e){const t=e.sets||[],i=e.options||this.gen.defaultOptions,n=this.svg.ownerDocument||R&&document,a=n.createElementNS('http://www.w3.org/2000/svg','g');for(const l of t){let e=null;switch(l.type){case'path':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke=i.stroke,e.style.strokeWidth=i.strokeWidth+'',e.style.fill='none';break}case'fillPath':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',this.opsToPath(l)),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'fillSketch':{e=this.fillSketch(n,l,i);break}case'path2Dfill':{e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=i.fill;break}case'path2Dpattern':{const t=l.size,a=n.createElementNS('http://www.w3.org/2000/svg','pattern'),o=`rough-${r(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;a.setAttribute('id',o),a.setAttribute('x','0'),a.setAttribute('y','0'),a.setAttribute('width','1'),a.setAttribute('height','1'),a.setAttribute('height','1'),a.setAttribute('viewBox',`0 0 ${s(t[0])} ${s(t[1])}`),a.setAttribute('patternUnits','objectBoundingBox');const p=this.fillSketch(n,l,i);a.appendChild(p),this.defs.appendChild(a),e=n.createElementNS('http://www.w3.org/2000/svg','path'),e.setAttribute('d',l.path||''),e.style.stroke='none',e.style.strokeWidth='0',e.style.fill=`url(#${o})`;break}}e&&a.appendChild(e)}return a}opsToPath(e){return this.gen.opsToPath(e)}fillSketch(e,t,i){let s=i.fillWeight;0>s&&(s=i.strokeWidth/2);const n=e.createElementNS('http://www.w3.org/2000/svg','path');return n.setAttribute('d',this.opsToPath(t)),n.style.stroke=i.fill,n.style.strokeWidth=s+'',n.style.fill='none',n}}class B extends D{constructor(e,t){super(e,t),this.genAsync=new L(t||null,this.svg)}get generator(){return this.genAsync}async line(e,t,i,s,n){const a=await this.genAsync.line(e,t,i,s,n);return this.draw(a)}async rectangle(e,t,i,s,n){const a=await this.genAsync.rectangle(e,t,i,s,n);return this.draw(a)}async ellipse(e,t,i,s,n){const a=await this.genAsync.ellipse(e,t,i,s,n);return this.draw(a)}async circle(e,t,i,s){const n=await this.genAsync.circle(e,t,i,s);return this.draw(n)}async linearPath(e,t){const i=await this.genAsync.linearPath(e,t);return this.draw(i)}async polygon(e,t){const i=await this.genAsync.polygon(e,t);return this.draw(i)}async arc(e,t,i,s,n,a,l=!1,o){const p=await this.genAsync.arc(e,t,i,s,n,a,l,o);return this.draw(p)}async curve(e,t){const i=await this.genAsync.curve(e,t);return this.draw(i)}async path(e,t){const i=await this.genAsync.path(e,t);return this.draw(i)}}var M={canvas(e,t){return t&&t.async?new N(e,t):new W(e,t)},svg(e,t){return t&&t.async?new B(e,t):new D(e,t)},createRenderer(){return W.createRenderer()},generator(e,t){return e&&e.async?new L(e,t):new z(e,t)}};return M}); diff --git a/src/path.ts b/src/path.ts index 5800d73..818b43e 100644 --- a/src/path.ts +++ b/src/path.ts @@ -15,27 +15,27 @@ export interface Segment { point?: Point; } -const PARAMS: { [key: string]: { length: number } } = { - A: { length: 7 }, - a: { length: 7 }, - C: { length: 6 }, - c: { length: 6 }, - H: { length: 1 }, - h: { length: 1 }, - L: { length: 2 }, - l: { length: 2 }, - M: { length: 2 }, - m: { length: 2 }, - Q: { length: 4 }, - q: { length: 4 }, - S: { length: 4 }, - s: { length: 4 }, - T: { length: 4 }, - t: { length: 2 }, - V: { length: 1 }, - v: { length: 1 }, - Z: { length: 0 }, - z: { length: 0 } +const PARAMS: { [key: string]: number } = { + A: 7, + a: 7, + C: 6, + c: 6, + H: 1, + h: 1, + L: 2, + l: 2, + M: 2, + m: 2, + Q: 4, + q: 4, + S: 4, + s: 4, + T: 4, + t: 2, + V: 1, + v: 1, + Z: 0, + z: 0 }; class ParsedPath { @@ -82,7 +82,7 @@ class ParsedPath { if (mode === 'BOD') { if (token.text === 'M' || token.text === 'm') { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } else { this.parseData('M0,0' + d); @@ -90,10 +90,10 @@ class ParsedPath { } } else { if (isType(token, this.NUMBER)) { - param_length = PARAMS[mode].length; + param_length = PARAMS[mode]; } else { index++; - param_length = PARAMS[token.text].length; + param_length = PARAMS[token.text]; mode = token.text; } } @@ -108,7 +108,7 @@ class ParsedPath { return; } } - if (PARAMS[mode]) { + if (typeof PARAMS[mode] === 'number') { const segment: Segment = { key: mode, data: params }; this.segments.push(segment); index += param_length;