@emasoft/svg-matrix 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/svg-matrix.js +7 -6
- package/bin/svgm.js +109 -40
- package/dist/svg-matrix.min.js +7 -7
- package/dist/svg-toolbox.min.js +148 -228
- package/dist/svgm.min.js +152 -232
- package/dist/version.json +5 -5
- package/package.json +1 -1
- package/scripts/postinstall.js +72 -41
- package/scripts/test-postinstall.js +18 -16
- package/scripts/version-sync.js +78 -60
- package/src/animation-optimization.js +190 -98
- package/src/animation-references.js +11 -3
- package/src/arc-length.js +23 -20
- package/src/bezier-analysis.js +9 -13
- package/src/bezier-intersections.js +18 -4
- package/src/browser-verify.js +35 -8
- package/src/clip-path-resolver.js +285 -114
- package/src/convert-path-data.js +20 -8
- package/src/css-specificity.js +33 -9
- package/src/douglas-peucker.js +272 -141
- package/src/geometry-to-path.js +79 -22
- package/src/gjk-collision.js +287 -126
- package/src/index.js +56 -21
- package/src/inkscape-support.js +122 -101
- package/src/logger.js +43 -27
- package/src/marker-resolver.js +201 -121
- package/src/mask-resolver.js +231 -98
- package/src/matrix.js +9 -5
- package/src/mesh-gradient.js +22 -14
- package/src/off-canvas-detection.js +53 -17
- package/src/path-optimization.js +356 -171
- package/src/path-simplification.js +671 -256
- package/src/pattern-resolver.js +1 -3
- package/src/polygon-clip.js +396 -78
- package/src/svg-boolean-ops.js +90 -23
- package/src/svg-collections.js +1546 -667
- package/src/svg-flatten.js +152 -38
- package/src/svg-matrix-lib.js +2 -2
- package/src/svg-parser.js +5 -1
- package/src/svg-rendering-context.js +3 -1
- package/src/svg-toolbox-lib.js +2 -2
- package/src/svg-toolbox.js +99 -457
- package/src/svg-validation-data.js +513 -345
- package/src/svg2-polyfills.js +156 -93
- package/src/svgm-lib.js +8 -4
- package/src/transform-optimization.js +168 -51
- package/src/transforms2d.js +73 -40
- package/src/transforms3d.js +34 -27
- package/src/use-symbol-resolver.js +175 -76
- package/src/vector.js +80 -44
- package/src/vendor/inkscape-hatch-polyfill.js +143 -108
- package/src/vendor/inkscape-hatch-polyfill.min.js +291 -1
- package/src/vendor/inkscape-mesh-polyfill.js +953 -766
- package/src/vendor/inkscape-mesh-polyfill.min.js +896 -1
- package/src/verification.js +3 -4
|
@@ -5,4 +5,899 @@
|
|
|
5
5
|
* License: GPLv3
|
|
6
6
|
* Copyright: 2017 Tavmjong Bah
|
|
7
7
|
*/
|
|
8
|
-
!function(){const t="http://www.w3.org/2000/svg",e="http://www.w3.org/1999/xlink",s="http://www.w3.org/1999/xhtml",r=2;if(document.createElementNS(t,"meshgradient").x)return;const n=(t,e,s,r)=>{let n=new x(.5*(e.x+s.x),.5*(e.y+s.y)),o=new x(.5*(t.x+e.x),.5*(t.y+e.y)),i=new x(.5*(s.x+r.x),.5*(s.y+r.y)),a=new x(.5*(n.x+o.x),.5*(n.y+o.y)),h=new x(.5*(n.x+i.x),.5*(n.y+i.y)),l=new x(.5*(a.x+h.x),.5*(a.y+h.y));return[[t,o,a,l],[l,h,i,r]]},o=t=>{let e=t[0].distSquared(t[1]),s=t[2].distSquared(t[3]),r=.25*t[0].distSquared(t[2]),n=.25*t[1].distSquared(t[3]),o=e>s?e:s,i=r>n?r:n;return 18*(o>i?o:i)},i=(t,e)=>Math.sqrt(t.distSquared(e)),a=(t,e)=>t.scale(2/3).add(e.scale(1/3)),h=t=>{let e,s,r,n,o,i,a,h=new g;return t.match(/(\w+\(\s*[^)]+\))+/g).forEach(t=>{let l=t.match(/[\w.-]+/g),d=l.shift();switch(d){case"translate":2===l.length?e=new g(1,0,0,1,l[0],l[1]):(console.error("mesh.js: translate does not have 2 arguments!"),e=new g(1,0,0,1,0,0)),h=h.append(e);break;case"scale":1===l.length?s=new g(l[0],0,0,l[0],0,0):2===l.length?s=new g(l[0],0,0,l[1],0,0):(console.error("mesh.js: scale does not have 1 or 2 arguments!"),s=new g(1,0,0,1,0,0)),h=h.append(s);break;case"rotate":if(3===l.length&&(e=new g(1,0,0,1,l[1],l[2]),h=h.append(e)),l[0]){r=l[0]*Math.PI/180;let t=Math.cos(r),e=Math.sin(r);Math.abs(t)<1e-16&&(t=0),Math.abs(e)<1e-16&&(e=0),a=new g(t,e,-e,t,0,0),h=h.append(a)}else console.error("math.js: No argument to rotate transform!");3===l.length&&(e=new g(1,0,0,1,-l[1],-l[2]),h=h.append(e));break;case"skewX":l[0]?(r=l[0]*Math.PI/180,n=Math.tan(r),o=new g(1,0,n,1,0,0),h=h.append(o)):console.error("math.js: No argument to skewX transform!");break;case"skewY":l[0]?(r=l[0]*Math.PI/180,n=Math.tan(r),i=new g(1,n,0,1,0,0),h=h.append(i)):console.error("math.js: No argument to skewY transform!");break;case"matrix":6===l.length?h=h.append(new g(...l)):console.error("math.js: Incorrect number of arguments for matrix!");break;default:console.error("mesh.js: Unhandled transform type: "+d)}}),h},l=t=>{let e=[],s=t.split(/[ ,]+/);for(let t=0,r=s.length-1;t<r;t+=2)e.push(new x(parseFloat(s[t]),parseFloat(s[t+1])));return e},d=(t,e)=>{for(let s in e)t.setAttribute(s,e[s])},c=(t,e,s,r,n)=>{let o,i,a=[0,0,0,0];for(let h=0;h<3;++h)e[h]<t[h]&&e[h]<s[h]||t[h]<e[h]&&s[h]<e[h]?a[h]=0:(a[h]=.5*((e[h]-t[h])/r+(s[h]-e[h])/n),o=Math.abs(3*(e[h]-t[h])/r),i=Math.abs(3*(s[h]-e[h])/n),a[h]>o?a[h]=o:a[h]>i&&(a[h]=i));return a},u=[[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],[-3,3,0,0,-2,-1,0,0,0,0,0,0,0,0,0,0],[2,-2,0,0,1,1,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],[0,0,0,0,0,0,0,0,-3,3,0,0,-2,-1,0,0],[0,0,0,0,0,0,0,0,2,-2,0,0,1,1,0,0],[-3,0,3,0,0,0,0,0,-2,0,-1,0,0,0,0,0],[0,0,0,0,-3,0,3,0,0,0,0,0,-2,0,-1,0],[9,-9,-9,9,6,3,-6,-3,6,-6,3,-3,4,2,2,1],[-6,6,6,-6,-3,-3,3,3,-4,4,-2,2,-2,-2,-1,-1],[2,0,-2,0,0,0,0,0,1,0,1,0,0,0,0,0],[0,0,0,0,2,0,-2,0,0,0,0,0,1,0,1,0],[-6,6,6,-6,-4,-2,4,2,-3,3,-3,3,-2,-1,-2,-1],[4,-4,-4,4,2,2,-2,-2,2,-2,2,-2,1,1,1,1]],f=t=>{let e=[];for(let s=0;s<16;++s){e[s]=0;for(let r=0;r<16;++r)e[s]+=u[s][r]*t[r]}return e},p=(t,e,s)=>{const r=e*e,n=s*s,o=e*e*e,i=s*s*s;return t[0]+t[1]*e+t[2]*r+t[3]*o+t[4]*s+t[5]*s*e+t[6]*s*r+t[7]*s*o+t[8]*n+t[9]*n*e+t[10]*n*r+t[11]*n*o+t[12]*i+t[13]*i*e+t[14]*i*r+t[15]*i*o},y=t=>{let e=[],s=[],r=[];for(let s=0;s<4;++s)e[s]=[],e[s][0]=n(t[0][s],t[1][s],t[2][s],t[3][s]),e[s][1]=[],e[s][1].push(...n(...e[s][0][0])),e[s][1].push(...n(...e[s][0][1])),e[s][2]=[],e[s][2].push(...n(...e[s][1][0])),e[s][2].push(...n(...e[s][1][1])),e[s][2].push(...n(...e[s][1][2])),e[s][2].push(...n(...e[s][1][3]));for(let t=0;t<8;++t){s[t]=[];for(let r=0;r<4;++r)s[t][r]=[],s[t][r][0]=n(e[0][2][t][r],e[1][2][t][r],e[2][2][t][r],e[3][2][t][r]),s[t][r][1]=[],s[t][r][1].push(...n(...s[t][r][0][0])),s[t][r][1].push(...n(...s[t][r][0][1])),s[t][r][2]=[],s[t][r][2].push(...n(...s[t][r][1][0])),s[t][r][2].push(...n(...s[t][r][1][1])),s[t][r][2].push(...n(...s[t][r][1][2])),s[t][r][2].push(...n(...s[t][r][1][3]))}for(let t=0;t<8;++t){r[t]=[];for(let e=0;e<8;++e)r[t][e]=[],r[t][e][0]=s[t][0][2][e],r[t][e][1]=s[t][1][2][e],r[t][e][2]=s[t][2][2][e],r[t][e][3]=s[t][3][2][e]}return r};class x{constructor(t,e){this.x=t||0,this.y=e||0}toString(){return`(x=${this.x}, y=${this.y})`}clone(){return new x(this.x,this.y)}add(t){return new x(this.x+t.x,this.y+t.y)}scale(t){return void 0===t.x?new x(this.x*t,this.y*t):new x(this.x*t.x,this.y*t.y)}distSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}transform(t){let e=this.x*t.a+this.y*t.c+t.e,s=this.x*t.b+this.y*t.d+t.f;return new x(e,s)}}class g{constructor(t,e,s,r,n,o){void 0===t?(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0):(this.a=t,this.b=e,this.c=s,this.d=r,this.e=n,this.f=o)}toString(){return`affine: ${this.a} ${this.c} ${this.e} \n ${this.b} ${this.d} ${this.f}`}append(t){t instanceof g||console.error("mesh.js: argument to Affine.append is not affine!");let e=this.a*t.a+this.c*t.b,s=this.b*t.a+this.d*t.b,r=this.a*t.c+this.c*t.d,n=this.b*t.c+this.d*t.d,o=this.a*t.e+this.c*t.f+this.e,i=this.b*t.e+this.d*t.f+this.f;return new g(e,s,r,n,o,i)}}class w{constructor(t,e){this.nodes=t,this.colors=e}paintCurve(t,e){if(o(this.nodes)>r){const s=n(...this.nodes);let r=[[],[]],o=[[],[]];for(let t=0;t<4;++t)r[0][t]=this.colors[0][t],r[1][t]=(this.colors[0][t]+this.colors[1][t])/2,o[0][t]=r[1][t],o[1][t]=this.colors[1][t];let i=new w(s[0],r),a=new w(s[1],o);i.paintCurve(t,e),a.paintCurve(t,e)}else{let s=Math.round(this.nodes[0].x);if(s>=0&&s<e){let r=4*(~~this.nodes[0].y*e+s);t[r]=Math.round(this.colors[0][0]),t[r+1]=Math.round(this.colors[0][1]),t[r+2]=Math.round(this.colors[0][2]),t[r+3]=Math.round(this.colors[0][3])}}}}class m{constructor(t,e){this.nodes=t,this.colors=e}split(){let t=[[],[],[],[]],e=[[],[],[],[]],s=[[[],[]],[[],[]]],r=[[[],[]],[[],[]]];for(let s=0;s<4;++s){const r=n(this.nodes[0][s],this.nodes[1][s],this.nodes[2][s],this.nodes[3][s]);t[0][s]=r[0][0],t[1][s]=r[0][1],t[2][s]=r[0][2],t[3][s]=r[0][3],e[0][s]=r[1][0],e[1][s]=r[1][1],e[2][s]=r[1][2],e[3][s]=r[1][3]}for(let t=0;t<4;++t)s[0][0][t]=this.colors[0][0][t],s[0][1][t]=this.colors[0][1][t],s[1][0][t]=(this.colors[0][0][t]+this.colors[1][0][t])/2,s[1][1][t]=(this.colors[0][1][t]+this.colors[1][1][t])/2,r[0][0][t]=s[1][0][t],r[0][1][t]=s[1][1][t],r[1][0][t]=this.colors[1][0][t],r[1][1][t]=this.colors[1][1][t];return[new m(t,s),new m(e,r)]}paint(t,e){let s,n=!1;for(let t=0;t<4;++t)if((s=o([this.nodes[0][t],this.nodes[1][t],this.nodes[2][t],this.nodes[3][t]]))>r){n=!0;break}if(n){let s=this.split();s[0].paint(t,e),s[1].paint(t,e)}else{new w([...this.nodes[0]],[...this.colors[0]]).paintCurve(t,e)}}}class b{constructor(t){this.readMesh(t),this.type=t.getAttribute("type")||"bilinear"}readMesh(t){let e=[[]],s=[[]],r=Number(t.getAttribute("x")),n=Number(t.getAttribute("y"));e[0][0]=new x(r,n);let o=t.children;for(let t=0,r=o.length;t<r;++t){e[3*t+1]=[],e[3*t+2]=[],e[3*t+3]=[],s[t+1]=[];let r=o[t].children;for(let n=0,o=r.length;n<o;++n){let o=r[n].children;for(let r=0,i=o.length;r<i;++r){let i=r;0!==t&&++i;let h,d=o[r].getAttribute("path"),c="l";null!=d&&(c=(h=d.match(/\s*([lLcC])\s*(.*)/))[1]);let u=l(h[2]);switch(c){case"l":0===i?(e[3*t][3*n+3]=u[0].add(e[3*t][3*n]),e[3*t][3*n+1]=a(e[3*t][3*n],e[3*t][3*n+3]),e[3*t][3*n+2]=a(e[3*t][3*n+3],e[3*t][3*n])):1===i?(e[3*t+3][3*n+3]=u[0].add(e[3*t][3*n+3]),e[3*t+1][3*n+3]=a(e[3*t][3*n+3],e[3*t+3][3*n+3]),e[3*t+2][3*n+3]=a(e[3*t+3][3*n+3],e[3*t][3*n+3])):2===i?(0===n&&(e[3*t+3][3*n+0]=u[0].add(e[3*t+3][3*n+3])),e[3*t+3][3*n+1]=a(e[3*t+3][3*n],e[3*t+3][3*n+3]),e[3*t+3][3*n+2]=a(e[3*t+3][3*n+3],e[3*t+3][3*n])):(e[3*t+1][3*n]=a(e[3*t][3*n],e[3*t+3][3*n]),e[3*t+2][3*n]=a(e[3*t+3][3*n],e[3*t][3*n]));break;case"L":0===i?(e[3*t][3*n+3]=u[0],e[3*t][3*n+1]=a(e[3*t][3*n],e[3*t][3*n+3]),e[3*t][3*n+2]=a(e[3*t][3*n+3],e[3*t][3*n])):1===i?(e[3*t+3][3*n+3]=u[0],e[3*t+1][3*n+3]=a(e[3*t][3*n+3],e[3*t+3][3*n+3]),e[3*t+2][3*n+3]=a(e[3*t+3][3*n+3],e[3*t][3*n+3])):2===i?(0===n&&(e[3*t+3][3*n+0]=u[0]),e[3*t+3][3*n+1]=a(e[3*t+3][3*n],e[3*t+3][3*n+3]),e[3*t+3][3*n+2]=a(e[3*t+3][3*n+3],e[3*t+3][3*n])):(e[3*t+1][3*n]=a(e[3*t][3*n],e[3*t+3][3*n]),e[3*t+2][3*n]=a(e[3*t+3][3*n],e[3*t][3*n]));break;case"c":0===i?(e[3*t][3*n+1]=u[0].add(e[3*t][3*n]),e[3*t][3*n+2]=u[1].add(e[3*t][3*n]),e[3*t][3*n+3]=u[2].add(e[3*t][3*n])):1===i?(e[3*t+1][3*n+3]=u[0].add(e[3*t][3*n+3]),e[3*t+2][3*n+3]=u[1].add(e[3*t][3*n+3]),e[3*t+3][3*n+3]=u[2].add(e[3*t][3*n+3])):2===i?(e[3*t+3][3*n+2]=u[0].add(e[3*t+3][3*n+3]),e[3*t+3][3*n+1]=u[1].add(e[3*t+3][3*n+3]),0===n&&(e[3*t+3][3*n+0]=u[2].add(e[3*t+3][3*n+3]))):(e[3*t+2][3*n]=u[0].add(e[3*t+3][3*n]),e[3*t+1][3*n]=u[1].add(e[3*t+3][3*n]));break;case"C":0===i?(e[3*t][3*n+1]=u[0],e[3*t][3*n+2]=u[1],e[3*t][3*n+3]=u[2]):1===i?(e[3*t+1][3*n+3]=u[0],e[3*t+2][3*n+3]=u[1],e[3*t+3][3*n+3]=u[2]):2===i?(e[3*t+3][3*n+2]=u[0],e[3*t+3][3*n+1]=u[1],0===n&&(e[3*t+3][3*n+0]=u[2])):(e[3*t+2][3*n]=u[0],e[3*t+1][3*n]=u[1]);break;default:console.error("mesh.js: "+c+" invalid path type.")}if(0===t&&0===n||r>0){let e=window.getComputedStyle(o[r]).stopColor.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i),a=window.getComputedStyle(o[r]).stopOpacity,h=255;a&&(h=Math.floor(255*a)),e&&(0===i?(s[t][n]=[],s[t][n][0]=Math.floor(e[1]),s[t][n][1]=Math.floor(e[2]),s[t][n][2]=Math.floor(e[3]),s[t][n][3]=h):1===i?(s[t][n+1]=[],s[t][n+1][0]=Math.floor(e[1]),s[t][n+1][1]=Math.floor(e[2]),s[t][n+1][2]=Math.floor(e[3]),s[t][n+1][3]=h):2===i?(s[t+1][n+1]=[],s[t+1][n+1][0]=Math.floor(e[1]),s[t+1][n+1][1]=Math.floor(e[2]),s[t+1][n+1][2]=Math.floor(e[3]),s[t+1][n+1][3]=h):3===i&&(s[t+1][n]=[],s[t+1][n][0]=Math.floor(e[1]),s[t+1][n][1]=Math.floor(e[2]),s[t+1][n][2]=Math.floor(e[3]),s[t+1][n][3]=h))}}e[3*t+1][3*n+1]=new x,e[3*t+1][3*n+2]=new x,e[3*t+2][3*n+1]=new x,e[3*t+2][3*n+2]=new x,e[3*t+1][3*n+1].x=(-4*e[3*t][3*n].x+6*(e[3*t][3*n+1].x+e[3*t+1][3*n].x)+-2*(e[3*t][3*n+3].x+e[3*t+3][3*n].x)+3*(e[3*t+3][3*n+1].x+e[3*t+1][3*n+3].x)+-1*e[3*t+3][3*n+3].x)/9,e[3*t+1][3*n+2].x=(-4*e[3*t][3*n+3].x+6*(e[3*t][3*n+2].x+e[3*t+1][3*n+3].x)+-2*(e[3*t][3*n].x+e[3*t+3][3*n+3].x)+3*(e[3*t+3][3*n+2].x+e[3*t+1][3*n].x)+-1*e[3*t+3][3*n].x)/9,e[3*t+2][3*n+1].x=(-4*e[3*t+3][3*n].x+6*(e[3*t+3][3*n+1].x+e[3*t+2][3*n].x)+-2*(e[3*t+3][3*n+3].x+e[3*t][3*n].x)+3*(e[3*t][3*n+1].x+e[3*t+2][3*n+3].x)+-1*e[3*t][3*n+3].x)/9,e[3*t+2][3*n+2].x=(-4*e[3*t+3][3*n+3].x+6*(e[3*t+3][3*n+2].x+e[3*t+2][3*n+3].x)+-2*(e[3*t+3][3*n].x+e[3*t][3*n+3].x)+3*(e[3*t][3*n+2].x+e[3*t+2][3*n].x)+-1*e[3*t][3*n].x)/9,e[3*t+1][3*n+1].y=(-4*e[3*t][3*n].y+6*(e[3*t][3*n+1].y+e[3*t+1][3*n].y)+-2*(e[3*t][3*n+3].y+e[3*t+3][3*n].y)+3*(e[3*t+3][3*n+1].y+e[3*t+1][3*n+3].y)+-1*e[3*t+3][3*n+3].y)/9,e[3*t+1][3*n+2].y=(-4*e[3*t][3*n+3].y+6*(e[3*t][3*n+2].y+e[3*t+1][3*n+3].y)+-2*(e[3*t][3*n].y+e[3*t+3][3*n+3].y)+3*(e[3*t+3][3*n+2].y+e[3*t+1][3*n].y)+-1*e[3*t+3][3*n].y)/9,e[3*t+2][3*n+1].y=(-4*e[3*t+3][3*n].y+6*(e[3*t+3][3*n+1].y+e[3*t+2][3*n].y)+-2*(e[3*t+3][3*n+3].y+e[3*t][3*n].y)+3*(e[3*t][3*n+1].y+e[3*t+2][3*n+3].y)+-1*e[3*t][3*n+3].y)/9,e[3*t+2][3*n+2].y=(-4*e[3*t+3][3*n+3].y+6*(e[3*t+3][3*n+2].y+e[3*t+2][3*n+3].y)+-2*(e[3*t+3][3*n].y+e[3*t][3*n+3].y)+3*(e[3*t][3*n+2].y+e[3*t+2][3*n].y)+-1*e[3*t][3*n].y)/9}}this.nodes=e,this.colors=s}paintMesh(t,e){let s=(this.nodes.length-1)/3,r=(this.nodes[0].length-1)/3;if("bilinear"===this.type||s<2||r<2){let n;for(let o=0;o<s;++o)for(let s=0;s<r;++s){let r=[];for(let t=3*o,e=3*o+4;t<e;++t)r.push(this.nodes[t].slice(3*s,3*s+4));let i=[];i.push(this.colors[o].slice(s,s+2)),i.push(this.colors[o+1].slice(s,s+2)),(n=new m(r,i)).paint(t,e)}}else{let n,o,a,h,l,d,u;const x=s,g=r;s++,r++;let w=new Array(s);for(let t=0;t<s;++t){w[t]=new Array(r);for(let e=0;e<r;++e)w[t][e]=[],w[t][e][0]=this.nodes[3*t][3*e],w[t][e][1]=this.colors[t][e]}for(let t=0;t<s;++t)for(let e=0;e<r;++e)0!==t&&t!==x&&(n=i(w[t-1][e][0],w[t][e][0]),o=i(w[t+1][e][0],w[t][e][0]),w[t][e][2]=c(w[t-1][e][1],w[t][e][1],w[t+1][e][1],n,o)),0!==e&&e!==g&&(n=i(w[t][e-1][0],w[t][e][0]),o=i(w[t][e+1][0],w[t][e][0]),w[t][e][3]=c(w[t][e-1][1],w[t][e][1],w[t][e+1][1],n,o));for(let t=0;t<r;++t){w[0][t][2]=[],w[x][t][2]=[];for(let e=0;e<4;++e)n=i(w[1][t][0],w[0][t][0]),o=i(w[x][t][0],w[x-1][t][0]),w[0][t][2][e]=n>0?2*(w[1][t][1][e]-w[0][t][1][e])/n-w[1][t][2][e]:0,w[x][t][2][e]=o>0?2*(w[x][t][1][e]-w[x-1][t][1][e])/o-w[x-1][t][2][e]:0}for(let t=0;t<s;++t){w[t][0][3]=[],w[t][g][3]=[];for(let e=0;e<4;++e)n=i(w[t][1][0],w[t][0][0]),o=i(w[t][g][0],w[t][g-1][0]),w[t][0][3][e]=n>0?2*(w[t][1][1][e]-w[t][0][1][e])/n-w[t][1][3][e]:0,w[t][g][3][e]=o>0?2*(w[t][g][1][e]-w[t][g-1][1][e])/o-w[t][g-1][3][e]:0}for(let s=0;s<x;++s)for(let r=0;r<g;++r){let n=i(w[s][r][0],w[s+1][r][0]),o=i(w[s][r+1][0],w[s+1][r+1][0]),c=i(w[s][r][0],w[s][r+1][0]),x=i(w[s+1][r][0],w[s+1][r+1][0]),g=[[],[],[],[]];for(let t=0;t<4;++t){(d=[])[0]=w[s][r][1][t],d[1]=w[s+1][r][1][t],d[2]=w[s][r+1][1][t],d[3]=w[s+1][r+1][1][t],d[4]=w[s][r][2][t]*n,d[5]=w[s+1][r][2][t]*n,d[6]=w[s][r+1][2][t]*o,d[7]=w[s+1][r+1][2][t]*o,d[8]=w[s][r][3][t]*c,d[9]=w[s+1][r][3][t]*x,d[10]=w[s][r+1][3][t]*c,d[11]=w[s+1][r+1][3][t]*x,d[12]=0,d[13]=0,d[14]=0,d[15]=0,u=f(d);for(let e=0;e<9;++e){g[t][e]=[];for(let s=0;s<9;++s)g[t][e][s]=p(u,e/8,s/8),g[t][e][s]>255?g[t][e][s]=255:g[t][e][s]<0&&(g[t][e][s]=0)}}h=[];for(let t=3*s,e=3*s+4;t<e;++t)h.push(this.nodes[t].slice(3*r,3*r+4));l=y(h);for(let s=0;s<8;++s)for(let r=0;r<8;++r)(a=new m(l[s][r],[[[g[0][s][r],g[1][s][r],g[2][s][r],g[3][s][r]],[g[0][s][r+1],g[1][s][r+1],g[2][s][r+1],g[3][s][r+1]]],[[g[0][s+1][r],g[1][s+1][r],g[2][s+1][r],g[3][s+1][r]],[g[0][s+1][r+1],g[1][s+1][r+1],g[2][s+1][r+1],g[3][s+1][r+1]]]])).paint(t,e)}}}transform(t){if(t instanceof x)for(let e=0,s=this.nodes.length;e<s;++e)for(let s=0,r=this.nodes[0].length;s<r;++s)this.nodes[e][s]=this.nodes[e][s].add(t);else if(t instanceof g)for(let e=0,s=this.nodes.length;e<s;++e)for(let s=0,r=this.nodes[0].length;s<r;++s)this.nodes[e][s]=this.nodes[e][s].transform(t)}scale(t){for(let e=0,s=this.nodes.length;e<s;++e)for(let s=0,r=this.nodes[0].length;s<r;++s)this.nodes[e][s]=this.nodes[e][s].scale(t)}}document.querySelectorAll("rect,circle,ellipse,path,text").forEach((r,n)=>{let o=r.getAttribute("id");o||(o="patchjs_shape"+n,r.setAttribute("id",o));const i=r.style.fill.match(/^url\(\s*"?\s*#([^\s"]+)"?\s*\)/),a=r.style.stroke.match(/^url\(\s*"?\s*#([^\s"]+)"?\s*\)/);if(i&&i[1]){const a=document.getElementById(i[1]);if(a&&"meshgradient"===a.nodeName){const i=r.getBBox();let l=document.createElementNS(s,"canvas");d(l,{width:i.width,height:i.height});const c=l.getContext("2d");let u=c.createImageData(i.width,i.height);const f=new b(a);"objectBoundingBox"===a.getAttribute("gradientUnits")&&f.scale(new x(i.width,i.height));const p=a.getAttribute("gradientTransform");null!=p&&f.transform(h(p)),"userSpaceOnUse"===a.getAttribute("gradientUnits")&&f.transform(new x(-i.x,-i.y)),f.paintMesh(u.data,l.width),c.putImageData(u,0,0);const y=document.createElementNS(t,"image");d(y,{width:i.width,height:i.height,x:i.x,y:i.y});let g=l.toDataURL();y.setAttributeNS(e,"xlink:href",g),r.parentNode.insertBefore(y,r),r.style.fill="none";const w=document.createElementNS(t,"use");w.setAttributeNS(e,"xlink:href","#"+o);const m="patchjs_clip"+n,M=document.createElementNS(t,"clipPath");M.setAttribute("id",m),M.appendChild(w),r.parentElement.insertBefore(M,r),y.setAttribute("clip-path","url(#"+m+")"),u=null,l=null,g=null}}if(a&&a[1]){const o=document.getElementById(a[1]);if(o&&"meshgradient"===o.nodeName){const i=parseFloat(r.style.strokeWidth.slice(0,-2))*(parseFloat(r.style.strokeMiterlimit)||parseFloat(r.getAttribute("stroke-miterlimit"))||1),a=r.getBBox(),l=Math.trunc(a.width+i),c=Math.trunc(a.height+i),u=Math.trunc(a.x-i/2),f=Math.trunc(a.y-i/2);let p=document.createElementNS(s,"canvas");d(p,{width:l,height:c});const y=p.getContext("2d");let g=y.createImageData(l,c);const w=new b(o);"objectBoundingBox"===o.getAttribute("gradientUnits")&&w.scale(new x(l,c));const m=o.getAttribute("gradientTransform");null!=m&&w.transform(h(m)),"userSpaceOnUse"===o.getAttribute("gradientUnits")&&w.transform(new x(-u,-f)),w.paintMesh(g.data,p.width),y.putImageData(g,0,0);const M=document.createElementNS(t,"image");d(M,{width:l,height:c,x:0,y:0});let S=p.toDataURL();M.setAttributeNS(e,"xlink:href",S);const k="pattern_clip"+n,A=document.createElementNS(t,"pattern");d(A,{id:k,patternUnits:"userSpaceOnUse",width:l,height:c,x:u,y:f}),A.appendChild(M),o.parentNode.appendChild(A),r.style.stroke="url(#"+k+")",g=null,p=null,S=null}}})}();
|
|
8
|
+
!(function () {
|
|
9
|
+
const t = "http://www.w3.org/2000/svg",
|
|
10
|
+
e = "http://www.w3.org/1999/xlink",
|
|
11
|
+
s = "http://www.w3.org/1999/xhtml",
|
|
12
|
+
r = 2;
|
|
13
|
+
if (document.createElementNS(t, "meshgradient").x) return;
|
|
14
|
+
const n = (t, e, s, r) => {
|
|
15
|
+
let n = new x(0.5 * (e.x + s.x), 0.5 * (e.y + s.y)),
|
|
16
|
+
o = new x(0.5 * (t.x + e.x), 0.5 * (t.y + e.y)),
|
|
17
|
+
i = new x(0.5 * (s.x + r.x), 0.5 * (s.y + r.y)),
|
|
18
|
+
a = new x(0.5 * (n.x + o.x), 0.5 * (n.y + o.y)),
|
|
19
|
+
h = new x(0.5 * (n.x + i.x), 0.5 * (n.y + i.y)),
|
|
20
|
+
l = new x(0.5 * (a.x + h.x), 0.5 * (a.y + h.y));
|
|
21
|
+
return [
|
|
22
|
+
[t, o, a, l],
|
|
23
|
+
[l, h, i, r],
|
|
24
|
+
];
|
|
25
|
+
},
|
|
26
|
+
o = (t) => {
|
|
27
|
+
let e = t[0].distSquared(t[1]),
|
|
28
|
+
s = t[2].distSquared(t[3]),
|
|
29
|
+
r = 0.25 * t[0].distSquared(t[2]),
|
|
30
|
+
n = 0.25 * t[1].distSquared(t[3]),
|
|
31
|
+
o = e > s ? e : s,
|
|
32
|
+
i = r > n ? r : n;
|
|
33
|
+
return 18 * (o > i ? o : i);
|
|
34
|
+
},
|
|
35
|
+
i = (t, e) => Math.sqrt(t.distSquared(e)),
|
|
36
|
+
a = (t, e) => t.scale(2 / 3).add(e.scale(1 / 3)),
|
|
37
|
+
h = (t) => {
|
|
38
|
+
let e,
|
|
39
|
+
s,
|
|
40
|
+
r,
|
|
41
|
+
n,
|
|
42
|
+
o,
|
|
43
|
+
i,
|
|
44
|
+
a,
|
|
45
|
+
h = new g();
|
|
46
|
+
return (
|
|
47
|
+
t.match(/(\w+\(\s*[^)]+\))+/g).forEach((t) => {
|
|
48
|
+
let l = t.match(/[\w.-]+/g),
|
|
49
|
+
d = l.shift();
|
|
50
|
+
switch (d) {
|
|
51
|
+
case "translate":
|
|
52
|
+
(2 === l.length
|
|
53
|
+
? (e = new g(1, 0, 0, 1, l[0], l[1]))
|
|
54
|
+
: (console.error(
|
|
55
|
+
"mesh.js: translate does not have 2 arguments!",
|
|
56
|
+
),
|
|
57
|
+
(e = new g(1, 0, 0, 1, 0, 0))),
|
|
58
|
+
(h = h.append(e)));
|
|
59
|
+
break;
|
|
60
|
+
case "scale":
|
|
61
|
+
(1 === l.length
|
|
62
|
+
? (s = new g(l[0], 0, 0, l[0], 0, 0))
|
|
63
|
+
: 2 === l.length
|
|
64
|
+
? (s = new g(l[0], 0, 0, l[1], 0, 0))
|
|
65
|
+
: (console.error(
|
|
66
|
+
"mesh.js: scale does not have 1 or 2 arguments!",
|
|
67
|
+
),
|
|
68
|
+
(s = new g(1, 0, 0, 1, 0, 0))),
|
|
69
|
+
(h = h.append(s)));
|
|
70
|
+
break;
|
|
71
|
+
case "rotate":
|
|
72
|
+
if (
|
|
73
|
+
(3 === l.length &&
|
|
74
|
+
((e = new g(1, 0, 0, 1, l[1], l[2])), (h = h.append(e))),
|
|
75
|
+
l[0])
|
|
76
|
+
) {
|
|
77
|
+
r = (l[0] * Math.PI) / 180;
|
|
78
|
+
let t = Math.cos(r),
|
|
79
|
+
e = Math.sin(r);
|
|
80
|
+
(Math.abs(t) < 1e-16 && (t = 0),
|
|
81
|
+
Math.abs(e) < 1e-16 && (e = 0),
|
|
82
|
+
(a = new g(t, e, -e, t, 0, 0)),
|
|
83
|
+
(h = h.append(a)));
|
|
84
|
+
} else console.error("math.js: No argument to rotate transform!");
|
|
85
|
+
3 === l.length &&
|
|
86
|
+
((e = new g(1, 0, 0, 1, -l[1], -l[2])), (h = h.append(e)));
|
|
87
|
+
break;
|
|
88
|
+
case "skewX":
|
|
89
|
+
l[0]
|
|
90
|
+
? ((r = (l[0] * Math.PI) / 180),
|
|
91
|
+
(n = Math.tan(r)),
|
|
92
|
+
(o = new g(1, 0, n, 1, 0, 0)),
|
|
93
|
+
(h = h.append(o)))
|
|
94
|
+
: console.error("math.js: No argument to skewX transform!");
|
|
95
|
+
break;
|
|
96
|
+
case "skewY":
|
|
97
|
+
l[0]
|
|
98
|
+
? ((r = (l[0] * Math.PI) / 180),
|
|
99
|
+
(n = Math.tan(r)),
|
|
100
|
+
(i = new g(1, n, 0, 1, 0, 0)),
|
|
101
|
+
(h = h.append(i)))
|
|
102
|
+
: console.error("math.js: No argument to skewY transform!");
|
|
103
|
+
break;
|
|
104
|
+
case "matrix":
|
|
105
|
+
6 === l.length
|
|
106
|
+
? (h = h.append(new g(...l)))
|
|
107
|
+
: console.error(
|
|
108
|
+
"math.js: Incorrect number of arguments for matrix!",
|
|
109
|
+
);
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
console.error("mesh.js: Unhandled transform type: " + d);
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
h
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
l = (t) => {
|
|
119
|
+
let e = [],
|
|
120
|
+
s = t.split(/[ ,]+/);
|
|
121
|
+
for (let t = 0, r = s.length - 1; t < r; t += 2)
|
|
122
|
+
e.push(new x(parseFloat(s[t]), parseFloat(s[t + 1])));
|
|
123
|
+
return e;
|
|
124
|
+
},
|
|
125
|
+
d = (t, e) => {
|
|
126
|
+
for (let s in e) t.setAttribute(s, e[s]);
|
|
127
|
+
},
|
|
128
|
+
c = (t, e, s, r, n) => {
|
|
129
|
+
let o,
|
|
130
|
+
i,
|
|
131
|
+
a = [0, 0, 0, 0];
|
|
132
|
+
for (let h = 0; h < 3; ++h)
|
|
133
|
+
(e[h] < t[h] && e[h] < s[h]) || (t[h] < e[h] && s[h] < e[h])
|
|
134
|
+
? (a[h] = 0)
|
|
135
|
+
: ((a[h] = 0.5 * ((e[h] - t[h]) / r + (s[h] - e[h]) / n)),
|
|
136
|
+
(o = Math.abs((3 * (e[h] - t[h])) / r)),
|
|
137
|
+
(i = Math.abs((3 * (s[h] - e[h])) / n)),
|
|
138
|
+
a[h] > o ? (a[h] = o) : a[h] > i && (a[h] = i));
|
|
139
|
+
return a;
|
|
140
|
+
},
|
|
141
|
+
u = [
|
|
142
|
+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
143
|
+
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
144
|
+
[-3, 3, 0, 0, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
145
|
+
[2, -2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
146
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
|
|
147
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
|
|
148
|
+
[0, 0, 0, 0, 0, 0, 0, 0, -3, 3, 0, 0, -2, -1, 0, 0],
|
|
149
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 1, 1, 0, 0],
|
|
150
|
+
[-3, 0, 3, 0, 0, 0, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0],
|
|
151
|
+
[0, 0, 0, 0, -3, 0, 3, 0, 0, 0, 0, 0, -2, 0, -1, 0],
|
|
152
|
+
[9, -9, -9, 9, 6, 3, -6, -3, 6, -6, 3, -3, 4, 2, 2, 1],
|
|
153
|
+
[-6, 6, 6, -6, -3, -3, 3, 3, -4, 4, -2, 2, -2, -2, -1, -1],
|
|
154
|
+
[2, 0, -2, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0],
|
|
155
|
+
[0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, 0, 1, 0, 1, 0],
|
|
156
|
+
[-6, 6, 6, -6, -4, -2, 4, 2, -3, 3, -3, 3, -2, -1, -2, -1],
|
|
157
|
+
[4, -4, -4, 4, 2, 2, -2, -2, 2, -2, 2, -2, 1, 1, 1, 1],
|
|
158
|
+
],
|
|
159
|
+
f = (t) => {
|
|
160
|
+
let e = [];
|
|
161
|
+
for (let s = 0; s < 16; ++s) {
|
|
162
|
+
e[s] = 0;
|
|
163
|
+
for (let r = 0; r < 16; ++r) e[s] += u[s][r] * t[r];
|
|
164
|
+
}
|
|
165
|
+
return e;
|
|
166
|
+
},
|
|
167
|
+
p = (t, e, s) => {
|
|
168
|
+
const r = e * e,
|
|
169
|
+
n = s * s,
|
|
170
|
+
o = e * e * e,
|
|
171
|
+
i = s * s * s;
|
|
172
|
+
return (
|
|
173
|
+
t[0] +
|
|
174
|
+
t[1] * e +
|
|
175
|
+
t[2] * r +
|
|
176
|
+
t[3] * o +
|
|
177
|
+
t[4] * s +
|
|
178
|
+
t[5] * s * e +
|
|
179
|
+
t[6] * s * r +
|
|
180
|
+
t[7] * s * o +
|
|
181
|
+
t[8] * n +
|
|
182
|
+
t[9] * n * e +
|
|
183
|
+
t[10] * n * r +
|
|
184
|
+
t[11] * n * o +
|
|
185
|
+
t[12] * i +
|
|
186
|
+
t[13] * i * e +
|
|
187
|
+
t[14] * i * r +
|
|
188
|
+
t[15] * i * o
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
y = (t) => {
|
|
192
|
+
let e = [],
|
|
193
|
+
s = [],
|
|
194
|
+
r = [];
|
|
195
|
+
for (let s = 0; s < 4; ++s)
|
|
196
|
+
((e[s] = []),
|
|
197
|
+
(e[s][0] = n(t[0][s], t[1][s], t[2][s], t[3][s])),
|
|
198
|
+
(e[s][1] = []),
|
|
199
|
+
e[s][1].push(...n(...e[s][0][0])),
|
|
200
|
+
e[s][1].push(...n(...e[s][0][1])),
|
|
201
|
+
(e[s][2] = []),
|
|
202
|
+
e[s][2].push(...n(...e[s][1][0])),
|
|
203
|
+
e[s][2].push(...n(...e[s][1][1])),
|
|
204
|
+
e[s][2].push(...n(...e[s][1][2])),
|
|
205
|
+
e[s][2].push(...n(...e[s][1][3])));
|
|
206
|
+
for (let t = 0; t < 8; ++t) {
|
|
207
|
+
s[t] = [];
|
|
208
|
+
for (let r = 0; r < 4; ++r)
|
|
209
|
+
((s[t][r] = []),
|
|
210
|
+
(s[t][r][0] = n(
|
|
211
|
+
e[0][2][t][r],
|
|
212
|
+
e[1][2][t][r],
|
|
213
|
+
e[2][2][t][r],
|
|
214
|
+
e[3][2][t][r],
|
|
215
|
+
)),
|
|
216
|
+
(s[t][r][1] = []),
|
|
217
|
+
s[t][r][1].push(...n(...s[t][r][0][0])),
|
|
218
|
+
s[t][r][1].push(...n(...s[t][r][0][1])),
|
|
219
|
+
(s[t][r][2] = []),
|
|
220
|
+
s[t][r][2].push(...n(...s[t][r][1][0])),
|
|
221
|
+
s[t][r][2].push(...n(...s[t][r][1][1])),
|
|
222
|
+
s[t][r][2].push(...n(...s[t][r][1][2])),
|
|
223
|
+
s[t][r][2].push(...n(...s[t][r][1][3])));
|
|
224
|
+
}
|
|
225
|
+
for (let t = 0; t < 8; ++t) {
|
|
226
|
+
r[t] = [];
|
|
227
|
+
for (let e = 0; e < 8; ++e)
|
|
228
|
+
((r[t][e] = []),
|
|
229
|
+
(r[t][e][0] = s[t][0][2][e]),
|
|
230
|
+
(r[t][e][1] = s[t][1][2][e]),
|
|
231
|
+
(r[t][e][2] = s[t][2][2][e]),
|
|
232
|
+
(r[t][e][3] = s[t][3][2][e]));
|
|
233
|
+
}
|
|
234
|
+
return r;
|
|
235
|
+
};
|
|
236
|
+
class x {
|
|
237
|
+
constructor(t, e) {
|
|
238
|
+
((this.x = t || 0), (this.y = e || 0));
|
|
239
|
+
}
|
|
240
|
+
toString() {
|
|
241
|
+
return `(x=${this.x}, y=${this.y})`;
|
|
242
|
+
}
|
|
243
|
+
clone() {
|
|
244
|
+
return new x(this.x, this.y);
|
|
245
|
+
}
|
|
246
|
+
add(t) {
|
|
247
|
+
return new x(this.x + t.x, this.y + t.y);
|
|
248
|
+
}
|
|
249
|
+
scale(t) {
|
|
250
|
+
return void 0 === t.x
|
|
251
|
+
? new x(this.x * t, this.y * t)
|
|
252
|
+
: new x(this.x * t.x, this.y * t.y);
|
|
253
|
+
}
|
|
254
|
+
distSquared(t) {
|
|
255
|
+
let e = this.x - t.x,
|
|
256
|
+
s = this.y - t.y;
|
|
257
|
+
return e * e + s * s;
|
|
258
|
+
}
|
|
259
|
+
transform(t) {
|
|
260
|
+
let e = this.x * t.a + this.y * t.c + t.e,
|
|
261
|
+
s = this.x * t.b + this.y * t.d + t.f;
|
|
262
|
+
return new x(e, s);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
class g {
|
|
266
|
+
constructor(t, e, s, r, n, o) {
|
|
267
|
+
void 0 === t
|
|
268
|
+
? ((this.a = 1),
|
|
269
|
+
(this.b = 0),
|
|
270
|
+
(this.c = 0),
|
|
271
|
+
(this.d = 1),
|
|
272
|
+
(this.e = 0),
|
|
273
|
+
(this.f = 0))
|
|
274
|
+
: ((this.a = t),
|
|
275
|
+
(this.b = e),
|
|
276
|
+
(this.c = s),
|
|
277
|
+
(this.d = r),
|
|
278
|
+
(this.e = n),
|
|
279
|
+
(this.f = o));
|
|
280
|
+
}
|
|
281
|
+
toString() {
|
|
282
|
+
return `affine: ${this.a} ${this.c} ${this.e} \n ${this.b} ${this.d} ${this.f}`;
|
|
283
|
+
}
|
|
284
|
+
append(t) {
|
|
285
|
+
t instanceof g ||
|
|
286
|
+
console.error("mesh.js: argument to Affine.append is not affine!");
|
|
287
|
+
let e = this.a * t.a + this.c * t.b,
|
|
288
|
+
s = this.b * t.a + this.d * t.b,
|
|
289
|
+
r = this.a * t.c + this.c * t.d,
|
|
290
|
+
n = this.b * t.c + this.d * t.d,
|
|
291
|
+
o = this.a * t.e + this.c * t.f + this.e,
|
|
292
|
+
i = this.b * t.e + this.d * t.f + this.f;
|
|
293
|
+
return new g(e, s, r, n, o, i);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
class w {
|
|
297
|
+
constructor(t, e) {
|
|
298
|
+
((this.nodes = t), (this.colors = e));
|
|
299
|
+
}
|
|
300
|
+
paintCurve(t, e) {
|
|
301
|
+
if (o(this.nodes) > r) {
|
|
302
|
+
const s = n(...this.nodes);
|
|
303
|
+
let r = [[], []],
|
|
304
|
+
o = [[], []];
|
|
305
|
+
for (let t = 0; t < 4; ++t)
|
|
306
|
+
((r[0][t] = this.colors[0][t]),
|
|
307
|
+
(r[1][t] = (this.colors[0][t] + this.colors[1][t]) / 2),
|
|
308
|
+
(o[0][t] = r[1][t]),
|
|
309
|
+
(o[1][t] = this.colors[1][t]));
|
|
310
|
+
let i = new w(s[0], r),
|
|
311
|
+
a = new w(s[1], o);
|
|
312
|
+
(i.paintCurve(t, e), a.paintCurve(t, e));
|
|
313
|
+
} else {
|
|
314
|
+
let s = Math.round(this.nodes[0].x);
|
|
315
|
+
if (s >= 0 && s < e) {
|
|
316
|
+
let r = 4 * (~~this.nodes[0].y * e + s);
|
|
317
|
+
((t[r] = Math.round(this.colors[0][0])),
|
|
318
|
+
(t[r + 1] = Math.round(this.colors[0][1])),
|
|
319
|
+
(t[r + 2] = Math.round(this.colors[0][2])),
|
|
320
|
+
(t[r + 3] = Math.round(this.colors[0][3])));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
class m {
|
|
326
|
+
constructor(t, e) {
|
|
327
|
+
((this.nodes = t), (this.colors = e));
|
|
328
|
+
}
|
|
329
|
+
split() {
|
|
330
|
+
let t = [[], [], [], []],
|
|
331
|
+
e = [[], [], [], []],
|
|
332
|
+
s = [
|
|
333
|
+
[[], []],
|
|
334
|
+
[[], []],
|
|
335
|
+
],
|
|
336
|
+
r = [
|
|
337
|
+
[[], []],
|
|
338
|
+
[[], []],
|
|
339
|
+
];
|
|
340
|
+
for (let s = 0; s < 4; ++s) {
|
|
341
|
+
const r = n(
|
|
342
|
+
this.nodes[0][s],
|
|
343
|
+
this.nodes[1][s],
|
|
344
|
+
this.nodes[2][s],
|
|
345
|
+
this.nodes[3][s],
|
|
346
|
+
);
|
|
347
|
+
((t[0][s] = r[0][0]),
|
|
348
|
+
(t[1][s] = r[0][1]),
|
|
349
|
+
(t[2][s] = r[0][2]),
|
|
350
|
+
(t[3][s] = r[0][3]),
|
|
351
|
+
(e[0][s] = r[1][0]),
|
|
352
|
+
(e[1][s] = r[1][1]),
|
|
353
|
+
(e[2][s] = r[1][2]),
|
|
354
|
+
(e[3][s] = r[1][3]));
|
|
355
|
+
}
|
|
356
|
+
for (let t = 0; t < 4; ++t)
|
|
357
|
+
((s[0][0][t] = this.colors[0][0][t]),
|
|
358
|
+
(s[0][1][t] = this.colors[0][1][t]),
|
|
359
|
+
(s[1][0][t] = (this.colors[0][0][t] + this.colors[1][0][t]) / 2),
|
|
360
|
+
(s[1][1][t] = (this.colors[0][1][t] + this.colors[1][1][t]) / 2),
|
|
361
|
+
(r[0][0][t] = s[1][0][t]),
|
|
362
|
+
(r[0][1][t] = s[1][1][t]),
|
|
363
|
+
(r[1][0][t] = this.colors[1][0][t]),
|
|
364
|
+
(r[1][1][t] = this.colors[1][1][t]));
|
|
365
|
+
return [new m(t, s), new m(e, r)];
|
|
366
|
+
}
|
|
367
|
+
paint(t, e) {
|
|
368
|
+
let s,
|
|
369
|
+
n = !1;
|
|
370
|
+
for (let t = 0; t < 4; ++t)
|
|
371
|
+
if (
|
|
372
|
+
(s = o([
|
|
373
|
+
this.nodes[0][t],
|
|
374
|
+
this.nodes[1][t],
|
|
375
|
+
this.nodes[2][t],
|
|
376
|
+
this.nodes[3][t],
|
|
377
|
+
])) > r
|
|
378
|
+
) {
|
|
379
|
+
n = !0;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
if (n) {
|
|
383
|
+
let s = this.split();
|
|
384
|
+
(s[0].paint(t, e), s[1].paint(t, e));
|
|
385
|
+
} else {
|
|
386
|
+
new w([...this.nodes[0]], [...this.colors[0]]).paintCurve(t, e);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
class b {
|
|
391
|
+
constructor(t) {
|
|
392
|
+
(this.readMesh(t), (this.type = t.getAttribute("type") || "bilinear"));
|
|
393
|
+
}
|
|
394
|
+
readMesh(t) {
|
|
395
|
+
let e = [[]],
|
|
396
|
+
s = [[]],
|
|
397
|
+
r = Number(t.getAttribute("x")),
|
|
398
|
+
n = Number(t.getAttribute("y"));
|
|
399
|
+
e[0][0] = new x(r, n);
|
|
400
|
+
let o = t.children;
|
|
401
|
+
for (let t = 0, r = o.length; t < r; ++t) {
|
|
402
|
+
((e[3 * t + 1] = []),
|
|
403
|
+
(e[3 * t + 2] = []),
|
|
404
|
+
(e[3 * t + 3] = []),
|
|
405
|
+
(s[t + 1] = []));
|
|
406
|
+
let r = o[t].children;
|
|
407
|
+
for (let n = 0, o = r.length; n < o; ++n) {
|
|
408
|
+
let o = r[n].children;
|
|
409
|
+
for (let r = 0, i = o.length; r < i; ++r) {
|
|
410
|
+
let i = r;
|
|
411
|
+
0 !== t && ++i;
|
|
412
|
+
let h,
|
|
413
|
+
d = o[r].getAttribute("path"),
|
|
414
|
+
c = "l";
|
|
415
|
+
null != d && (c = (h = d.match(/\s*([lLcC])\s*(.*)/))[1]);
|
|
416
|
+
let u = l(h[2]);
|
|
417
|
+
switch (c) {
|
|
418
|
+
case "l":
|
|
419
|
+
0 === i
|
|
420
|
+
? ((e[3 * t][3 * n + 3] = u[0].add(e[3 * t][3 * n])),
|
|
421
|
+
(e[3 * t][3 * n + 1] = a(
|
|
422
|
+
e[3 * t][3 * n],
|
|
423
|
+
e[3 * t][3 * n + 3],
|
|
424
|
+
)),
|
|
425
|
+
(e[3 * t][3 * n + 2] = a(
|
|
426
|
+
e[3 * t][3 * n + 3],
|
|
427
|
+
e[3 * t][3 * n],
|
|
428
|
+
)))
|
|
429
|
+
: 1 === i
|
|
430
|
+
? ((e[3 * t + 3][3 * n + 3] = u[0].add(
|
|
431
|
+
e[3 * t][3 * n + 3],
|
|
432
|
+
)),
|
|
433
|
+
(e[3 * t + 1][3 * n + 3] = a(
|
|
434
|
+
e[3 * t][3 * n + 3],
|
|
435
|
+
e[3 * t + 3][3 * n + 3],
|
|
436
|
+
)),
|
|
437
|
+
(e[3 * t + 2][3 * n + 3] = a(
|
|
438
|
+
e[3 * t + 3][3 * n + 3],
|
|
439
|
+
e[3 * t][3 * n + 3],
|
|
440
|
+
)))
|
|
441
|
+
: 2 === i
|
|
442
|
+
? (0 === n &&
|
|
443
|
+
(e[3 * t + 3][3 * n + 0] = u[0].add(
|
|
444
|
+
e[3 * t + 3][3 * n + 3],
|
|
445
|
+
)),
|
|
446
|
+
(e[3 * t + 3][3 * n + 1] = a(
|
|
447
|
+
e[3 * t + 3][3 * n],
|
|
448
|
+
e[3 * t + 3][3 * n + 3],
|
|
449
|
+
)),
|
|
450
|
+
(e[3 * t + 3][3 * n + 2] = a(
|
|
451
|
+
e[3 * t + 3][3 * n + 3],
|
|
452
|
+
e[3 * t + 3][3 * n],
|
|
453
|
+
)))
|
|
454
|
+
: ((e[3 * t + 1][3 * n] = a(
|
|
455
|
+
e[3 * t][3 * n],
|
|
456
|
+
e[3 * t + 3][3 * n],
|
|
457
|
+
)),
|
|
458
|
+
(e[3 * t + 2][3 * n] = a(
|
|
459
|
+
e[3 * t + 3][3 * n],
|
|
460
|
+
e[3 * t][3 * n],
|
|
461
|
+
)));
|
|
462
|
+
break;
|
|
463
|
+
case "L":
|
|
464
|
+
0 === i
|
|
465
|
+
? ((e[3 * t][3 * n + 3] = u[0]),
|
|
466
|
+
(e[3 * t][3 * n + 1] = a(
|
|
467
|
+
e[3 * t][3 * n],
|
|
468
|
+
e[3 * t][3 * n + 3],
|
|
469
|
+
)),
|
|
470
|
+
(e[3 * t][3 * n + 2] = a(
|
|
471
|
+
e[3 * t][3 * n + 3],
|
|
472
|
+
e[3 * t][3 * n],
|
|
473
|
+
)))
|
|
474
|
+
: 1 === i
|
|
475
|
+
? ((e[3 * t + 3][3 * n + 3] = u[0]),
|
|
476
|
+
(e[3 * t + 1][3 * n + 3] = a(
|
|
477
|
+
e[3 * t][3 * n + 3],
|
|
478
|
+
e[3 * t + 3][3 * n + 3],
|
|
479
|
+
)),
|
|
480
|
+
(e[3 * t + 2][3 * n + 3] = a(
|
|
481
|
+
e[3 * t + 3][3 * n + 3],
|
|
482
|
+
e[3 * t][3 * n + 3],
|
|
483
|
+
)))
|
|
484
|
+
: 2 === i
|
|
485
|
+
? (0 === n && (e[3 * t + 3][3 * n + 0] = u[0]),
|
|
486
|
+
(e[3 * t + 3][3 * n + 1] = a(
|
|
487
|
+
e[3 * t + 3][3 * n],
|
|
488
|
+
e[3 * t + 3][3 * n + 3],
|
|
489
|
+
)),
|
|
490
|
+
(e[3 * t + 3][3 * n + 2] = a(
|
|
491
|
+
e[3 * t + 3][3 * n + 3],
|
|
492
|
+
e[3 * t + 3][3 * n],
|
|
493
|
+
)))
|
|
494
|
+
: ((e[3 * t + 1][3 * n] = a(
|
|
495
|
+
e[3 * t][3 * n],
|
|
496
|
+
e[3 * t + 3][3 * n],
|
|
497
|
+
)),
|
|
498
|
+
(e[3 * t + 2][3 * n] = a(
|
|
499
|
+
e[3 * t + 3][3 * n],
|
|
500
|
+
e[3 * t][3 * n],
|
|
501
|
+
)));
|
|
502
|
+
break;
|
|
503
|
+
case "c":
|
|
504
|
+
0 === i
|
|
505
|
+
? ((e[3 * t][3 * n + 1] = u[0].add(e[3 * t][3 * n])),
|
|
506
|
+
(e[3 * t][3 * n + 2] = u[1].add(e[3 * t][3 * n])),
|
|
507
|
+
(e[3 * t][3 * n + 3] = u[2].add(e[3 * t][3 * n])))
|
|
508
|
+
: 1 === i
|
|
509
|
+
? ((e[3 * t + 1][3 * n + 3] = u[0].add(
|
|
510
|
+
e[3 * t][3 * n + 3],
|
|
511
|
+
)),
|
|
512
|
+
(e[3 * t + 2][3 * n + 3] = u[1].add(e[3 * t][3 * n + 3])),
|
|
513
|
+
(e[3 * t + 3][3 * n + 3] = u[2].add(e[3 * t][3 * n + 3])))
|
|
514
|
+
: 2 === i
|
|
515
|
+
? ((e[3 * t + 3][3 * n + 2] = u[0].add(
|
|
516
|
+
e[3 * t + 3][3 * n + 3],
|
|
517
|
+
)),
|
|
518
|
+
(e[3 * t + 3][3 * n + 1] = u[1].add(
|
|
519
|
+
e[3 * t + 3][3 * n + 3],
|
|
520
|
+
)),
|
|
521
|
+
0 === n &&
|
|
522
|
+
(e[3 * t + 3][3 * n + 0] = u[2].add(
|
|
523
|
+
e[3 * t + 3][3 * n + 3],
|
|
524
|
+
)))
|
|
525
|
+
: ((e[3 * t + 2][3 * n] = u[0].add(e[3 * t + 3][3 * n])),
|
|
526
|
+
(e[3 * t + 1][3 * n] = u[1].add(e[3 * t + 3][3 * n])));
|
|
527
|
+
break;
|
|
528
|
+
case "C":
|
|
529
|
+
0 === i
|
|
530
|
+
? ((e[3 * t][3 * n + 1] = u[0]),
|
|
531
|
+
(e[3 * t][3 * n + 2] = u[1]),
|
|
532
|
+
(e[3 * t][3 * n + 3] = u[2]))
|
|
533
|
+
: 1 === i
|
|
534
|
+
? ((e[3 * t + 1][3 * n + 3] = u[0]),
|
|
535
|
+
(e[3 * t + 2][3 * n + 3] = u[1]),
|
|
536
|
+
(e[3 * t + 3][3 * n + 3] = u[2]))
|
|
537
|
+
: 2 === i
|
|
538
|
+
? ((e[3 * t + 3][3 * n + 2] = u[0]),
|
|
539
|
+
(e[3 * t + 3][3 * n + 1] = u[1]),
|
|
540
|
+
0 === n && (e[3 * t + 3][3 * n + 0] = u[2]))
|
|
541
|
+
: ((e[3 * t + 2][3 * n] = u[0]),
|
|
542
|
+
(e[3 * t + 1][3 * n] = u[1]));
|
|
543
|
+
break;
|
|
544
|
+
default:
|
|
545
|
+
console.error("mesh.js: " + c + " invalid path type.");
|
|
546
|
+
}
|
|
547
|
+
if ((0 === t && 0 === n) || r > 0) {
|
|
548
|
+
let e = window
|
|
549
|
+
.getComputedStyle(o[r])
|
|
550
|
+
.stopColor.match(
|
|
551
|
+
/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,
|
|
552
|
+
),
|
|
553
|
+
a = window.getComputedStyle(o[r]).stopOpacity,
|
|
554
|
+
h = 255;
|
|
555
|
+
(a && (h = Math.floor(255 * a)),
|
|
556
|
+
e &&
|
|
557
|
+
(0 === i
|
|
558
|
+
? ((s[t][n] = []),
|
|
559
|
+
(s[t][n][0] = Math.floor(e[1])),
|
|
560
|
+
(s[t][n][1] = Math.floor(e[2])),
|
|
561
|
+
(s[t][n][2] = Math.floor(e[3])),
|
|
562
|
+
(s[t][n][3] = h))
|
|
563
|
+
: 1 === i
|
|
564
|
+
? ((s[t][n + 1] = []),
|
|
565
|
+
(s[t][n + 1][0] = Math.floor(e[1])),
|
|
566
|
+
(s[t][n + 1][1] = Math.floor(e[2])),
|
|
567
|
+
(s[t][n + 1][2] = Math.floor(e[3])),
|
|
568
|
+
(s[t][n + 1][3] = h))
|
|
569
|
+
: 2 === i
|
|
570
|
+
? ((s[t + 1][n + 1] = []),
|
|
571
|
+
(s[t + 1][n + 1][0] = Math.floor(e[1])),
|
|
572
|
+
(s[t + 1][n + 1][1] = Math.floor(e[2])),
|
|
573
|
+
(s[t + 1][n + 1][2] = Math.floor(e[3])),
|
|
574
|
+
(s[t + 1][n + 1][3] = h))
|
|
575
|
+
: 3 === i &&
|
|
576
|
+
((s[t + 1][n] = []),
|
|
577
|
+
(s[t + 1][n][0] = Math.floor(e[1])),
|
|
578
|
+
(s[t + 1][n][1] = Math.floor(e[2])),
|
|
579
|
+
(s[t + 1][n][2] = Math.floor(e[3])),
|
|
580
|
+
(s[t + 1][n][3] = h))));
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
((e[3 * t + 1][3 * n + 1] = new x()),
|
|
584
|
+
(e[3 * t + 1][3 * n + 2] = new x()),
|
|
585
|
+
(e[3 * t + 2][3 * n + 1] = new x()),
|
|
586
|
+
(e[3 * t + 2][3 * n + 2] = new x()),
|
|
587
|
+
(e[3 * t + 1][3 * n + 1].x =
|
|
588
|
+
(-4 * e[3 * t][3 * n].x +
|
|
589
|
+
6 * (e[3 * t][3 * n + 1].x + e[3 * t + 1][3 * n].x) +
|
|
590
|
+
-2 * (e[3 * t][3 * n + 3].x + e[3 * t + 3][3 * n].x) +
|
|
591
|
+
3 * (e[3 * t + 3][3 * n + 1].x + e[3 * t + 1][3 * n + 3].x) +
|
|
592
|
+
-1 * e[3 * t + 3][3 * n + 3].x) /
|
|
593
|
+
9),
|
|
594
|
+
(e[3 * t + 1][3 * n + 2].x =
|
|
595
|
+
(-4 * e[3 * t][3 * n + 3].x +
|
|
596
|
+
6 * (e[3 * t][3 * n + 2].x + e[3 * t + 1][3 * n + 3].x) +
|
|
597
|
+
-2 * (e[3 * t][3 * n].x + e[3 * t + 3][3 * n + 3].x) +
|
|
598
|
+
3 * (e[3 * t + 3][3 * n + 2].x + e[3 * t + 1][3 * n].x) +
|
|
599
|
+
-1 * e[3 * t + 3][3 * n].x) /
|
|
600
|
+
9),
|
|
601
|
+
(e[3 * t + 2][3 * n + 1].x =
|
|
602
|
+
(-4 * e[3 * t + 3][3 * n].x +
|
|
603
|
+
6 * (e[3 * t + 3][3 * n + 1].x + e[3 * t + 2][3 * n].x) +
|
|
604
|
+
-2 * (e[3 * t + 3][3 * n + 3].x + e[3 * t][3 * n].x) +
|
|
605
|
+
3 * (e[3 * t][3 * n + 1].x + e[3 * t + 2][3 * n + 3].x) +
|
|
606
|
+
-1 * e[3 * t][3 * n + 3].x) /
|
|
607
|
+
9),
|
|
608
|
+
(e[3 * t + 2][3 * n + 2].x =
|
|
609
|
+
(-4 * e[3 * t + 3][3 * n + 3].x +
|
|
610
|
+
6 * (e[3 * t + 3][3 * n + 2].x + e[3 * t + 2][3 * n + 3].x) +
|
|
611
|
+
-2 * (e[3 * t + 3][3 * n].x + e[3 * t][3 * n + 3].x) +
|
|
612
|
+
3 * (e[3 * t][3 * n + 2].x + e[3 * t + 2][3 * n].x) +
|
|
613
|
+
-1 * e[3 * t][3 * n].x) /
|
|
614
|
+
9),
|
|
615
|
+
(e[3 * t + 1][3 * n + 1].y =
|
|
616
|
+
(-4 * e[3 * t][3 * n].y +
|
|
617
|
+
6 * (e[3 * t][3 * n + 1].y + e[3 * t + 1][3 * n].y) +
|
|
618
|
+
-2 * (e[3 * t][3 * n + 3].y + e[3 * t + 3][3 * n].y) +
|
|
619
|
+
3 * (e[3 * t + 3][3 * n + 1].y + e[3 * t + 1][3 * n + 3].y) +
|
|
620
|
+
-1 * e[3 * t + 3][3 * n + 3].y) /
|
|
621
|
+
9),
|
|
622
|
+
(e[3 * t + 1][3 * n + 2].y =
|
|
623
|
+
(-4 * e[3 * t][3 * n + 3].y +
|
|
624
|
+
6 * (e[3 * t][3 * n + 2].y + e[3 * t + 1][3 * n + 3].y) +
|
|
625
|
+
-2 * (e[3 * t][3 * n].y + e[3 * t + 3][3 * n + 3].y) +
|
|
626
|
+
3 * (e[3 * t + 3][3 * n + 2].y + e[3 * t + 1][3 * n].y) +
|
|
627
|
+
-1 * e[3 * t + 3][3 * n].y) /
|
|
628
|
+
9),
|
|
629
|
+
(e[3 * t + 2][3 * n + 1].y =
|
|
630
|
+
(-4 * e[3 * t + 3][3 * n].y +
|
|
631
|
+
6 * (e[3 * t + 3][3 * n + 1].y + e[3 * t + 2][3 * n].y) +
|
|
632
|
+
-2 * (e[3 * t + 3][3 * n + 3].y + e[3 * t][3 * n].y) +
|
|
633
|
+
3 * (e[3 * t][3 * n + 1].y + e[3 * t + 2][3 * n + 3].y) +
|
|
634
|
+
-1 * e[3 * t][3 * n + 3].y) /
|
|
635
|
+
9),
|
|
636
|
+
(e[3 * t + 2][3 * n + 2].y =
|
|
637
|
+
(-4 * e[3 * t + 3][3 * n + 3].y +
|
|
638
|
+
6 * (e[3 * t + 3][3 * n + 2].y + e[3 * t + 2][3 * n + 3].y) +
|
|
639
|
+
-2 * (e[3 * t + 3][3 * n].y + e[3 * t][3 * n + 3].y) +
|
|
640
|
+
3 * (e[3 * t][3 * n + 2].y + e[3 * t + 2][3 * n].y) +
|
|
641
|
+
-1 * e[3 * t][3 * n].y) /
|
|
642
|
+
9));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
((this.nodes = e), (this.colors = s));
|
|
646
|
+
}
|
|
647
|
+
paintMesh(t, e) {
|
|
648
|
+
let s = (this.nodes.length - 1) / 3,
|
|
649
|
+
r = (this.nodes[0].length - 1) / 3;
|
|
650
|
+
if ("bilinear" === this.type || s < 2 || r < 2) {
|
|
651
|
+
let n;
|
|
652
|
+
for (let o = 0; o < s; ++o)
|
|
653
|
+
for (let s = 0; s < r; ++s) {
|
|
654
|
+
let r = [];
|
|
655
|
+
for (let t = 3 * o, e = 3 * o + 4; t < e; ++t)
|
|
656
|
+
r.push(this.nodes[t].slice(3 * s, 3 * s + 4));
|
|
657
|
+
let i = [];
|
|
658
|
+
(i.push(this.colors[o].slice(s, s + 2)),
|
|
659
|
+
i.push(this.colors[o + 1].slice(s, s + 2)),
|
|
660
|
+
(n = new m(r, i)).paint(t, e));
|
|
661
|
+
}
|
|
662
|
+
} else {
|
|
663
|
+
let n, o, a, h, l, d, u;
|
|
664
|
+
const x = s,
|
|
665
|
+
g = r;
|
|
666
|
+
(s++, r++);
|
|
667
|
+
let w = new Array(s);
|
|
668
|
+
for (let t = 0; t < s; ++t) {
|
|
669
|
+
w[t] = new Array(r);
|
|
670
|
+
for (let e = 0; e < r; ++e)
|
|
671
|
+
((w[t][e] = []),
|
|
672
|
+
(w[t][e][0] = this.nodes[3 * t][3 * e]),
|
|
673
|
+
(w[t][e][1] = this.colors[t][e]));
|
|
674
|
+
}
|
|
675
|
+
for (let t = 0; t < s; ++t)
|
|
676
|
+
for (let e = 0; e < r; ++e)
|
|
677
|
+
(0 !== t &&
|
|
678
|
+
t !== x &&
|
|
679
|
+
((n = i(w[t - 1][e][0], w[t][e][0])),
|
|
680
|
+
(o = i(w[t + 1][e][0], w[t][e][0])),
|
|
681
|
+
(w[t][e][2] = c(
|
|
682
|
+
w[t - 1][e][1],
|
|
683
|
+
w[t][e][1],
|
|
684
|
+
w[t + 1][e][1],
|
|
685
|
+
n,
|
|
686
|
+
o,
|
|
687
|
+
))),
|
|
688
|
+
0 !== e &&
|
|
689
|
+
e !== g &&
|
|
690
|
+
((n = i(w[t][e - 1][0], w[t][e][0])),
|
|
691
|
+
(o = i(w[t][e + 1][0], w[t][e][0])),
|
|
692
|
+
(w[t][e][3] = c(
|
|
693
|
+
w[t][e - 1][1],
|
|
694
|
+
w[t][e][1],
|
|
695
|
+
w[t][e + 1][1],
|
|
696
|
+
n,
|
|
697
|
+
o,
|
|
698
|
+
))));
|
|
699
|
+
for (let t = 0; t < r; ++t) {
|
|
700
|
+
((w[0][t][2] = []), (w[x][t][2] = []));
|
|
701
|
+
for (let e = 0; e < 4; ++e)
|
|
702
|
+
((n = i(w[1][t][0], w[0][t][0])),
|
|
703
|
+
(o = i(w[x][t][0], w[x - 1][t][0])),
|
|
704
|
+
(w[0][t][2][e] =
|
|
705
|
+
n > 0
|
|
706
|
+
? (2 * (w[1][t][1][e] - w[0][t][1][e])) / n - w[1][t][2][e]
|
|
707
|
+
: 0),
|
|
708
|
+
(w[x][t][2][e] =
|
|
709
|
+
o > 0
|
|
710
|
+
? (2 * (w[x][t][1][e] - w[x - 1][t][1][e])) / o -
|
|
711
|
+
w[x - 1][t][2][e]
|
|
712
|
+
: 0));
|
|
713
|
+
}
|
|
714
|
+
for (let t = 0; t < s; ++t) {
|
|
715
|
+
((w[t][0][3] = []), (w[t][g][3] = []));
|
|
716
|
+
for (let e = 0; e < 4; ++e)
|
|
717
|
+
((n = i(w[t][1][0], w[t][0][0])),
|
|
718
|
+
(o = i(w[t][g][0], w[t][g - 1][0])),
|
|
719
|
+
(w[t][0][3][e] =
|
|
720
|
+
n > 0
|
|
721
|
+
? (2 * (w[t][1][1][e] - w[t][0][1][e])) / n - w[t][1][3][e]
|
|
722
|
+
: 0),
|
|
723
|
+
(w[t][g][3][e] =
|
|
724
|
+
o > 0
|
|
725
|
+
? (2 * (w[t][g][1][e] - w[t][g - 1][1][e])) / o -
|
|
726
|
+
w[t][g - 1][3][e]
|
|
727
|
+
: 0));
|
|
728
|
+
}
|
|
729
|
+
for (let s = 0; s < x; ++s)
|
|
730
|
+
for (let r = 0; r < g; ++r) {
|
|
731
|
+
let n = i(w[s][r][0], w[s + 1][r][0]),
|
|
732
|
+
o = i(w[s][r + 1][0], w[s + 1][r + 1][0]),
|
|
733
|
+
c = i(w[s][r][0], w[s][r + 1][0]),
|
|
734
|
+
x = i(w[s + 1][r][0], w[s + 1][r + 1][0]),
|
|
735
|
+
g = [[], [], [], []];
|
|
736
|
+
for (let t = 0; t < 4; ++t) {
|
|
737
|
+
(((d = [])[0] = w[s][r][1][t]),
|
|
738
|
+
(d[1] = w[s + 1][r][1][t]),
|
|
739
|
+
(d[2] = w[s][r + 1][1][t]),
|
|
740
|
+
(d[3] = w[s + 1][r + 1][1][t]),
|
|
741
|
+
(d[4] = w[s][r][2][t] * n),
|
|
742
|
+
(d[5] = w[s + 1][r][2][t] * n),
|
|
743
|
+
(d[6] = w[s][r + 1][2][t] * o),
|
|
744
|
+
(d[7] = w[s + 1][r + 1][2][t] * o),
|
|
745
|
+
(d[8] = w[s][r][3][t] * c),
|
|
746
|
+
(d[9] = w[s + 1][r][3][t] * x),
|
|
747
|
+
(d[10] = w[s][r + 1][3][t] * c),
|
|
748
|
+
(d[11] = w[s + 1][r + 1][3][t] * x),
|
|
749
|
+
(d[12] = 0),
|
|
750
|
+
(d[13] = 0),
|
|
751
|
+
(d[14] = 0),
|
|
752
|
+
(d[15] = 0),
|
|
753
|
+
(u = f(d)));
|
|
754
|
+
for (let e = 0; e < 9; ++e) {
|
|
755
|
+
g[t][e] = [];
|
|
756
|
+
for (let s = 0; s < 9; ++s)
|
|
757
|
+
((g[t][e][s] = p(u, e / 8, s / 8)),
|
|
758
|
+
g[t][e][s] > 255
|
|
759
|
+
? (g[t][e][s] = 255)
|
|
760
|
+
: g[t][e][s] < 0 && (g[t][e][s] = 0));
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
h = [];
|
|
764
|
+
for (let t = 3 * s, e = 3 * s + 4; t < e; ++t)
|
|
765
|
+
h.push(this.nodes[t].slice(3 * r, 3 * r + 4));
|
|
766
|
+
l = y(h);
|
|
767
|
+
for (let s = 0; s < 8; ++s)
|
|
768
|
+
for (let r = 0; r < 8; ++r)
|
|
769
|
+
(a = new m(l[s][r], [
|
|
770
|
+
[
|
|
771
|
+
[g[0][s][r], g[1][s][r], g[2][s][r], g[3][s][r]],
|
|
772
|
+
[
|
|
773
|
+
g[0][s][r + 1],
|
|
774
|
+
g[1][s][r + 1],
|
|
775
|
+
g[2][s][r + 1],
|
|
776
|
+
g[3][s][r + 1],
|
|
777
|
+
],
|
|
778
|
+
],
|
|
779
|
+
[
|
|
780
|
+
[
|
|
781
|
+
g[0][s + 1][r],
|
|
782
|
+
g[1][s + 1][r],
|
|
783
|
+
g[2][s + 1][r],
|
|
784
|
+
g[3][s + 1][r],
|
|
785
|
+
],
|
|
786
|
+
[
|
|
787
|
+
g[0][s + 1][r + 1],
|
|
788
|
+
g[1][s + 1][r + 1],
|
|
789
|
+
g[2][s + 1][r + 1],
|
|
790
|
+
g[3][s + 1][r + 1],
|
|
791
|
+
],
|
|
792
|
+
],
|
|
793
|
+
])).paint(t, e);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
transform(t) {
|
|
798
|
+
if (t instanceof x)
|
|
799
|
+
for (let e = 0, s = this.nodes.length; e < s; ++e)
|
|
800
|
+
for (let s = 0, r = this.nodes[0].length; s < r; ++s)
|
|
801
|
+
this.nodes[e][s] = this.nodes[e][s].add(t);
|
|
802
|
+
else if (t instanceof g)
|
|
803
|
+
for (let e = 0, s = this.nodes.length; e < s; ++e)
|
|
804
|
+
for (let s = 0, r = this.nodes[0].length; s < r; ++s)
|
|
805
|
+
this.nodes[e][s] = this.nodes[e][s].transform(t);
|
|
806
|
+
}
|
|
807
|
+
scale(t) {
|
|
808
|
+
for (let e = 0, s = this.nodes.length; e < s; ++e)
|
|
809
|
+
for (let s = 0, r = this.nodes[0].length; s < r; ++s)
|
|
810
|
+
this.nodes[e][s] = this.nodes[e][s].scale(t);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
document.querySelectorAll("rect,circle,ellipse,path,text").forEach((r, n) => {
|
|
814
|
+
let o = r.getAttribute("id");
|
|
815
|
+
o || ((o = "patchjs_shape" + n), r.setAttribute("id", o));
|
|
816
|
+
const i = r.style.fill.match(/^url\(\s*"?\s*#([^\s"]+)"?\s*\)/),
|
|
817
|
+
a = r.style.stroke.match(/^url\(\s*"?\s*#([^\s"]+)"?\s*\)/);
|
|
818
|
+
if (i && i[1]) {
|
|
819
|
+
const a = document.getElementById(i[1]);
|
|
820
|
+
if (a && "meshgradient" === a.nodeName) {
|
|
821
|
+
const i = r.getBBox();
|
|
822
|
+
let l = document.createElementNS(s, "canvas");
|
|
823
|
+
d(l, { width: i.width, height: i.height });
|
|
824
|
+
const c = l.getContext("2d");
|
|
825
|
+
let u = c.createImageData(i.width, i.height);
|
|
826
|
+
const f = new b(a);
|
|
827
|
+
"objectBoundingBox" === a.getAttribute("gradientUnits") &&
|
|
828
|
+
f.scale(new x(i.width, i.height));
|
|
829
|
+
const p = a.getAttribute("gradientTransform");
|
|
830
|
+
(null != p && f.transform(h(p)),
|
|
831
|
+
"userSpaceOnUse" === a.getAttribute("gradientUnits") &&
|
|
832
|
+
f.transform(new x(-i.x, -i.y)),
|
|
833
|
+
f.paintMesh(u.data, l.width),
|
|
834
|
+
c.putImageData(u, 0, 0));
|
|
835
|
+
const y = document.createElementNS(t, "image");
|
|
836
|
+
d(y, { width: i.width, height: i.height, x: i.x, y: i.y });
|
|
837
|
+
let g = l.toDataURL();
|
|
838
|
+
(y.setAttributeNS(e, "xlink:href", g),
|
|
839
|
+
r.parentNode.insertBefore(y, r),
|
|
840
|
+
(r.style.fill = "none"));
|
|
841
|
+
const w = document.createElementNS(t, "use");
|
|
842
|
+
w.setAttributeNS(e, "xlink:href", "#" + o);
|
|
843
|
+
const m = "patchjs_clip" + n,
|
|
844
|
+
M = document.createElementNS(t, "clipPath");
|
|
845
|
+
(M.setAttribute("id", m),
|
|
846
|
+
M.appendChild(w),
|
|
847
|
+
r.parentElement.insertBefore(M, r),
|
|
848
|
+
y.setAttribute("clip-path", "url(#" + m + ")"),
|
|
849
|
+
(u = null),
|
|
850
|
+
(l = null),
|
|
851
|
+
(g = null));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
if (a && a[1]) {
|
|
855
|
+
const o = document.getElementById(a[1]);
|
|
856
|
+
if (o && "meshgradient" === o.nodeName) {
|
|
857
|
+
const i =
|
|
858
|
+
parseFloat(r.style.strokeWidth.slice(0, -2)) *
|
|
859
|
+
(parseFloat(r.style.strokeMiterlimit) ||
|
|
860
|
+
parseFloat(r.getAttribute("stroke-miterlimit")) ||
|
|
861
|
+
1),
|
|
862
|
+
a = r.getBBox(),
|
|
863
|
+
l = Math.trunc(a.width + i),
|
|
864
|
+
c = Math.trunc(a.height + i),
|
|
865
|
+
u = Math.trunc(a.x - i / 2),
|
|
866
|
+
f = Math.trunc(a.y - i / 2);
|
|
867
|
+
let p = document.createElementNS(s, "canvas");
|
|
868
|
+
d(p, { width: l, height: c });
|
|
869
|
+
const y = p.getContext("2d");
|
|
870
|
+
let g = y.createImageData(l, c);
|
|
871
|
+
const w = new b(o);
|
|
872
|
+
"objectBoundingBox" === o.getAttribute("gradientUnits") &&
|
|
873
|
+
w.scale(new x(l, c));
|
|
874
|
+
const m = o.getAttribute("gradientTransform");
|
|
875
|
+
(null != m && w.transform(h(m)),
|
|
876
|
+
"userSpaceOnUse" === o.getAttribute("gradientUnits") &&
|
|
877
|
+
w.transform(new x(-u, -f)),
|
|
878
|
+
w.paintMesh(g.data, p.width),
|
|
879
|
+
y.putImageData(g, 0, 0));
|
|
880
|
+
const M = document.createElementNS(t, "image");
|
|
881
|
+
d(M, { width: l, height: c, x: 0, y: 0 });
|
|
882
|
+
let S = p.toDataURL();
|
|
883
|
+
M.setAttributeNS(e, "xlink:href", S);
|
|
884
|
+
const k = "pattern_clip" + n,
|
|
885
|
+
A = document.createElementNS(t, "pattern");
|
|
886
|
+
(d(A, {
|
|
887
|
+
id: k,
|
|
888
|
+
patternUnits: "userSpaceOnUse",
|
|
889
|
+
width: l,
|
|
890
|
+
height: c,
|
|
891
|
+
x: u,
|
|
892
|
+
y: f,
|
|
893
|
+
}),
|
|
894
|
+
A.appendChild(M),
|
|
895
|
+
o.parentNode.appendChild(A),
|
|
896
|
+
(r.style.stroke = "url(#" + k + ")"),
|
|
897
|
+
(g = null),
|
|
898
|
+
(p = null),
|
|
899
|
+
(S = null));
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
})();
|