@digital-blueprint/esign-app
Version:
[GitHub Repository](https://github.com/digital-blueprint/esign-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/esign-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/esign-app/) | [Esign Bundle](https://gitlab.tugraz.
23 lines • 6.72 kB
JavaScript
/*!
* License: LGPL-2.1-or-later
* Dependencies:
*
* @webcomponents/scoped-custom-element-registry: BSD-3-Clause
* @dbp-toolkit/app-shell: LGPL-2.1-or-later
* @dbp-toolkit/language-select: LGPL-2.1-or-later
* @dbp-toolkit/auth: LGPL-2.1-or-later
* @dbp-toolkit/notification: LGPL-2.1-or-later
* @dbp-toolkit/theme-switcher: LGPL-2.1-or-later
* universal-router: MIT
* @dbp-toolkit/matomo: LGPL-2.1-or-later
* @tugraz/web-components: LGPL-2.1-or-later
* exceljs: MIT
* fabric: MIT
* jspdf-autotable: MIT
* keycloak-js: Apache-2.0
* jszip: (MIT OR GPL-3.0-or-later)
* pdfjs-dist: Apache-2.0
* path2d: MIT
*/
var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/gi,n=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function r(e){let t=e.match(n);return t?t.map(Number):[]}function i(n){let i=[],a=String(n).trim();return a[0]!==`M`&&a[0]!==`m`||a.replace(t,(t,n,a)=>{let o=r(a),s=n.toLowerCase(),c=n;if(s===`m`&&o.length>2&&(i.push([c,...o.splice(0,2)]),s=`l`,c=c===`m`?`l`:`L`),o.length<e[s])return``;for(i.push([c,...o.splice(0,e[s])]);o.length>=e[s]&&o.length&&e[s];)i.push([c,...o.splice(0,e[s])]);return``}),i}function a(e,t){let n=e.x*Math.cos(t)-e.y*Math.sin(t),r=e.y*Math.cos(t)+e.x*Math.sin(t);e.x=n,e.y=r}function o(e,t,n){e.x+=t,e.y+=n}function s(e,t){e.x*=t,e.y*=t}var c=class e{constructor(t){this.commands=[],t&&t instanceof e?this.commands.push(...t.commands):t&&(this.commands=i(t))}addPath(t){t&&t instanceof e&&this.commands.push(...t.commands)}moveTo(e,t){this.commands.push([`M`,e,t])}lineTo(e,t){this.commands.push([`L`,e,t])}arc(e,t,n,r,i,a){this.commands.push([`AC`,e,t,n,r,i,!!a])}arcTo(e,t,n,r,i){this.commands.push([`AT`,e,t,n,r,i])}ellipse(e,t,n,r,i,a,o,s){this.commands.push([`E`,e,t,n,r,i,a,o,!!s])}closePath(){this.commands.push([`Z`])}bezierCurveTo(e,t,n,r,i,a){this.commands.push([`C`,e,t,n,r,i,a])}quadraticCurveTo(e,t,n,r){this.commands.push([`Q`,e,t,n,r])}rect(e,t,n,r){this.commands.push([`R`,e,t,n,r])}roundRect(e,t,n,r,i){i===void 0?this.commands.push([`RR`,e,t,n,r,0]):this.commands.push([`RR`,e,t,n,r,i])}};function l(e,t){let n=0,r=0,i,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=null,k=null,A=null,j=null,M=null,N=null;e.beginPath();for(let P=0;P<t.length;++P){w=t[P][0],w!==`S`&&w!==`s`&&w!==`C`&&w!==`c`&&(O=null,k=null),w!==`T`&&w!==`t`&&w!==`Q`&&w!==`q`&&(A=null,j=null);let F;switch(w){case`m`:case`M`:F=t[P],w===`m`?(n+=F[1],r+=F[2]):(n=F[1],r=F[2]),(w===`M`||!M)&&(M={x:n,y:r}),e.moveTo(n,r);break;case`l`:F=t[P],n+=F[1],r+=F[2],e.lineTo(n,r);break;case`L`:F=t[P],n=F[1],r=F[2],e.lineTo(n,r);break;case`H`:F=t[P],n=F[1],e.lineTo(n,r);break;case`h`:F=t[P],n+=F[1],e.lineTo(n,r);break;case`V`:F=t[P],r=F[1],e.lineTo(n,r);break;case`v`:F=t[P],r+=F[1],e.lineTo(n,r);break;case`a`:case`A`:if(F=t[P],N===null)throw Error(`This should never happen`);w===`a`?(n+=F[6],r+=F[7]):(n=F[6],r=F[7]),b=F[1],x=F[2],p=F[3]*Math.PI/180,l=!!F[4],u=!!F[5],d={x:n,y:r},f={x:(N.x-d.x)/2,y:(N.y-d.y)/2},a(f,-p),m=f.x*f.x/(b*b)+f.y*f.y/(x*x),m>1&&(m=Math.sqrt(m),b*=m,x*=m),T={x:b*f.y/x,y:-(x*f.x)/b},h=b*b*x*x,g=b*b*f.y*f.y+x*x*f.x*f.x,u===l?s(T,-Math.sqrt((h-g)/g)||0):s(T,Math.sqrt((h-g)/g)||0),c=Math.atan2((f.y-T.y)/x,(f.x-T.x)/b),i=Math.atan2(-(f.y+T.y)/x,-(f.x+T.x)/b),a(T,p),o(T,(d.x+N.x)/2,(d.y+N.y)/2),e.save(),e.translate(T.x,T.y),e.rotate(p),e.scale(b,x),e.arc(0,0,1,c,i,!u),e.restore();break;case`C`:F=t[P],O=F[3],k=F[4],n=F[5],r=F[6],e.bezierCurveTo(F[1],F[2],O,k,n,r);break;case`c`:F=t[P],e.bezierCurveTo(F[1]+n,F[2]+r,F[3]+n,F[4]+r,F[5]+n,F[6]+r),O=F[3]+n,k=F[4]+r,n+=F[5],r+=F[6];break;case`S`:F=t[P],(O===null||k===null)&&(O=n,k=r),e.bezierCurveTo(2*n-O,2*r-k,F[1],F[2],F[3],F[4]),O=F[1],k=F[2],n=F[3],r=F[4];break;case`s`:F=t[P],(O===null||k===null)&&(O=n,k=r),e.bezierCurveTo(2*n-O,2*r-k,F[1]+n,F[2]+r,F[3]+n,F[4]+r),O=F[1]+n,k=F[2]+r,n+=F[3],r+=F[4];break;case`Q`:F=t[P],A=F[1],j=F[2],n=F[3],r=F[4],e.quadraticCurveTo(A,j,n,r);break;case`q`:F=t[P],A=F[1]+n,j=F[2]+r,n+=F[3],r+=F[4],e.quadraticCurveTo(A,j,n,r);break;case`T`:F=t[P],(A===null||j===null)&&(A=n,j=r),A=2*n-A,j=2*r-j,n=F[1],r=F[2],e.quadraticCurveTo(A,j,n,r);break;case`t`:F=t[P],(A===null||j===null)&&(A=n,j=r),A=2*n-A,j=2*r-j,n+=F[1],r+=F[2],e.quadraticCurveTo(A,j,n,r);break;case`z`:case`Z`:M&&(n=M.x,r=M.y),M=null,e.closePath();break;case`AC`:F=t[P],n=F[1],r=F[2],y=F[3],c=F[4],i=F[5],E=F[6],e.arc(n,r,y,c,i,E);break;case`AT`:F=t[P],_=F[1],v=F[2],n=F[3],r=F[4],y=F[5],e.arcTo(_,v,n,r,y);break;case`E`:F=t[P],n=F[1],r=F[2],b=F[3],x=F[4],p=F[5],c=F[6],i=F[7],E=F[8],e.save(),e.translate(n,r),e.rotate(p),e.scale(b,x),e.arc(0,0,1,c,i,E),e.restore();break;case`R`:F=t[P],n=F[1],r=F[2],S=F[3],C=F[4],M={x:n,y:r},e.rect(n,r,S,C);break;case`RR`:F=t[P],n=F[1],r=F[2],S=F[3],C=F[4],D=F[5],M={x:n,y:r},e.roundRect(n,r,S,C,D);break;default:throw Error(`Invalid path command: ${w}`)}N?(N.x=n,N.y=r):N={x:n,y:r}}}function u(e,t,n,r,i=0){if(typeof i==`number`&&(i=[i]),Array.isArray(i)){if(i.length===0||i.length>4)throw RangeError(`Failed to execute 'roundRect' on '${this.constructor.name}': ${i.length} radii provided. Between one and four radii are necessary.`);i.forEach(e=>{if(e<0)throw RangeError(`Failed to execute 'roundRect' on '${this.constructor.name}': Radius value ${e} is negative.`)})}else return;if(i.length===1&&i[0]===0){this.rect(e,t,n,r);return}let a=Math.min(n,r)/2,o=Math.min(a,i[0]),s=o,c=o,l=o;i.length===2&&(s=Math.min(a,i[1]),l=s),i.length===3&&(s=Math.min(a,i[1]),l=s,c=Math.min(a,i[2])),i.length===4&&(s=Math.min(a,i[1]),c=Math.min(a,i[2]),l=Math.min(a,i[3])),this.moveTo(e,t+r-l),this.arcTo(e,t,e+o,t,o),this.arcTo(e+n,t,e+n,t+s,s),this.arcTo(e+n,t+r,e+n-c,t+r,c),this.arcTo(e,t+r,e,t+r-l,l),this.closePath()}function d(e){if(!e)return;let t=e.prototype.clip,n=e.prototype.fill,r=e.prototype.stroke,i=e.prototype.isPointInPath;e.prototype.clip=function(...e){if(e[0]instanceof c){let n=e[0],r=e[1]||`nonzero`;return l(this,n.commands),t.apply(this,[r])}let n=e[0]||`nonzero`;return t.apply(this,[n])},e.prototype.fill=function(...e){if(e[0]instanceof c){let t=e[0],r=e[1]||`nonzero`;return l(this,t.commands),n.apply(this,[r])}let t=e[0]||`nonzero`;return n.apply(this,[t])},e.prototype.stroke=function(e){e&&l(this,e.commands),r.apply(this)},e.prototype.isPointInPath=function(...e){if(e[0]instanceof c){let t=e[0],n=e[1],r=e[2],a=e[3]||`nonzero`;return l(this,t.commands),i.apply(this,[n,r,a])}return i.apply(this,e)}}function f(e){e&&!e.prototype.roundRect&&(e.prototype.roundRect=u)}function p(e){e&&!e.prototype.roundRect&&(e.prototype.roundRect=u)}export{c as Path2D,d as applyPath2DToCanvasRenderingContext,f as applyRoundRectToCanvasRenderingContext2D,p as applyRoundRectToPath2D,l as buildPath,i as parsePath,u as roundRect};
//# sourceMappingURL=dist.CzsTjCmd.js.map