@antv/g-canvas 2.0.51 → 2.1.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/README.md +3 -3
- package/dist/index.esm.js +2643 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2651 -38
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +8 -31
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +7 -11
- package/types/index.d.ts +7 -8
- package/types/index.d.ts.map +1 -1
- package/types/plugins/canvas-renderer/CanvasRendererPlugin.d.ts +55 -0
- package/types/plugins/canvas-renderer/CanvasRendererPlugin.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/index.d.ts +17 -0
- package/types/plugins/canvas-renderer/index.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/interfaces.d.ts +5 -0
- package/types/plugins/canvas-renderer/interfaces.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/Default.d.ts +14 -0
- package/types/plugins/canvas-renderer/shapes/styles/Default.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/Image.d.ts +19 -0
- package/types/plugins/canvas-renderer/shapes/styles/Image.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/OptimizedDefault.d.ts +37 -0
- package/types/plugins/canvas-renderer/shapes/styles/OptimizedDefault.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/Text.d.ts +19 -0
- package/types/plugins/canvas-renderer/shapes/styles/Text.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/helper.d.ts +5 -0
- package/types/plugins/canvas-renderer/shapes/styles/helper.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/index.d.ts +13 -0
- package/types/plugins/canvas-renderer/shapes/styles/index.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/shapes/styles/interfaces.d.ts +8 -0
- package/types/plugins/canvas-renderer/shapes/styles/interfaces.d.ts.map +1 -0
- package/types/plugins/canvas-renderer/utils/math.d.ts +8 -0
- package/types/plugins/canvas-renderer/utils/math.d.ts.map +1 -0
- package/types/plugins/path-generator/index.d.ts +11 -0
- package/types/plugins/path-generator/index.d.ts.map +1 -0
- package/types/plugins/path-generator/interfaces.d.ts +6 -0
- package/types/plugins/path-generator/interfaces.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Circle.d.ts +3 -0
- package/types/plugins/path-generator/paths/Circle.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Ellipse.d.ts +3 -0
- package/types/plugins/path-generator/paths/Ellipse.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Line.d.ts +3 -0
- package/types/plugins/path-generator/paths/Line.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Path.d.ts +3 -0
- package/types/plugins/path-generator/paths/Path.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Polygon.d.ts +3 -0
- package/types/plugins/path-generator/paths/Polygon.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Polyline.d.ts +3 -0
- package/types/plugins/path-generator/paths/Polyline.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/Rect.d.ts +3 -0
- package/types/plugins/path-generator/paths/Rect.d.ts.map +1 -0
- package/types/plugins/path-generator/paths/index.d.ts +8 -0
- package/types/plugins/path-generator/paths/index.d.ts.map +1 -0
- package/types/plugins/picker/CanvasPickerPlugin.d.ts +23 -0
- package/types/plugins/picker/CanvasPickerPlugin.d.ts.map +1 -0
- package/types/plugins/picker/Circle.d.ts +3 -0
- package/types/plugins/picker/Circle.d.ts.map +1 -0
- package/types/plugins/picker/Ellipse.d.ts +3 -0
- package/types/plugins/picker/Ellipse.d.ts.map +1 -0
- package/types/plugins/picker/Image.d.ts +3 -0
- package/types/plugins/picker/Image.d.ts.map +1 -0
- package/types/plugins/picker/Line.d.ts +3 -0
- package/types/plugins/picker/Line.d.ts.map +1 -0
- package/types/plugins/picker/Path.d.ts +3 -0
- package/types/plugins/picker/Path.d.ts.map +1 -0
- package/types/plugins/picker/Polygon.d.ts +3 -0
- package/types/plugins/picker/Polygon.d.ts.map +1 -0
- package/types/plugins/picker/Polyline.d.ts +3 -0
- package/types/plugins/picker/Polyline.d.ts.map +1 -0
- package/types/plugins/picker/Rect.d.ts +4 -0
- package/types/plugins/picker/Rect.d.ts.map +1 -0
- package/types/plugins/picker/Text.d.ts +3 -0
- package/types/plugins/picker/Text.d.ts.map +1 -0
- package/types/plugins/picker/index.d.ts +7 -0
- package/types/plugins/picker/index.d.ts.map +1 -0
- package/types/plugins/picker/utils/math.d.ts +8 -0
- package/types/plugins/picker/utils/math.d.ts.map +1 -0
package/dist/index.umd.min.js
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g-canvas
|
|
3
3
|
* @description A renderer implemented by Canvas 2D API
|
|
4
|
-
* @version 2.0
|
|
5
|
-
* @date 12/
|
|
4
|
+
* @version 2.1.0
|
|
5
|
+
* @date 12/22/2025, 3:03:16 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
9
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.Canvas2D={}),e.window.G)}(this,function(e,t){"use strict";function n(e){return n="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},n(e)}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function a(e,t){for(var n=0;t.length>n;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,r(a.key),a)}}function i(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function c(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t,n){return t=l(t),c(e,s()?Reflect.construct(t,n||[],l(e).constructor):t.apply(e,n))}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function f(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);t>n;n++)r[n]=e[n];return r}function p(e,t){if(e){if("string"==typeof e)return v(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,l=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return l}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return null==e}function g(e){return"string"==typeof e}var b=function(e,t,n){return t>e?t:e>n?n:e};function S(e){return"number"==typeof e}var x="undefined"!=typeof Float32Array?Float32Array:Array;function k(){var e=new x(16);return x!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function E(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],l=t[4],s=t[5],c=t[6],u=t[7],h=t[8],d=t[9],f=t[10],v=t[11],p=t[12],y=t[13],m=t[14],g=t[15],b=n[0],S=n[1],x=n[2],k=n[3];return e[0]=b*r+S*l+x*h+k*p,e[1]=b*a+S*s+x*d+k*y,e[2]=b*i+S*c+x*f+k*m,e[3]=b*o+S*u+x*v+k*g,e[4]=(b=n[4])*r+(S=n[5])*l+(x=n[6])*h+(k=n[7])*p,e[5]=b*a+S*s+x*d+k*y,e[6]=b*i+S*c+x*f+k*m,e[7]=b*o+S*u+x*v+k*g,e[8]=(b=n[8])*r+(S=n[9])*l+(x=n[10])*h+(k=n[11])*p,e[9]=b*a+S*s+x*d+k*y,e[10]=b*i+S*c+x*f+k*m,e[11]=b*o+S*u+x*v+k*g,e[12]=(b=n[12])*r+(S=n[13])*l+(x=n[14])*h+(k=n[15])*p,e[13]=b*a+S*s+x*d+k*y,e[14]=b*i+S*c+x*f+k*m,e[15]=b*o+S*u+x*v+k*g,e}function M(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function C(){var e=new x(3);return x!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function O(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e}function T(e,t,n){var r=t[0],a=t[1],i=t[2],o=n[3]*r+n[7]*a+n[11]*i+n[15];return e[0]=(n[0]*r+n[4]*a+n[8]*i+n[12])/(o=o||1),e[1]=(n[1]*r+n[5]*a+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*a+n[10]*i+n[14])/o,e}function A(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function P(e,t,n,r,a,i,o,l,s,c){var u,h,d,f,v,p=e,y=t,m=n,g=r,b=l,S=s,x=120*Math.PI/180,k=Math.PI/180*(+a||0),w=[];if(c)h=c[0],d=c[1],f=c[2],v=c[3];else{y=(u=A(p,y,-k)).y;var E=((p=u.x)-(b=(u=A(b,S,-k)).x))/2,M=(y-(S=u.y))/2,C=E*E/(m*m)+M*M/(g*g);C>1&&(m*=C=Math.sqrt(C),g*=C);var O=m*m,T=g*g,R=(i===o?-1:1)*Math.sqrt(Math.abs((O*T-O*M*M-T*E*E)/(O*M*M+T*E*E)));f=R*m*M/g+(p+b)/2,h=Math.asin(((y-(v=R*-g*E/m+(y+S)/2))/g*1e9|0)/1e9),d=Math.asin(((S-v)/g*1e9|0)/1e9),0>(h=f>p?Math.PI-h:h)&&(h=2*Math.PI+h),0>(d=f>b?Math.PI-d:d)&&(d=2*Math.PI+d),o&&h>d&&(h-=2*Math.PI),!o&&d>h&&(d-=2*Math.PI)}var L=d-h;if(Math.abs(L)>x){var D=d,I=b,N=S;w=P(b=f+m*Math.cos(d=h+x*(o&&d>h?1:-1)),S=v+g*Math.sin(d),m,g,a,0,o,I,N,[d,D,f,v])}L=d-h;var j=Math.cos(h),F=Math.sin(h),B=Math.cos(d),G=Math.sin(d),_=Math.tan(L/4),W=4/3*m*_,H=4/3*g*_,z=[p,y],$=[p+W*F,y-H*j],U=[b+W*G,S-H*B],Y=[b,S];if($[0]=2*z[0]-$[0],$[1]=2*z[1]-$[1],c)return $.concat(U,Y,w);for(var V=[],X=0,q=(w=$.concat(U,Y,w)).length;q>X;X+=1)V[X]=X%2?A(w[X-1],w[X],k).y:A(w[X],w[X+1],k).x;return V}
|
|
10
|
-
/*!
|
|
11
|
-
* @antv/g-plugin-canvas-path-generator
|
|
12
|
-
* @description A G plugin of path generator with Canvas2D API
|
|
13
|
-
* @version 2.1.25
|
|
14
|
-
* @date 12/10/2025, 8:43:23 AM
|
|
15
|
-
* @author AntVis
|
|
16
|
-
* @docs https://g.antv.antgroup.com/
|
|
17
|
-
*/function R(e,t){var n=t.cx,r=t.cy;e.arc(void 0===n?0:n,void 0===r?0:r,t.r,0,2*Math.PI,!1)}function L(e,t){var n=t.cx,r=void 0===n?0:n,a=t.cy,i=void 0===a?0:a,o=t.rx,l=t.ry;if(e.ellipse)e.ellipse(r,i,o,l,0,0,2*Math.PI,!1);else{var s=o>l?o:l,c=o>l?1:o/l,u=o>l?l/o:1;e.save(),e.scale(c,u),e.arc(r,i,s,0,2*Math.PI)}}function D(e,n){var r=n.x1,a=n.y1,i=n.x2,o=n.y2,l=n.markerStart,s=n.markerEnd,c=n.markerStartOffset,u=n.markerEndOffset,h=0,d=0,f=0,v=0,p=0;l&&t.isDisplayObject(l)&&c&&(h=Math.cos(p=Math.atan2(o-a,i-r))*(c||0),d=Math.sin(p)*(c||0)),s&&t.isDisplayObject(s)&&u&&(f=Math.cos(p=Math.atan2(a-o,r-i))*(u||0),v=Math.sin(p)*(u||0)),e.moveTo(r+h,a+d),e.lineTo(i+f,o+v)}function I(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.d,s=l.absolutePath,c=l.segments,u=0,h=0,d=0,f=0,v=0;if(r&&t.isDisplayObject(r)&&i){var p=y(r.parentNode.getStartTangent(),2),m=p[0],g=p[1];u=Math.cos(v=Math.atan2(m[1]-g[1],m[0]-g[0]))*(i||0),h=Math.sin(v)*(i||0)}if(a&&t.isDisplayObject(a)&&o){var b=y(a.parentNode.getEndTangent(),2),S=b[0],x=b[1];d=Math.cos(v=Math.atan2(S[1]-x[1],S[0]-x[0]))*(o||0),f=Math.sin(v)*(o||0)}for(var k=0;s.length>k;k++){var w=s[k],E=w[0],M=s[k+1],C=(k===s.length-1||M&&("M"===M[0]||"Z"===M[0]))&&0!==d&&0!==f,O=y(0===k&&(0!==u||0!==h)?[u,h]:[0,0],2),T=O[0],A=O[1],P=y(C?[d,f]:[0,0],2),R=P[0],L=P[1];switch(E){case"M":e.moveTo(w[1]+T,w[2]+A);break;case"L":e.lineTo(w[1]+R,w[2]+L);break;case"Q":e.quadraticCurveTo(w[1],w[2],w[3]+R,w[4]+L);break;case"C":e.bezierCurveTo(w[1],w[2],w[3],w[4],w[5]+R,w[6]+L);break;case"A":var D=c[k].arcParams,I=D.cx,N=D.cy,j=D.rx,F=D.ry,B=D.startAngle,G=D.endAngle,_=D.xRotation,W=D.sweepFlag;if(e.ellipse)e.ellipse(I,N,j,F,_,B,G,!!(1-W));else{var H=j>F?j:F,z=j>F?1:j/F,$=j>F?F/j:1;e.translate(I,N),e.rotate(_),e.scale(z,$),e.arc(0,0,H,B,G,!!(1-W)),e.scale(1/z,1/$),e.rotate(-_),e.translate(-I,-N)}C&&e.lineTo(w[6]+d,w[7]+f);break;case"Z":e.closePath()}}}function N(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],d=l[s-1][1],f=0,v=0,p=0,y=0,m=0;r&&t.isDisplayObject(r)&&i&&(f=Math.cos(m=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(m)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(m=Math.atan2(l[s-1][1]-l[0][1],l[s-1][0]-l[0][0]))*(o||0),y=Math.sin(m)*(o||0)),e.moveTo(c+(f||p),u+(v||y));for(var g=1;s-1>g;g++){var b=l[g];e.lineTo(b[0],b[1])}e.lineTo(h,d)}function j(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],d=l[s-1][1],f=0,v=0,p=0,y=0,m=0;r&&t.isDisplayObject(r)&&i&&(f=Math.cos(m=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(m)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(m=Math.atan2(l[s-2][1]-l[s-1][1],l[s-2][0]-l[s-1][0]))*(o||0),y=Math.sin(m)*(o||0)),e.moveTo(c+f,u+v);for(var g=1;s-1>g;g++){var b=l[g];e.lineTo(b[0],b[1])}e.lineTo(h+p,d+y)}function F(e,t){var n=t.x,r=void 0===n?0:n,a=t.y,i=void 0===a?0:a,o=t.radius,l=t.width,s=t.height,c=l,u=s;if(o&&o.some(function(e){return 0!==e})){var h=l>0?1:-1,d=s>0?1:-1,f=h+d===0,v=y(o.map(function(e){return b(e,0,Math.min(Math.abs(c)/2,Math.abs(u)/2))}),4),p=v[0],m=v[1],g=v[2],S=v[3];e.moveTo(h*p+r,i),e.lineTo(c-h*m+r,i),0!==m&&e.arc(c-h*m+r,d*m+i,m,-d*Math.PI/2,h>0?0:Math.PI,f),e.lineTo(c+r,u-d*g+i),0!==g&&e.arc(c-h*g+r,u-d*g+i,g,h>0?0:Math.PI,d>0?Math.PI/2:1.5*Math.PI,f),e.lineTo(h*S+r,u+i),0!==S&&e.arc(h*S+r,u-d*S+i,S,d>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,f),e.lineTo(r,d*p+i),0!==p&&e.arc(h*p+r,d*p+i,p,h>0?Math.PI:0,d>0?1.5*Math.PI:Math.PI/2,f)}else e.rect(r,i,c,u)}C(),function(){var e,t=(e=new x(2),x!=Float32Array&&(e[0]=0,e[1]=0),e)}();var B=function(e){function n(){var e;o(this,n);for(var t=arguments.length,r=Array(t),a=0;t>a;a++)r[a]=arguments[a];return(e=u(this,n,[].concat(r))).name="canvas-path-generator",e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,R),t.Shape.ELLIPSE,L),t.Shape.RECT,F),t.Shape.LINE,D),t.Shape.POLYLINE,j),t.Shape.POLYGON,N),t.Shape.PATH,I),t.Shape.TEXT,void 0),t.Shape.GROUP,void 0),t.Shape.IMAGE,void 0),f(f(f(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.pathGeneratorFactory=n}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(t.AbstractRendererPlugin),G=Object.freeze({__proto__:null,Plugin:B});function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return e.length>r?{done:!1,value:e[r++]}:{done:!0}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){l=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw i}}}}function W(e,t){this.v=e,this.k=t}function H(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}H=function(e,t,n,r){function i(t,n){H(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},H(e,t,n,r)}function z(){
|
|
9
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.Canvas2D={}),e.window.G)}(this,function(e,t){"use strict";function r(e){return r="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},r(e)}function n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function i(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}function s(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t,r){return t=l(t),s(e,c()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach(function(t){d(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function g(e,t){if(e){if("string"==typeof e)return y(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,l=[],c=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){s=!0,i=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw i}}return l}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var S=0;function w(e){return"__private_"+S+++"_"+e}var M="undefined"!=typeof Float32Array?Float32Array:Array;function k(){var e=new M(16);return M!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function O(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function C(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],c=t[5],s=t[6],u=t[7],h=t[8],f=t[9],d=t[10],v=t[11],p=t[12],y=t[13],g=t[14],m=t[15],b=r[0],x=r[1],S=r[2],w=r[3];return e[0]=b*n+x*l+S*h+w*p,e[1]=b*i+x*c+S*f+w*y,e[2]=b*a+x*s+S*d+w*g,e[3]=b*o+x*u+S*v+w*m,e[4]=(b=r[4])*n+(x=r[5])*l+(S=r[6])*h+(w=r[7])*p,e[5]=b*i+x*c+S*f+w*y,e[6]=b*a+x*s+S*d+w*g,e[7]=b*o+x*u+S*v+w*m,e[8]=(b=r[8])*n+(x=r[9])*l+(S=r[10])*h+(w=r[11])*p,e[9]=b*i+x*c+S*f+w*y,e[10]=b*a+x*s+S*d+w*g,e[11]=b*o+x*u+S*v+w*m,e[12]=(b=r[12])*n+(x=r[13])*l+(S=r[14])*h+(w=r[15])*p,e[13]=b*i+x*c+S*f+w*y,e[14]=b*a+x*s+S*d+w*g,e[15]=b*o+x*u+S*v+w*m,e}function P(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function T(){var e=new M(3);return M!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function A(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function E(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/(o=o||1),e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e}function R(e){return null==e}T(),function(){var e,t=(e=new M(2),M!=Float32Array&&(e[0]=0,e[1]=0),e)}();var D=function(e,t,r){return t>e?t:e>r?r:e};function L(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function I(e,t,r,n,i,a,o,l,c,s){var u,h,f,d,v,p=e,y=t,g=r,m=n,b=l,x=c,S=120*Math.PI/180,w=Math.PI/180*(+i||0),M=[];if(s)h=s[0],f=s[1],d=s[2],v=s[3];else{y=(u=L(p,y,-w)).y;var k=((p=u.x)-(b=(u=L(b,x,-w)).x))/2,O=(y-(x=u.y))/2,C=k*k/(g*g)+O*O/(m*m);C>1&&(g*=C=Math.sqrt(C),m*=C);var P=g*g,T=m*m,A=(a===o?-1:1)*Math.sqrt(Math.abs((P*T-P*O*O-T*k*k)/(P*O*O+T*k*k)));d=A*g*O/m+(p+b)/2,h=Math.asin(((y-(v=A*-m*k/g+(y+x)/2))/m*1e9|0)/1e9),f=Math.asin(((x-v)/m*1e9|0)/1e9),0>(h=d>p?Math.PI-h:h)&&(h=2*Math.PI+h),0>(f=d>b?Math.PI-f:f)&&(f=2*Math.PI+f),o&&h>f&&(h-=2*Math.PI),!o&&f>h&&(f-=2*Math.PI)}var E=f-h;if(Math.abs(E)>S){var R=f,D=b,j=x;M=I(b=d+g*Math.cos(f=h+S*(o&&f>h?1:-1)),x=v+m*Math.sin(f),g,m,i,0,o,D,j,[f,R,d,v])}E=f-h;var F=Math.cos(h),B=Math.sin(h),N=Math.cos(f),G=Math.sin(f),W=Math.tan(E/4),_=4/3*g*W,H=4/3*m*W,$=[p,y],Y=[p+_*B,y-H*F],z=[b+_*G,x-H*N],X=[b,x];if(Y[0]=2*$[0]-Y[0],Y[1]=2*$[1]-Y[1],s)return Y.concat(z,X,M);for(var U=[],q=0,V=(M=Y.concat(z,X,M)).length;V>q;q+=1)U[q]=q%2?L(M[q-1],M[q],w).y:L(M[q],M[q+1],w).x;return U}var j=w("renderState"),F=function(){function e(t){o(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,j,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=k(),this.dprMatrix=k(),this.tmpMat4=k(),this.vec3a=T(),this.vec3b=T(),this.vec3c=T(),this.vec3d=T(),this.canvasRendererPluginOptions=t}return a(e,[{key:"apply",value:function(r,n){var i=this;this.context=r;var a=this.context,o=a.config,l=a.camera,c=a.renderingService,s=a.renderingContext,u=a.rBushRoot,h=a.pathGeneratorFactory,f=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=h;var d=r.contextService,v=s.root.ownerDocument.defaultView,p=function(e){var t=e.target.rBushNode;null!=t&&t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)},y=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)};c.hooks.init.tap(e.tag,function(){v.addEventListener(t.ElementEvent.UNMOUNTED,p),v.addEventListener(t.ElementEvent.CULLED,y);var e=d.getDPR(),r=o.width,n=o.height,a=d.getContext();i.clearRect(a,0,0,r*e,n*e,o.background)}),c.hooks.destroy.tap(e.tag,function(){v.removeEventListener(t.ElementEvent.UNMOUNTED,p),v.removeEventListener(t.ElementEvent.CULLED,y),i.renderQueue=[],i.removedRBushNodeAABBs=[],x(i,j)[j]={restoreStack:[],prevObject:null,currentContext:null}});var g=function(e,t){for(var r=[e];r.length>0;){var a,o=r.pop();o.isVisible()&&!o.isCulled()&&(f?i.renderDisplayObjectOptimized(o,t,i.context,x(i,j)[j],n):i.renderDisplayObject(o,t,i.context,x(i,j)[j],n));for(var l=(null===(a=o.sortable)||void 0===a||null===(a=a.sorted)||void 0===a?void 0:a.length)>0?o.sortable.sorted:o.childNodes,c=l.length-1;c>=0;c--)r.push(l[c])}};c.hooks.endFrame.tap(e.tag,function(){if(function(){var e,t=d.getContext(),r=d.getDPR(),n=o.width,a=o.height,l=i.canvasRendererPluginOptions,s=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,h=c.getStats(),f=h.rendered,p=f/h.total;i.clearFullScreen=i.clearFullScreenLastFrame||!(null!==(e=v.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||c.disableDirtyRectangleRendering()||f>s&&p>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,n*r,a*r,o.background))}(),0!==s.root.childNodes.length){f=o.renderer.getConfig().enableRenderingOptimization,x(i,j)[j]={restoreStack:[],prevObject:null,currentContext:x(i,j)[j].currentContext},x(i,j)[j].currentContext.clear(),i.clearFullScreenLastFrame=!1;var e,r,a=d.getContext(),u=d.getDPR();if((e=i.dprMatrix)[0]=(r=[u,u,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,C(i.vpMatrix,i.dprMatrix,l.getOrthoMatrix()),i.clearFullScreen)f?(a.save(),g(s.root,a),a.restore()):g(s.root,a),i.removedRBushNodeAABBs=[];else{var h=i.safeMergeAABB.apply(i,[i.mergeDirtyAABBs(i.renderQueue)].concat(b(i.removedRBushNodeAABBs.map(function(e){var r=e.minX,n=e.minY,i=e.maxX,a=e.maxY,o=new t.AABB;return o.setMinMax([r,n,0],[i,a,0]),o}))));if(i.removedRBushNodeAABBs=[],t.AABB.isEmpty(h))return void(i.renderQueue=[]);var p=i.convertAABB2Rect(h),y=p.x,m=p.y,S=p.width,w=p.height,M=E(i.vec3a,[y,m,0],i.vpMatrix),k=E(i.vec3b,[y+S,m,0],i.vpMatrix),O=E(i.vec3c,[y,m+w,0],i.vpMatrix),P=E(i.vec3d,[y+S,m+w,0],i.vpMatrix),T=Math.min(M[0],k[0],P[0],O[0]),A=Math.min(M[1],k[1],P[1],O[1]),R=Math.max(M[0],k[0],P[0],O[0]),D=Math.max(M[1],k[1],P[1],O[1]),L=Math.floor(T),I=Math.floor(A),F=Math.ceil(R-T),B=Math.ceil(D-A);a.save(),i.clearRect(a,L,I,F,B,o.background),a.beginPath(),a.rect(L,I,F,B),a.clip(),a.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&v.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:L,y:I,width:F,height:B}})),i.searchDirtyObjects(h).sort(function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&i.renderDisplayObject(e,a,i.context,x(i,j)[j],n)}),a.restore(),i.renderQueue.forEach(function(e){i.saveDirtyAABB(e)}),i.renderQueue=[]}x(i,j)[j].restoreStack.forEach(function(){a.restore()}),x(i,j)[j].restoreStack=[]}else i.clearFullScreenLastFrame=!0}),c.hooks.render.tap(e.tag,function(e){i.clearFullScreen||i.renderQueue.push(e)})}},{key:"clearRect",value:function(e,t,r,n,i,a){e.clearRect(t,r,n,i),a&&(e.fillStyle=a,e.fillRect(t,r,n,i))}},{key:"renderDisplayObjectOptimized",value:function(e,r,n,i,a){var o=e.nodeName,l=!1,c=this.context.styleRendererFactory[o],s=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){(!i.prevObject||!P(u.getWorldTransform(),i.prevObject.getWorldTransform()))&&(this.applyWorldTransform(r,u),i.prevObject=null);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),l=!0,r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}if(c){(!i.prevObject||!P(e.getWorldTransform(),i.prevObject.getWorldTransform()))&&this.applyWorldTransform(r,e);var f=!i.prevObject;if(!f){var d=i.prevObject.nodeName;f=o===t.Shape.TEXT?d!==t.Shape.TEXT:o===t.Shape.IMAGE?d!==t.Shape.IMAGE:d===t.Shape.TEXT||d===t.Shape.IMAGE}c.applyStyleToContext(r,e,f,i),i.prevObject=e}s&&(r.beginPath(),s(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),c&&c.drawToContext(r,e,x(this,j)[j],this,a),l&&r.restore(),e.dirty(!1)}},{key:"renderDisplayObject",value:function(e,r,n,i,a){var o=e.nodeName,l=i.restoreStack[i.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.restoreStack.pop());var c=this.context.styleRendererFactory[o],s=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(r,u);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),i.restoreStack.push(e),r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}c&&(this.applyWorldTransform(r,e),r.save(),this.applyAttributesToContext(r,e)),s&&(r.beginPath(),s(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),c&&(c.render(r,e.parsedStyle,e,n,this,a),r.restore()),e.dirty(!1)}},{key:"applyAttributesToContext",value:function(e,t){var r=t.parsedStyle,n=r.stroke,i=r.fill,a=r.opacity,o=r.lineDash,l=r.lineDashOffset;o&&e.setLineDash(o),R(l)||(e.lineDashOffset=l),R(a)||(e.globalAlpha*=a),R(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),R(i)||Array.isArray(i)||i.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}}},{key:"mergeDirtyAABBs",value:function(e){var r=new t.AABB;return e.forEach(function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)}),r}},{key:"searchDirtyObjects",value:function(e){var t=m(e.getMin(),2),r=t[0],n=t[1],i=m(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[1]}).map(function(e){return e.displayObject})}},{key:"saveDirtyAABB",value:function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(e,t,r){r?(O(this.tmpMat4,t.getLocalTransform()),C(this.tmpMat4,r,this.tmpMat4),C(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(O(this.tmpMat4,t.getWorldTransform()),C(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var e=new t.AABB,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach(function(t){e.add(t)}),e}}])}();function B(e,t,r,n,i,a,o){var l,c;if("rect"===e.image.nodeName){var s=e.image.parsedStyle,u=s.width,h=s.height;c=n.contextService.getDPR();var f=n.config.offscreenCanvas;(l=a.offscreenCanvasCreator.getOrCreateCanvas(f)).width=u*c,l.height=h*c;var d=a.offscreenCanvasCreator.getOrCreateContext(f),v={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach(function(e){i.renderDisplayObject(e,d,n,v,a)}),v.restoreStack.forEach(function(){d.restore()})}return o.getOrCreatePatternSync(t,e,r,l,c,t.getGeometryBounds().min,function(){t.dirty(),n.renderingService.dirty()})}function N(e,r,n,i){var a;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var o=r.getGeometryBounds(),l=o&&2*o.halfExtents[0]||1,c=o&&2*o.halfExtents[1]||1,s=o&&o.min||[0,0];a=i.getOrCreateGradient(p(p({type:e.type},e.value),{},{min:s,width:l,height:c}),n)}return a}F.tag="CanvasRenderer";var G=["shadowBlur","shadowOffsetX","shadowOffsetY"],W=["lineCap","lineJoin","miterLimit"],_={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},H={};function $(e,t,r,n){var i=n.has(t)?n.get(t):_[t];return i!==r&&("lineDash"===t?e.setLineDash(r):e[t]=r,n.set(t,r)),i}var Y=function(){return a(function e(t){o(this,e),this.imagePool=t},[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,r,n,i,a){}},{key:"applyCommonStyleToContext",value:function(e,t,r,n){var i=r?H:n.prevObject.parsedStyle,a=t.parsedStyle;(r||a.opacity!==i.opacity)&&$(e,"globalAlpha",R(a.opacity)?_.globalAlpha:a.opacity,n.currentContext),(r||a.blend!==i.blend)&&$(e,"globalCompositeOperation",R(a.blend)?_.globalCompositeOperation:a.blend,n.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,r,n){var i=r?H:n.prevObject.parsedStyle,a=t.parsedStyle,o=a.lineWidth,l=a.fill&&!a.fill.isNone;if(a.stroke&&!a.stroke.isNone&&(void 0===o?_.lineWidth:o)>0){if(r||t.attributes.stroke!==n.prevObject.attributes.stroke)$(e,"strokeStyle",R(a.stroke)||Array.isArray(a.stroke)||a.stroke.isNone?_.strokeStyle:t.attributes.stroke,n.currentContext);(r||a.lineWidth!==i.lineWidth)&&$(e,"lineWidth",R(a.lineWidth)?_.lineWidth:a.lineWidth,n.currentContext),(r||a.lineDash!==i.lineDash)&&$(e,"lineDash",a.lineDash||_.lineDash,n.currentContext),(r||a.lineDashOffset!==i.lineDashOffset)&&$(e,"lineDashOffset",R(a.lineDashOffset)?_.lineDashOffset:a.lineDashOffset,n.currentContext);for(var c=0;W.length>c;c++){var s=W[c];(r||a[s]!==i[s])&&$(e,s,R(a[s])?_[s]:a[s],n.currentContext)}}l&&(r||t.attributes.fill!==n.prevObject.attributes.fill)&&$(e,"fillStyle",R(a.fill)||Array.isArray(a.fill)||a.fill.isNone?_.fillStyle:t.attributes.fill,n.currentContext)}},{key:"applyStyleToContext",value:function(e,r,n,i){var a=r.nodeName;this.applyCommonStyleToContext(e,r,n,i),a===t.Shape.IMAGE||this.applyStrokeFillStyleToContext(e,r,n,i)}},{key:"applyShadowAndFilterStyleToContext",value:function(e,t,r,n){var i=t.parsedStyle;if(r){$(e,"shadowColor",""+i.shadowColor,n.currentContext);for(var a=0;G.length>a;a++){var o=G[a];$(e,o,i[o]||_[o],n.currentContext)}}i.filter&&i.filter.length&&$(e,"filter",t.attributes.filter,n.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t){$(e,"shadowColor",_.shadowColor,n.currentContext);for(var a=0;G.length>a;a++){var o=G[a];$(e,o,_[o],n.currentContext)}}if(r)if(t&&i){var l=e.filter;!R(l)&&l.indexOf("drop-shadow")>-1&&$(e,"filter",l.replace(/drop-shadow\([^)]*\)/,"").trim()||_.filter,n.currentContext)}else $(e,"filter",_.filter,n.currentContext)}},{key:"fillToContext",value:function(e,r,n,i,a){var o=this,l=r.parsedStyle,c=l.fill,s=l.fillRule,u=null;if(Array.isArray(c)&&c.length>0)c.forEach(function(t){var i=$(e,"fillStyle",N(t,r,e,o.imagePool),n.currentContext);u=null!=u?u:i,s?e.fill(s):e.fill()});else{if(t.isPattern(c)){var h=B(c,r,e,r.ownerDocument.defaultView.context,i,a,this.imagePool);h&&(e.fillStyle=h,u=!0)}s?e.fill(s):e.fill()}null!==u&&$(e,"fillStyle",u,n.currentContext)}},{key:"strokeToContext",value:function(e,r,n,i,a){var o=this,l=r.parsedStyle.stroke,c=null;if(Array.isArray(l)&&l.length>0)l.forEach(function(t){var i=$(e,"strokeStyle",N(t,r,e,o.imagePool),n.currentContext);c=null!=c?c:i,e.stroke()});else{if(t.isPattern(l)){var s=B(l,r,e,r.ownerDocument.defaultView.context,i,a,this.imagePool);if(s){var u=$(e,"strokeStyle",s,n.currentContext);c=null!=c?c:u}}e.stroke()}null!==c&&$(e,"strokeStyle",c,n.currentContext)}},{key:"drawToContext",value:function(e,r,n,i,a){var o,l=r.nodeName,c=r.parsedStyle,s=c.opacity,u=void 0===s?_.globalAlpha:s,h=c.fillOpacity,f=void 0===h?_.fillOpacity:h,d=c.strokeOpacity,v=void 0===d?_.strokeOpacity:d,p=c.lineWidth,y=c.fill&&!c.fill.isNone,g=c.stroke&&!c.stroke.isNone&&(void 0===p?_.lineWidth:p)>0;if(y||g){var m=!R(c.shadowColor)&&c.shadowBlur>0,b="inner"===c.shadowType,x=0===(null===(o=c.fill)||void 0===o?void 0:o.alpha),S=!(!c.filter||!c.filter.length),w=m&&g&&(l===t.Shape.PATH||l===t.Shape.LINE||l===t.Shape.POLYLINE||x||b),M=null;if(y)w||this.applyShadowAndFilterStyleToContext(e,r,m,n),M=$(e,"globalAlpha",u*f,n.currentContext),this.fillToContext(e,r,n,i,a),w||this.clearShadowAndFilterStyleForContext(e,m,S,n);if(g){var k=!1,O=$(e,"globalAlpha",u*v,n.currentContext);if(M=y?M:O,w&&(this.applyShadowAndFilterStyleToContext(e,r,m,n),k=!0,b)){var C=e.globalCompositeOperation;e.globalCompositeOperation="source-atop",this.strokeToContext(e,r,n,i,a),e.globalCompositeOperation=C,this.clearShadowAndFilterStyleForContext(e,m,S,n,!0)}this.strokeToContext(e,r,n,i,a),k&&this.clearShadowAndFilterStyleForContext(e,m,S,n)}null!==M&&$(e,"globalAlpha",M,n.currentContext)}}}])}(),z=function(e){function r(){return o(this,r),u(this,r,arguments)}return f(r,e),a(r,[{key:"render",value:function(e,r,n,i,a,o){var l=r.fill,c=r.fillRule,s=r.opacity,u=void 0===s?1:s,h=r.fillOpacity,f=void 0===h?1:h,d=r.stroke,v=r.strokeOpacity,p=void 0===v?1:v,y=r.lineWidth,g=void 0===y?1:y,m=r.lineCap,b=r.lineJoin,x=r.shadowType,S=r.shadowBlur,w=r.filter,M=r.miterLimit,k=l&&!l.isNone,O=d&&!d.isNone&&g>0,C=0===(null==l?void 0:l.alpha),P=!(!w||!w.length),T=!R(r.shadowColor)&&S>0,A=n.nodeName,E="inner"===x,D=O&&T&&(A===t.Shape.PATH||A===t.Shape.LINE||A===t.Shape.POLYLINE||C||E);k&&(e.globalAlpha=u*f,D||X(n,e,T),U(e,n,l,c,i,a,o,this.imagePool),D||this.clearShadowAndFilter(e,P,T)),O&&(e.globalAlpha=u*p,e.lineWidth=g,R(M)||(e.miterLimit=M),R(m)||(e.lineCap=m),R(b)||(e.lineJoin=b),D&&(E&&(e.globalCompositeOperation="source-atop"),X(n,e,!0),E&&(q(e,n,d,i,a,o,this.imagePool),e.globalCompositeOperation=_.globalCompositeOperation,this.clearShadowAndFilter(e,P,!0))),q(e,n,d,i,a,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(e,t,r){if(r&&(e.shadowColor="transparent",e.shadowBlur=0),t){var n=e.filter;!R(n)&&n.indexOf("drop-shadow")>-1&&(e.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Y);function X(e,t,r){var n=e.parsedStyle,i=n.filter,a=n.shadowColor,o=n.shadowBlur,l=n.shadowOffsetX,c=n.shadowOffsetY;i&&i.length&&(t.filter=e.style.filter),r&&(t.shadowColor=""+a,t.shadowBlur=o||0,t.shadowOffsetX=l||0,t.shadowOffsetY=c||0)}function U(e,r,n,i,a,o,l,c){var s=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach(function(t){e.fillStyle=N(t,r,e,c),s||(i?e.fill(i):e.fill())}):(t.isPattern(n)&&(e.fillStyle=B(n,r,e,a,o,l,c)),s||(i?e.fill(i):e.fill()))}function q(e,r,n,i,a,o,l){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach(function(t){e.strokeStyle=N(t,r,e,l),c||e.stroke()}):(t.isPattern(n)&&(e.strokeStyle=B(n,r,e,i,a,o,l)),c||e.stroke())}var V=function(e){function t(){return o(this,t),u(this,t,arguments)}return f(t,e),a(t,[{key:"renderDownSampled",value:function(e,t,r,n){var i=n.src,a=n.imageCache;a.downSampled?e.drawImage(a.downSampled,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3])):this.imagePool.createDownSampledImage(i,r).then(function(){r.ownerDocument&&(r.dirty(),r.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(e){console.error(e)})}},{key:"renderTile",value:function(e,t,r,n){var i=n.src,a=n.imageCache,o=n.imageRect,l=n.drawRect,c=a.size,s=e.getTransform(),u=s.a,h=s.b,f=s.c,d=s.d,v=s.e,p=s.f;if(e.resetTransform(),null!=a&&a.gridSize){for(var y=[c[0]/o[2],c[1]/o[3]],g=[a.tileSize[0]/y[0],a.tileSize[1]/y[1]],m=[Math.floor((l[0]-o[0])/g[0]),Math.ceil((l[0]+l[2]-o[0])/g[0])],b=m[0],x=m[1],S=[Math.floor((l[1]-o[1])/g[1]),Math.ceil((l[1]+l[3]-o[1])/g[1])],w=S[1],M=S[0];w>=M;M++)for(var k=b;x>=k;k++){var O=a.tiles[M][k];if(O){var C=[Math.floor(o[0]+O.tileX*g[0]),Math.floor(o[1]+O.tileY*g[1]),Math.ceil(g[0]),Math.ceil(g[1])];e.drawImage(O.data,C[0],C[1],C[2],C[3])}}e.setTransform(u,h,f,d,v,p)}else this.imagePool.createImageTiles(i,[],function(){r.ownerDocument&&(r.dirty(),r.ownerDocument.defaultView.context.renderingService.dirty())},r).catch(function(e){console.error(e)})}},{key:"render",value:function(e,r,n){var i=r.x,a=void 0===i?0:i,o=r.y,l=void 0===o?0:o,c=r.width,s=r.height,u=r.src,h=r.shadowColor,f=r.shadowBlur,d=this.imagePool.getImageSync(u,n),v=null==d?void 0:d.img,p=c,y=s;if(v){var g,b,x,S,w,k,O,C,P,A,D,L,I,j,F,B,N,G,W,_,H,$,Y,z,U,q,V,Q,J,Z,K,ee,te,re,ne,ie,ae,oe;p||(p=v.width),y||(y=v.height),X(n,e,!R(h)&&f>0);try{var le=n.ownerDocument.defaultView.getContextService().getDomElement(),ce=le.width,se=le.height,ue=e.getTransform(),he=($=ue.a,Y=ue.c,z=0,U=0,q=ue.b,V=ue.d,Q=0,J=0,Z=0,K=0,ee=1,te=0,re=ue.e,ne=ue.f,ie=0,ae=1,(oe=new M(16))[0]=$,oe[1]=Y,oe[2]=z,oe[3]=U,oe[4]=q,oe[5]=V,oe[6]=Q,oe[7]=J,oe[8]=Z,oe[9]=K,oe[10]=ee,oe[11]=te,oe[12]=re,oe[13]=ne,oe[14]=ie,oe[15]=ae,oe),fe=(B=[a,l,p,y],N=he,G=E(T(),[B[0],B[1],0],N),W=E(T(),[B[0]+B[2],B[1],0],N),_=E(T(),[B[0],B[1]+B[3],0],N),H=E(T(),[B[0]+B[2],B[1]+B[3],0],N),[Math.min(G[0],W[0],_[0],H[0]),Math.min(G[1],W[1],_[1],H[1]),Math.max(G[0],W[0],_[0],H[0])-Math.min(G[0],W[0],_[0],H[0]),Math.max(G[1],W[1],_[1],H[1])-Math.min(G[1],W[1],_[1],H[1])]),de=(g=fe,b=m([0,0,ce,se],4),x=b[0],S=b[1],w=b[2],k=b[3],O=m(g,4),P=O[1],A=O[2],D=O[3],L=Math.max(x,C=O[0]),I=Math.max(S,P),j=Math.min(x+w,C+A),F=Math.min(S+k,P+D),j>L&&F>I?[L,I,j-L,F-I]:null);if(!de)return;if(!n.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void t.renderFull(e,r,n,{image:v,drawRect:[a,l,p,y]});if((d.downSamplingRate||.5)>fe[2]/d.size[0])return void this.renderDownSampled(e,r,n,{src:u,imageCache:d,drawRect:[a,l,p,y]});if(!ImagePool.isSupportTile)return void t.renderFull(e,r,n,{image:v,drawRect:[a,l,p,y]});this.renderTile(e,r,n,{src:u,imageCache:d,imageRect:fe,drawRect:de})}catch(e){}}}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t)}}],[{key:"renderFull",value:function(e,t,r,n){e.drawImage(n.image,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3]))}}])}(z);function Q(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){l=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}var J=function(e){function t(){return o(this,t),u(this,t,arguments)}return f(t,e),a(t,[{key:"render",value:function(e,t,r,n,i,a){r.getBounds();var o=t.lineWidth,l=void 0===o?1:o,c=t.textAlign,s=void 0===c?"start":c,u=t.textBaseline,h=void 0===u?"alphabetic":u,f=t.lineJoin,d=void 0===f?"miter":f,v=t.miterLimit,p=void 0===v?10:v,y=t.letterSpacing,g=void 0===y?0:y,m=t.stroke,b=t.fill,x=t.fillRule,S=t.fillOpacity,w=void 0===S?1:S,M=t.strokeOpacity,k=void 0===M?1:M,O=t.opacity,C=void 0===O?1:O,P=t.metrics,T=t.x,A=void 0===T?0:T,E=t.y,D=void 0===E?0:E,L=t.dx,I=t.dy,j=t.shadowColor,F=t.shadowBlur,B=t.textDecorationLine,N=P.lines,G=P.height,W=P.lineHeight,_=P.lineMetrics;e.font=P.font,e.lineWidth=l,e.textAlign="middle"===s?"center":s;var H=h;"alphabetic"===H&&(H="bottom"),e.lineJoin=d,R(p)||(e.miterLimit=p);var $=D;"middle"===h?$+=-G/2-W/2:"bottom"===h||"alphabetic"===h||"ideographic"===h?$+=-G:"top"!==h&&"hanging"!==h||($+=-W);var Y=A+(L||0);$+=I||0,1===N.length&&("bottom"===H?(H="middle",$-=.5*G):"top"===H&&(H="middle",$+=.5*G)),e.textBaseline=H,X(r,e,!R(j)&&F>0);for(var z=0;N.length>z;z++){var U=l/2+Y;$+=W,R(m)||m.isNone||!l||this.drawLetterSpacing(e,r,N[z],_[z],s,U,$,g,b,x,w,m,k,C,!0,n,i,a),R(b)||this.drawLetterSpacing(e,r,N[z],_[z],s,U,$,g,b,x,w,m,k,C,!1,n,i,a)}B&&"none"!==B&&this.drawTextDecorations(e,t,r,N,W,Y,D+(I||0),n,i,a)}},{key:"drawLetterSpacing",value:function(e,t,r,n,i,a,o,l,c,s,u,h,f,d,v,p,y,g){if(0!==l){var m=e.textAlign;e.textAlign="left";var b=a;"center"===i||"middle"===i?b=a-n.width/2:"right"!==i&&"end"!==i||(b=a-n.width);for(var x=Array.from(r),S=e.measureText(r).width,w=0,M=0;x.length>M;++M){var k=x[M];v?this.strokeText(e,t,k,b,o,h,f,p,y,g):this.fillText(e,t,k,b,o,c,s,u,d,p,y,g),b+=S-(w=e.measureText(r.substring(M+1)).width)+l,S=w}e.textAlign=m}else v?this.strokeText(e,t,r,a,o,h,f,p,y,g):this.fillText(e,t,r,a,o,c,s,u,d,p,y,g)}},{key:"fillText",value:function(e,t,r,n,i,a,o,l,c,s,u,h){var f;U(e,t,a,o,s,u,h,this.imagePool,!0);var d=!R(l)&&1!==l;d&&(f=e.globalAlpha,e.globalAlpha=l*c),e.fillText(r,n,i),d&&(e.globalAlpha=f)}},{key:"strokeText",value:function(e,t,r,n,i,a,o,l,c,s){var u;q(e,t,a,l,c,s,this.imagePool,!0);var h=!R(o)&&1!==o;h&&(u=e.globalAlpha,e.globalAlpha=o),e.strokeText(r,n,i),h&&(e.globalAlpha=u)}},{key:"drawTextDecorations",value:function(e,t,r,n,i,a,o,l,c,s){var u=t.textDecorationLine,h=t.textDecorationColor,f=t.textDecorationStyle,d=t.textDecorationThickness,v=void 0===d?1:d,p=t.textAlign,y=void 0===p?"start":p,g=t.lineWidth,m=void 0===g?1:g,b=t.metrics;if(u&&"none"!==u){var x=b.lineMetrics,S=u.split(" ");switch(e.lineWidth=v,h&&(e.strokeStyle="rgba(".concat(h.r,", ").concat(h.g,", ").concat(h.b,", ").concat(h.alpha,")")),f){case"dashed":e.setLineDash([5,5]);break;case"dotted":e.setLineDash([2,2]);break;default:e.setLineDash([])}var w=o,M=t.textBaseline,k=void 0===M?"alphabetic":M;"middle"===k?w+=-b.height/2-i/2:"bottom"===k||"alphabetic"===k||"ideographic"===k?w+=-b.height:"top"!==k&&"hanging"!==k||(w+=-i);for(var O=0;n.length>O;O++){w+=i;var C=x[O];if(C){var P=m/2,T=a,A=a+C.width;"center"===y||"middle"===y?(T=a-C.width/2,A=a+C.width/2):"right"!==y&&"end"!==y||(T=a-C.width,A=a),T+=P,A+=P;var E,R=Q(S);try{for(R.s();!(E=R.n()).done;){var D=w;switch(E.value){case"underline":D+=2;break;case"overline":D-=i-2;break;case"line-through":D-=i/2;break;default:continue}"wavy"===f?this.drawWavyLine(e,T,A,D):(e.beginPath(),e.moveTo(T,D),e.lineTo(A,D),e.stroke())}}catch(e){R.e(e)}finally{R.f()}}}e.setLineDash([])}}},{key:"drawWavyLine",value:function(e,t,r,n){var i=10,a=Math.floor((r-t)/i);e.beginPath(),e.moveTo(t,n);for(var o=0;a>o;o++){e.quadraticCurveTo(t+o*i+2.5,n+2,t+o*i+5,n),e.quadraticCurveTo(t+o*i+7.5,n-2,t+(o+1)*i,n)}e.stroke()}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t,t.ownerDocument.defaultView.context,n,i)}}])}(z),Z=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(this,r),(e=u(this,r)).name="canvas-renderer",e.options=t,e}return f(r,e),a(r,[{key:"init",value:function(){var e,r=p({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new z(n),a=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,i),t.Shape.ELLIPSE,i),t.Shape.RECT,i),t.Shape.IMAGE,new V(n)),t.Shape.TEXT,new J(n)),t.Shape.LINE,i),t.Shape.POLYLINE,i),t.Shape.POLYGON,i),t.Shape.PATH,i),t.Shape.GROUP,void 0),d(d(d(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new F(r))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(t.AbstractRendererPlugin),K=Object.freeze({__proto__:null,CircleRenderer:z,DefaultRenderer:z,EllipseRenderer:z,ImageRenderer:V,LineRenderer:z,PathRenderer:z,Plugin:Z,PolygonRenderer:z,PolylineRenderer:z,RectRenderer:z,TextRenderer:J});function ee(e,t){this.v=e,this.k=t}function te(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}te=function(e,t,r,n){function a(t,r){te(e,t,function(e){return this._invoke(t,r,e)})}t?i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},te(e,t,r,n)}function re(){
|
|
18
10
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
19
|
-
var e,t,
|
|
11
|
+
var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var c=Object.create((n&&n.prototype instanceof l?n:l).prototype);return te(c,"_invoke",function(r,n,i){var a,l,c,s=0,u=i||[],h=!1,f={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return a=t,l=0,c=e,f.n=r,o}};function d(r,n){for(l=r,c=n,t=0;!h&&s&&!i&&u.length>t;t++){var i,a=u[t],d=f.p,v=a[2];r>3?(i=v===n)&&(c=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):d>=a[0]&&((i=2>r&&a[1]>d)?(l=0,f.v=n,f.n=a[1]):v>d&&(i=3>r||a[0]>n||n>v)&&(a[4]=r,a[5]=n,f.n=v,l=0))}if(i||r>1)return o;throw h=!0,n}return function(i,u,v){if(s>1)throw TypeError("Generator is already running");for(h&&1===u&&d(u,v),l=u,c=v;(t=2>l?e:c)||!h;){a||(l?3>l?(l>1&&(f.n=-1),d(l,c)):f.n=c:f.v=c);try{if(s=2,a){if(l||(i="next"),t=a[i]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,2>l&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),2>l&&(c=TypeError("The iterator does not provide a '"+i+"' method"),l=1);a=e}else if((t=(h=0>f.n)?c:r.call(n,f))!==o)break}catch(t){a=e,l=1,c=t}finally{s=1}}return{value:t,done:h}}}(r,i,a),!0),c}var o={};function l(){}function c(){}function s(){}t=Object.getPrototypeOf;var u=[][n]?t(t([][n]())):(te(t={},n,function(){return this}),t),h=s.prototype=l.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,te(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return c.prototype=s,te(h,"constructor",s),te(s,"constructor",c),c.displayName="GeneratorFunction",te(s,i,"GeneratorFunction"),te(h),te(h,i,"Generator"),te(h,n,function(){return this}),te(h,"toString",function(){return"[object Generator]"}),(re=function(){return{w:a,m:f}})()}function ne(e,t){function r(n,i,a,o){try{var l=e[n](i),c=l.value;return c instanceof ee?t.resolve(c.v).then(function(e){r("next",e,a,o)},function(e){r("throw",e,a,o)}):t.resolve(c).then(function(e){l.value=e,a(l)},function(e){return r("throw",e,a,o)})}catch(e){o(e)}}var n;this.next||(te(ne.prototype),te(ne.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),te(this,"_invoke",function(e,i,a){function o(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(o,o):o()},!0)}function ie(e,t,r,n,i){return new ne(re().w(e,t,r,n),i||Promise)}function ae(e,t,r,n,i){var a=ie(e,t,r,n,i);return a.next().then(function(e){return e.done?e.value:a.next()})}function oe(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function le(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(r(e)+" is not iterable")}function ce(){var e=re(),t=e.m(ce),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var i={throw:1,return:2,break:3,continue:3};function a(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,i[e],t)},delegateYield:function(e,i,a){return t.resultName=i,r(n.d,le(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,i){n.p=t.prev,n.n=t.next;try{return e(r,i)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(ce=function(){return{wrap:function(t,r,n,i){return e.w(a(t),r,n,i&&i.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new ee(e,t)},AsyncIterator:ne,async:function(e,t,r,i,o){return(n(t)?ie:ae)(a(e),t,r,i,o)},keys:oe,values:le}})()}function se(e,t,r,n,i,a,o){try{var l=e[a](o),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function ue(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){se(a,n,i,o,l,"next",e)}function l(e){se(a,n,i,o,l,"throw",e)}o(void 0)})}}var he=T(),fe=T(),de=T(),ve=k(),pe=function(){function e(){var r=this;o(this,e),this.isHit=function(e,n,i,a){var o,l,c,s,u,h,f,d,v,p,y,g,m,b,x,S,w,M,k,O,C,P,T,R,D,L,I,j,F,B,N,G=r.context.pointInPathPickerFactory[e.nodeName];if(G){var W=(o=ve,(N=(k=(c=(l=i)[0])*(d=l[5])-(s=l[1])*(f=l[4]))*(B=(m=l[10])*(M=l[15])-(b=l[11])*(w=l[14]))-(O=c*(v=l[6])-(u=l[2])*f)*(F=(g=l[9])*M-b*(S=l[13]))+(C=c*(p=l[7])-(h=l[3])*f)*(j=g*w-m*S)+(P=s*v-u*d)*(I=(y=l[8])*M-b*(x=l[12]))-(T=s*p-h*d)*(L=y*w-m*x)+(R=u*p-h*v)*(D=y*S-g*x))?(o[0]=(d*B-v*F+p*j)*(N=1/N),o[1]=(u*F-s*B-h*j)*N,o[2]=(S*R-w*T+M*P)*N,o[3]=(m*T-g*R-b*P)*N,o[4]=(v*I-f*B-p*L)*N,o[5]=(c*B-u*I+h*L)*N,o[6]=(w*C-x*R-M*O)*N,o[7]=(y*R-m*C+b*O)*N,o[8]=(f*F-d*I+p*D)*N,o[9]=(s*I-c*F-h*D)*N,o[10]=(x*T-S*C+M*k)*N,o[11]=(g*C-y*T-b*k)*N,o[12]=(d*L-f*j-v*D)*N,o[13]=(c*j-s*L+u*D)*N,o[14]=(S*O-x*P-w*k)*N,o[15]=(y*P-g*O+m*k)*N,o):null),_=E(fe,A(de,n[0],n[1],0),W);if(G(e,new t.Point(_[0],_[1]),a,r.isPointInPath,r.context,r.runtime))return!0}return!1},this.isPointInPath=function(e,t){var n=r.runtime.offscreenCanvasCreator.getOrCreateContext(r.context.config.offscreenCanvas),i=r.context.pathGeneratorFactory[e.nodeName];return i&&(n.beginPath(),i(n,e.parsedStyle),n.closePath()),n.isPointInPath(t.x,t.y)}}return a(e,[{key:"apply",value:function(t,r){var n,i=this,a=t.renderingService,o=t.renderingContext;this.context=t,this.runtime=r;var l=null===(n=o.root)||void 0===n?void 0:n.ownerDocument;a.hooks.pick.tapPromise(e.tag,function(){var e=ue(ce().mark(function e(t){return ce().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",i.pick(l,t));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),a.hooks.pickSync.tap(e.tag,function(e){return i.pick(l,e)})}},{key:"pick",value:function(e,r){var n,i=r.topmost,a=r.position,o=A(he,a.x,a.y,0),l=[],c=Q(e.elementsFromBBox(o[0],o[1],o[0],o[1]));try{for(c.s();!(n=c.n()).done;){var s=n.value,u=s.getWorldTransform();if(this.isHit(s,o,u,!1)){var h=t.findClosestClipPathTarget(s);if(h){var f=h.parsedStyle.clipPath;if(this.isHit(f,o,f.getWorldTransform(),!0)){if(i)return r.picked=[s],r;l.push(s)}}else{if(i)return r.picked=[s],r;l.push(s)}}}}catch(e){c.e(e)}finally{c.f()}return r.picked=l,r}}])}();
|
|
20
12
|
/*!
|
|
21
13
|
* @antv/g-math
|
|
22
14
|
* @description Geometry util
|
|
23
|
-
* @version 3.0
|
|
24
|
-
* @date 12/
|
|
25
|
-
* @author AntVis
|
|
26
|
-
* @docs https://g.antv.antgroup.com/
|
|
27
|
-
*/function K(e,t,n,r){var a=e-n,i=t-r;return Math.sqrt(a*a+i*i)}function ee(e,t,n,r,a,i){var o=-1,l=1/0,s=[n,r],c=20;i&&i>200&&(c=i/10);for(var u=1/c,h=u/10,d=0;c>=d;d++){var f=d*u,v=[a.apply(void 0,J(e.concat([f]))),a.apply(void 0,J(t.concat([f])))],p=K(s[0],s[1],v[0],v[1]);l>p&&(o=f,l=p)}if(0===o)return{x:e[0],y:t[0]};if(1===o){var y=e.length;return{x:e[y-1],y:t[y-1]}}l=1/0;for(var m=0;32>m&&1e-4<=h;m++){var g=o-h,b=o+h,S=[a.apply(void 0,J(e.concat([g]))),a.apply(void 0,J(t.concat([g])))],x=K(s[0],s[1],S[0],S[1]);if(g>=0&&l>x)o=g,l=x;else{var k=[a.apply(void 0,J(e.concat([b]))),a.apply(void 0,J(t.concat([b])))],w=K(s[0],s[1],k[0],k[1]);1>=b&&l>w?(o=b,l=w):h*=.5}}return{x:a.apply(void 0,J(e.concat([o]))),y:a.apply(void 0,J(t.concat([o])))}}function te(e,t,n,r,a,i){var o=[n-e,r-t];if(function(e,t){return e[0]===t[0]&&e[1]===t[1]}(o,[0,0]))return Math.sqrt((a-e)*(a-e)+(i-t)*(i-t));var l=[-o[1],o[0]];return function(e,t){var n=t[0],r=t[1],a=n*n+r*r;a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a}(l,l),Math.abs(function(e,t){return e[0]*t[0]+e[1]*t[1]}([a-e,i-t],l))}function ne(e,t,n,r,a){var i=1-a;return i*i*i*e+3*t*a*i*i+3*n*a*a*i+r*a*a*a}function re(e,t,n,r,a,i,o,l,s,c,u){var h=function(e,t,n,r,a,i,o,l,s,c,u){return ee([e,n,a,o],[t,r,i,l],s,c,ne,u)}(e,t,n,r,a,i,o,l,s,c,u);return K(h.x,h.y,s,c)}function ae(e,t,n,r){var a=1-r;return a*a*e+2*r*a*t+r*r*n}function ie(e,t,n,r,a,i,o,l){var s=function(e,t,n,r,a,i,o,l){return ee([e,n,a],[t,r,i],o,l,ae)}(e,t,n,r,a,i,o,l);return K(s.x,s.y,o,l)}function oe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function le(e){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}
|
|
28
|
-
/*!
|
|
29
|
-
* @antv/g-plugin-canvas-picker
|
|
30
|
-
* @description A G plugin for picking in canvas
|
|
31
|
-
* @version 2.3.0
|
|
32
|
-
* @date 12/10/2025, 8:45:15 AM
|
|
33
|
-
* @author AntVis
|
|
34
|
-
* @docs https://g.antv.antgroup.com/
|
|
35
|
-
*/var se=C(),ce=C(),ue=C(),he=k(),de=function(){function e(){var n=this;o(this,e),this.isHit=function(e,r,a,i){var o,l,s,c,u,h,d,f,v,p,y,m,g,b,S,x,k,w,E,M,C,A,P,R,L,D,I,N,j,F,B,G=n.context.pointInPathPickerFactory[e.nodeName];if(G){var _=(o=he,(B=(E=(s=(l=a)[0])*(f=l[5])-(c=l[1])*(d=l[4]))*(F=(g=l[10])*(w=l[15])-(b=l[11])*(k=l[14]))-(M=s*(v=l[6])-(u=l[2])*d)*(j=(m=l[9])*w-b*(x=l[13]))+(C=s*(p=l[7])-(h=l[3])*d)*(N=m*k-g*x)+(A=c*v-u*f)*(I=(y=l[8])*w-b*(S=l[12]))-(P=c*p-h*f)*(D=y*k-g*S)+(R=u*p-h*v)*(L=y*x-m*S))?(o[0]=(f*F-v*j+p*N)*(B=1/B),o[1]=(u*j-c*F-h*N)*B,o[2]=(x*R-k*P+w*A)*B,o[3]=(g*P-m*R-b*A)*B,o[4]=(v*I-d*F-p*D)*B,o[5]=(s*F-u*I+h*D)*B,o[6]=(k*C-S*R-w*M)*B,o[7]=(y*R-g*C+b*M)*B,o[8]=(d*j-f*I+p*L)*B,o[9]=(c*I-s*j-h*L)*B,o[10]=(S*P-x*C+w*E)*B,o[11]=(m*C-y*P-b*E)*B,o[12]=(f*D-d*N-v*L)*B,o[13]=(s*N-c*D+u*L)*B,o[14]=(x*M-S*A-k*E)*B,o[15]=(y*A-m*M+g*E)*B,o):null),W=T(ce,O(ue,r[0],r[1],0),_);if(G(e,new t.Point(W[0],W[1]),i,n.isPointInPath,n.context,n.runtime))return!0}return!1},this.isPointInPath=function(e,t){var r=n.runtime.offscreenCanvasCreator.getOrCreateContext(n.context.config.offscreenCanvas),a=n.context.pathGeneratorFactory[e.nodeName];return a&&(r.beginPath(),a(r,e.parsedStyle),r.closePath()),r.isPointInPath(t.x,t.y)}}return i(e,[{key:"apply",value:function(t,n){var r,a=this,i=t.renderingService,o=t.renderingContext;this.context=t,this.runtime=n;var l=null===(r=o.root)||void 0===r?void 0:r.ownerDocument;i.hooks.pick.tapPromise(e.tag,function(){var e=Z(q().mark(function e(t){return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a.pick(l,t));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),i.hooks.pickSync.tap(e.tag,function(e){return a.pick(l,e)})}},{key:"pick",value:function(e,n){var r,a=n.topmost,i=n.position,o=O(se,i.x,i.y,0),l=[],s=_(e.elementsFromBBox(o[0],o[1],o[0],o[1]));try{for(s.s();!(r=s.n()).done;){var c=r.value,u=c.getWorldTransform();if(this.isHit(c,o,u,!1)){var h=t.findClosestClipPathTarget(c);if(h){var d=h.parsedStyle.clipPath;if(this.isHit(d,o,d.getWorldTransform(),!0)){if(a)return n.picked=[c],n;l.push(c)}}else{if(a)return n.picked=[c],n;l.push(c)}}}}catch(e){s.e(e)}finally{s.f()}return n.picked=l,n}}])}();function fe(e,n,r){var a=e.parsedStyle,i=a.cx,o=a.cy,l=a.r,s=a.fill,c=a.stroke,u=a.lineWidth,h=a.increasedLineWidthForHitTesting,d=a.pointerEvents,f=void 0===d?"auto":d,v=((void 0===u?1:u)+(void 0===h?0:h))/2,p=K(void 0===i?0:i,void 0===o?0:o,n.x,n.y),m=y(t.isFillOrStrokeAffected(f,s,c),2),g=m[0],b=m[1];return g&&b||r?l+v>=p:g?l>=p:!!b&&(p>=l-v&&l+v>=p)}function ve(e,t,n,r){return e/(n*n)+t/(r*r)}function pe(e,n,r){var a=e.parsedStyle,i=a.cx,o=void 0===i?0:i,l=a.cy,s=void 0===l?0:l,c=a.rx,u=a.ry,h=a.lineWidth,d=void 0===h?1:h,f=a.increasedLineWidthForHitTesting,v=void 0===f?0:f,p=a.pointerEvents,m=n.x,g=n.y,b=y(t.isFillOrStrokeAffected(void 0===p?"auto":p,a.fill,a.stroke),2),S=b[0],x=b[1],k=(d+v)/2,w=(m-o)*(m-o),E=(g-s)*(g-s);return S&&x||r?1>=ve(w,E,c+k,u+k):S?1>=ve(w,E,c,u):!!x&&(ve(w,E,c-k,u-k)>=1&&1>=ve(w,E,c+k,u+k))}function ye(e,t,n,r,a,i){return!(e>a||a>e+n||t>i||i>t+r)}function me(e,t,n,r,a,i,o,l){var s=(Math.atan2(l-t,o-e)+2*Math.PI)%(2*Math.PI),c={x:e+n*Math.cos(s),y:t+n*Math.sin(s)};return K(c.x,c.y,o,l)<=i/2}function ge(e,t,n,r,a,i,o){var l=a/2;return!(Math.min(e,n)-l>i||i>Math.max(e,n)+l||Math.min(t,r)-l>o||o>Math.max(t,r)+l)&&te(e,t,n,r,i,o)<=a/2}function be(e,t,n,r,a){var i=e.length;if(2>i)return!1;for(var o=0;i-1>o;o++){if(ge(e[o][0],e[o][1],e[o+1][0],e[o+1][1],t,n,r))return!0}if(a){var l=e[0],s=e[i-1];if(ge(l[0],l[1],s[0],s[1],t,n,r))return!0}return!1}de.tag="CanvasPicker";function Se(e){return 1e-6>Math.abs(e)?0:0>e?-1:1}function xe(e,t,n){return!((n[0]-e[0])*(t[1]-e[1])!==(t[0]-e[0])*(n[1]-e[1])||Math.min(e[0],t[0])>n[0]||n[0]>Math.max(e[0],t[0])||Math.min(e[1],t[1])>n[1]||n[1]>Math.max(e[1],t[1]))}function ke(e,t,n){var r=!1,a=e.length;if(2>=a)return!1;for(var i=0;a>i;i++){var o=e[i],l=e[(i+1)%a];if(xe(o,l,[t,n]))return!0;Se(o[1]-n)>0!=Se(l[1]-n)>0&&0>Se(t-(n-o[1])*(o[0]-l[0])/(o[1]-l[1])-o[0])&&(r=!r)}return r}function we(e,t,n){for(var r=!1,a=0;e.length>a;a++){if(r=ke(e[a],t,n))break}return r}function Ee(e,n,r){var a=e.parsedStyle,i=a.x1,o=a.y1,l=a.x2,s=a.y2,c=a.lineWidth,u=void 0===c?1:c,h=a.increasedLineWidthForHitTesting,d=void 0===h?0:h,f=a.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===f?"auto":f,a.fill,a.stroke),2)[1]&&!r||!u)&&ge(i,o,l,s,u+d,n.x,n.y)}function Me(e,n,r,a,i,o){var l=e.parsedStyle,s=l.lineWidth,c=void 0===s?1:s,u=l.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=l.d,f=l.pointerEvents,v=d.segments,p=d.hasArc,m=d.polylines,g=d.polygons,b=y(t.isFillOrStrokeAffected(void 0===f?"auto":f,(null==g?void 0:g.length)&&l.fill,l.stroke),2),S=b[0],x=b[1],k=t.getOrCalculatePathTotalLength(e),w=!1;return S||r?w=p?a(e,n):we(g,n.x,n.y)||we(m,n.x,n.y):((x||r)&&(w=function(e,t,n,r,a){for(var i=!1,o=t/2,l=0;e.length>l;l++){var s=e[l],c=s.currentPoint,u=s.params,h=s.prePoint,d=s.box;if(!d||ye(d.x-o,d.y-o,d.width+t,d.height+t,n,r))switch(s.command){case"L":case"Z":if(i=ge(h[0],h[1],c[0],c[1],t,n,r))return!0;break;case"Q":if(i=t/2>=ie(h[0],h[1],u[1],u[2],u[3],u[4],n,r))return!0;break;case"C":if(i=t/2>=re(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],n,r,a))return!0;break;case"A":s.cubicParams||(s.cubicParams=P(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],u[7],void 0));for(var f=s.cubicParams,v=h,p=0;f.length>p;p+=6){var y=re(v[0],v[1],f[p],f[p+1],f[p+2],f[p+3],f[p+4],f[p+5],n,r,a);if(v=[f[p+4],f[p+5]],i=t/2>=y)return!0}}}return i}(v,c+h,n.x,n.y,k)),w)}function Ce(e,n,r){var a=e.parsedStyle,i=a.lineWidth,o=void 0===i?1:i,l=a.increasedLineWidthForHitTesting,s=void 0===l?0:l,c=a.points,u=a.pointerEvents,h=y(t.isFillOrStrokeAffected(void 0===u?"auto":u,a.fill,a.stroke),2),d=h[0],f=!1;return(h[1]||r)&&(f=be(c.points,o+s,n.x,n.y,!0)),f||!d&&!r||(f=ke(c.points,n.x,n.y)),f}function Oe(e,n,r){var a=e.parsedStyle,i=a.lineWidth,o=void 0===i?1:i,l=a.increasedLineWidthForHitTesting,s=void 0===l?0:l,c=a.points,u=a.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===u?"auto":u,a.fill,a.stroke),2)[1]&&!r||!o)&&be(c.points,o+s,n.x,n.y,!1)}function Te(e,n,r,a,i){var o=e.parsedStyle,l=o.radius,s=o.lineWidth,c=void 0===s?1:s,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=o.x,f=void 0===d?0:d,v=o.y,p=void 0===v?0:v,m=o.width,g=o.height,S=o.pointerEvents,x=y(t.isFillOrStrokeAffected(void 0===S?"auto":S,o.fill,o.stroke),2),k=x[0],w=x[1],E=c+h;if(l&&l.some(function(e){return 0!==e})){var M=!1;return(w||r)&&(M=function(e,t,n,r,a,i,o,l){var s=y(a,4),c=s[0],u=s[1],h=s[2],d=s[3];return ge(e+c,t,e+n-u,t,i,o,l)||ge(e+n,t+u,e+n,t+r-h,i,o,l)||ge(e+n-h,t+r,e+d,t+r,i,o,l)||ge(e,t+r-d,e,t+c,i,o,l)||me(e+n-u,t+u,u,0,0,i,o,l)||me(e+n-h,t+r-h,h,0,0,i,o,l)||me(e+d,t+r-d,d,0,0,i,o,l)||me(e+c,t+c,c,0,0,i,o,l)}(f,p,m,g,l.map(function(e){return b(e,0,Math.min(Math.abs(m)/2,Math.abs(g)/2))}),E,n.x,n.y)),M||!k&&!r||(M=a(e,n)),M}var C=E/2;return k&&w||r?ye(f-C,p-C,m+C,g+C,n.x,n.y):k?ye(f,p,m,g,n.x,n.y):!!w&&function(e,t,n,r,a,i,o){var l=a/2;return ye(e-l,t-l,n,a,i,o)||ye(e+n-l,t-l,a,r,i,o)||ye(e+l,t+r-l,n,a,i,o)||ye(e-l,t+l,a,r,i,o)}(f,p,m,g,E,n.x,n.y)}function Ae(e,n,r,a,i,o){var l=e.parsedStyle,s=l.pointerEvents,c=l.x,u=void 0===c?0:c,h=l.y,d=void 0===h?0:h,f=l.width,v=l.height;if("non-transparent-pixel"===(void 0===s?"auto":s)){var p=i.config.offscreenCanvas,y=o.offscreenCanvasCreator.getOrCreateCanvas(p),m=o.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return y.width=f,y.height=v,i.defaultStyleRendererFactory[t.Shape.IMAGE].render(m,le(le({},e.parsedStyle),{},{x:0,y:0}),e,void 0,void 0,void 0),m.getImageData(n.x-u,n.y-d,1,1).data.every(function(e){return 0!==e})}return!0}function Pe(e,t,n,r){var a=e.getGeometryBounds();return!(a.min[0]>t.x||a.min[1]>t.y||t.x>a.max[0]||t.y>a.max[1])}var Re=function(e){function n(){var e;o(this,n);for(var t=arguments.length,r=Array(t),a=0;t>a;a++)r[a]=arguments[a];return(e=u(this,n,[].concat(r))).name="canvas-picker",e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,fe),t.Shape.ELLIPSE,pe),t.Shape.RECT,Te),t.Shape.LINE,Ee),t.Shape.POLYLINE,Oe),t.Shape.POLYGON,Ce),t.Shape.PATH,Me),t.Shape.TEXT,Pe),t.Shape.GROUP,null),t.Shape.IMAGE,Ae),f(f(e,t.Shape.HTML,null),t.Shape.MESH,null));this.context.pointInPathPickerFactory=n,this.addRenderingPlugin(new de)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Le=Object.freeze({__proto__:null,Plugin:Re});function De(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var Ie=0;function Ne(e){return"__private_"+Ie+++"_"+e}
|
|
36
|
-
/*!
|
|
37
|
-
* @antv/g-plugin-image-loader
|
|
38
|
-
* @description A G plugin for loading image
|
|
39
|
-
* @version 2.3.0
|
|
40
|
-
* @date 12/10/2025, 8:43:47 AM
|
|
15
|
+
* @version 3.1.0
|
|
16
|
+
* @date 12/22/2025, 3:02:36 AM
|
|
41
17
|
* @author AntVis
|
|
42
18
|
* @docs https://g.antv.antgroup.com/
|
|
43
|
-
*/var je=function(){return i(function e(){o(this,e),this.cacheStore=new Map},[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,n){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([n.entity])}),this.onRefAdded(n),!0)}},{key:"get",value:function(e,t){var n=this.cacheStore.get(e);return n?(n.counter.has(t.entity)||(n.counter.add(t.entity),this.onRefAdded(t)),n.value):null}},{key:"update",value:function(e,t,n){var r=this.cacheStore.get(e);return!!r&&(r.value=le(le({},r.value),t),r.counter.has(n.entity)||(r.counter.add(n.entity),this.onRefAdded(n)),!0)}},{key:"release",value:function(e,t){var n=this.cacheStore.get(e);return!!n&&(n.counter.delete(t.entity),n.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach(function(n){t.release(n,e)})}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Fe=[],Be=[],Ge=function(){function e(){o(this,e)}return i(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Fe.length>0||Be.length>0)&&(Be.forEach(function(e){return e()}),Be=Fe.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame(function(){e.executeTask(t)}))}},{key:"sliceImage",value:function(t,n,r,a){for(var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,l=t.naturalWidth||t.width,s=t.naturalHeight||t.height,c=n-i,u=r-i,h=Math.ceil(l/c),d=Math.ceil(s/u),f={tileSize:[n,r],gridSize:[d,h],tiles:Array(d).fill(null).map(function(){return Array(h).fill(null)})},v=function(e){for(var i=function(i){Fe.push(function(){var h=i*c,d=e*u,v=[Math.min(n,l-h),Math.min(r,s-d)],p=v[0],y=v[1],m=o.createCanvas();m.width=n,m.height=r,m.getContext("2d").drawImage(t,h,d,p,y,0,0,p,y),f.tiles[e][i]={x:h,y:d,tileX:i,tileY:e,data:m},a()})},d=0;h>d;d++)i(d)},p=0;d>p;p++)v(p);return e.stop(),e.executeTask(),f}}])}();Ge.TASK_NUM_PER_FRAME=10;var _e=new je;_e.onRefAdded=function(e){var n=this;e.addEventListener(t.ElementEvent.DESTROY,function(){n.releaseRef(e)},{once:!0})};var We=function(){return i(function e(t,n){o(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=n},[{key:"getImageSync",value:function(e,t,n){var r=g(e)?e:e.src;if(_e.has(r)){var a=_e.get(r,t);if(a.img.complete)return null==n||n(a),a}return this.getOrCreateImage(e,t).then(function(e){null==n||n(e)}).catch(function(e){console.error(e)}),null}},{key:"getOrCreateImage",value:function(e,t){var n=this,r=g(e)?e:e.src;if(!g(e)&&!_e.has(r)){var a={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:He(e)};_e.put(r,a,t)}if(_e.has(r)){var i=_e.get(r,t);return i.img.complete?Promise.resolve(i):new Promise(function(e,t){i.img.addEventListener("load",function(){i.size=[i.img.naturalWidth||i.img.width,i.img.naturalHeight||i.img.height],i.tileSize=He(i.img),e(i)}),i.img.addEventListener("error",function(e){t(e)})})}return new Promise(function(e,a){var i=n.context.config.createImage();if(i){var o={img:i,size:[0,0],tileSize:He(i)};_e.put(r,o,t),i.onload=function(){o.size=[i.naturalWidth||i.width,i.naturalHeight||i.height],o.tileSize=He(o.img),e(o)},i.onerror=function(e){a(e)},i.crossOrigin="Anonymous",i.src=r}})}},{key:"createDownSampledImage",value:(n=Z(q().mark(function e(t,n){var r,a,i,o,l,s,c,u,h,d,f,v,p,m;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(t,n);case 1:if(void 0===(r=e.sent).downSamplingRate){e.next=2;break}return e.abrupt("return",r);case 2:if(l=void 0===(o=(i="boolean"==typeof(a=this.context.config.enableLargeImageOptimization)?{}:a).maxDownSampledImageSize)?2048:o,c=void 0===(s=i.downSamplingRateThreshold)?.5:s,u=this.runtime.globalThis.createImageBitmap,h=y(r.size,2),v=r.img,p=Math.min((l+l)/((d=h[0])+(f=h[1])),Math.max(.01,Math.min(c,.5))),m=le(le({},r),{},{downSamplingRate:p}),_e.update(r.img.src,m,n),!u){e.next=7;break}return e.prev=3,e.next=4,u(r.img,{resizeWidth:d*p,resizeHeight:f*p});case 4:v=e.sent,e.next=6;break;case 5:e.prev=5,e.catch(3),p=1;case 6:e.next=8;break;case 7:p=1;case 8:return m=le(le({},this.getImageSync(t,n)),{},{downSampled:v,downSamplingRate:p}),_e.update(r.img.src,m,n),e.abrupt("return",m);case 9:case"end":return e.stop()}},e,this,[[3,5]])})),function(e,t){return n.apply(this,arguments)})},{key:"createImageTiles",value:(e=Z(q().mark(function e(n,r,a,i){var o,l,s;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(n,i);case 1:return o=e.sent,Ge.api={requestAnimationFrame:(l=i.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:l.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},s=le(le({},o),Ge.sliceImage(o.img,o.tileSize[0],o.tileSize[0],a)),_e.update(o.img.src,s,i),e.abrupt("return",s);case 2:case"end":return e.stop()}},e,this)})),function(t,n,r,a){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){_e.release(g(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){_e.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,n,r,a,i,o,l){var s=this.generatePatternKey(n);if(s&&this.patternCache[s])return this.patternCache[s];var c,u=n.image,h=n.repetition,d=n.transform,f=!1;if(g(u)){var v=this.getImageSync(u,e,l);c=null==v?void 0:v.img}else a?(c=a,f=!0):c=u;var p,y,m=c&&r.createPattern(c,h);m&&(d?p=t.parsedTransformToMat4(t.parseTransform(d),new t.DisplayObject({})):((y=k())[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,p=y),f&&function(e,t,n){var r=n[0],a=n[1],i=n[2];e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(p,p,[1/i,1/i,1]),m.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return s&&m&&(this.patternCache[s]=m),m}},{key:"getOrCreateGradient",value:function(e,n){var r=this.generateGradientKey(e),a=e.type,i=e.steps,o=e.min,l=e.width,s=e.height,c=e.cx,u=e.cy,h=e.size;if(this.gradientCache[r])return this.gradientCache[r];var d=null;if(a===t.GradientType.LinearGradient){var f=t.computeLinearGradient(o,l,s,e.angle);d=n.createLinearGradient(f.x1,f.y1,f.x2,f.y2)}else if(a===t.GradientType.RadialGradient){var v=t.computeRadialGradient(o,l,s,c,u,h),p=v.x,y=v.y;d=n.createRadialGradient(p,y,0,p,y,v.r)}return d&&(i.forEach(function(e){var n,r=e.offset;r.unit===t.UnitType.kPercentage&&(null===(n=d)||void 0===n||n.addColorStop(r.value/100,""+e.color))}),this.gradientCache[r]=d),this.gradientCache[r]}},{key:"generateGradientKey",value:function(e){var t=e.min,n=e.width,r=e.height,a=e.steps,i=e.angle,o=e.cx,l=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==l?void 0:""+l)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(n,"-").concat(r,"-").concat(a.map(function(e){var t=e.color;return"".concat(e.offset).concat(t)}).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,n=e.repetition;return g(t)?"pattern-".concat(t,"-").concat(n):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(n):void 0}}]);var e,n}();function He(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,n=e.naturalHeight||e.height,r=256;return[256,512].forEach(function(e){1e3>Math.ceil(n/e)*Math.ceil(t/e)&&(r=e)}),[r,r]}We.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var ze=function(){function e(){o(this,e)}return i(e,[{key:"apply",value:function(n){var r=n.renderingService,a=n.imagePool,i=n.renderingContext.root.ownerDocument.defaultView,o=function(e,t,n){var r=e.parsedStyle,a=r.width,i=r.height;a&&!i?e.setAttribute("height",n/t*a):!a&&i&&e.setAttribute("width",t/n*i)},l=function(e){var n=e.target,i=n.attributes;if(n.nodeName===t.Shape.IMAGE){var l=i.keepAspectRatio;a.getImageSync(i.src,n,function(e){var t=e.img;l&&o(n,t.width,t.height),n.dirty(),r.dirty()})}},s=function(e){var n=e.target,i=e.prevValue,l=e.newValue;n.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(i!==l&&a.releaseImage(i,n),g(l)&&a.getOrCreateImage(l,n).then(function(e){var t=e.img;n.attributes.keepAspectRatio&&o(n,t.width,t.height),n.dirty(),r.dirty()}).catch(function(){}))};r.hooks.init.tap(e.tag,function(){i.addEventListener(t.ElementEvent.MOUNTED,l),i.addEventListener(t.ElementEvent.ATTR_MODIFIED,s)}),r.hooks.destroy.tap(e.tag,function(){i.removeEventListener(t.ElementEvent.MOUNTED,l),i.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)})}}])}();ze.tag="LoadImage";var $e=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="image-loader",e}return d(t,e),i(t,[{key:"init",value:function(e){this.context.imagePool=new We(this.context,e),this.addRenderingPlugin(new ze)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Ue=Object.freeze({__proto__:null,ImagePool:We,Plugin:$e}),Ye=Ne("renderState"),Ve=function(){function e(t){o(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,Ye,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=k(),this.dprMatrix=k(),this.tmpMat4=k(),this.vec3a=C(),this.vec3b=C(),this.vec3c=C(),this.vec3d=C(),this.canvasRendererPluginOptions=t}return i(e,[{key:"apply",value:function(n,r){var a=this;this.context=n;var i=this.context,o=i.config,l=i.camera,s=i.renderingService,c=i.renderingContext,u=i.rBushRoot,h=i.pathGeneratorFactory,d=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=h;var f=n.contextService,v=c.root.ownerDocument.defaultView,p=function(e){var t=e.target.rBushNode;null!=t&&t.aabb&&a.removedRBushNodeAABBs.push(t.aabb)},y=function(e){var t=e.target.rBushNode;t.aabb&&a.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,function(){v.addEventListener(t.ElementEvent.UNMOUNTED,p),v.addEventListener(t.ElementEvent.CULLED,y);var e=f.getDPR(),n=o.width,r=o.height,i=f.getContext();a.clearRect(i,0,0,n*e,r*e,o.background)}),s.hooks.destroy.tap(e.tag,function(){v.removeEventListener(t.ElementEvent.UNMOUNTED,p),v.removeEventListener(t.ElementEvent.CULLED,y),a.renderQueue=[],a.removedRBushNodeAABBs=[],De(a,Ye)[Ye]={restoreStack:[],prevObject:null,currentContext:null}});var m=function(e,t){for(var n=[e];n.length>0;){var i,o=n.pop();o.isVisible()&&!o.isCulled()&&(d?a.renderDisplayObjectOptimized(o,t,a.context,De(a,Ye)[Ye],r):a.renderDisplayObject(o,t,a.context,De(a,Ye)[Ye],r));for(var l=(null===(i=o.sortable)||void 0===i||null===(i=i.sorted)||void 0===i?void 0:i.length)>0?o.sortable.sorted:o.childNodes,s=l.length-1;s>=0;s--)n.push(l[s])}};s.hooks.endFrame.tap(e.tag,function(){if(function(){var e,t=f.getContext(),n=f.getDPR(),r=o.width,i=o.height,l=a.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,h=s.getStats(),d=h.rendered,p=d/h.total;a.clearFullScreen=a.clearFullScreenLastFrame||!(null!==(e=v.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||d>c&&p>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),a.clearFullScreen&&a.clearRect(t,0,0,r*n,i*n,o.background))}(),0!==c.root.childNodes.length){d=o.renderer.getConfig().enableRenderingOptimization,De(a,Ye)[Ye]={restoreStack:[],prevObject:null,currentContext:De(a,Ye)[Ye].currentContext},De(a,Ye)[Ye].currentContext.clear(),a.clearFullScreenLastFrame=!1;var e,n,i=f.getContext(),u=f.getDPR();if((e=a.dprMatrix)[0]=(n=[u,u,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=n[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,E(a.vpMatrix,a.dprMatrix,l.getOrthoMatrix()),a.clearFullScreen)d?(i.save(),m(c.root,i),i.restore()):m(c.root,i),a.removedRBushNodeAABBs=[];else{var h=a.safeMergeAABB.apply(a,[a.mergeDirtyAABBs(a.renderQueue)].concat(J(a.removedRBushNodeAABBs.map(function(e){var n=e.minX,r=e.minY,a=e.maxX,i=e.maxY,o=new t.AABB;return o.setMinMax([n,r,0],[a,i,0]),o}))));if(a.removedRBushNodeAABBs=[],t.AABB.isEmpty(h))return void(a.renderQueue=[]);var p=a.convertAABB2Rect(h),y=p.x,g=p.y,b=p.width,S=p.height,x=T(a.vec3a,[y,g,0],a.vpMatrix),k=T(a.vec3b,[y+b,g,0],a.vpMatrix),w=T(a.vec3c,[y,g+S,0],a.vpMatrix),M=T(a.vec3d,[y+b,g+S,0],a.vpMatrix),C=Math.min(x[0],k[0],M[0],w[0]),O=Math.min(x[1],k[1],M[1],w[1]),A=Math.max(x[0],k[0],M[0],w[0]),P=Math.max(x[1],k[1],M[1],w[1]),R=Math.floor(C),L=Math.floor(O),D=Math.ceil(A-C),I=Math.ceil(P-O);i.save(),a.clearRect(i,R,L,D,I,o.background),i.beginPath(),i.rect(R,L,D,I),i.clip(),i.setTransform(a.vpMatrix[0],a.vpMatrix[1],a.vpMatrix[4],a.vpMatrix[5],a.vpMatrix[12],a.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&v.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:R,y:L,width:D,height:I}})),a.searchDirtyObjects(h).sort(function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&a.renderDisplayObject(e,i,a.context,De(a,Ye)[Ye],r)}),i.restore(),a.renderQueue.forEach(function(e){a.saveDirtyAABB(e)}),a.renderQueue=[]}De(a,Ye)[Ye].restoreStack.forEach(function(){i.restore()}),De(a,Ye)[Ye].restoreStack=[]}else a.clearFullScreenLastFrame=!0}),s.hooks.render.tap(e.tag,function(e){a.clearFullScreen||a.renderQueue.push(e)})}},{key:"clearRect",value:function(e,t,n,r,a,i){e.clearRect(t,n,r,a),i&&(e.fillStyle=i,e.fillRect(t,n,r,a))}},{key:"renderDisplayObjectOptimized",value:function(e,n,r,a,i){var o=e.nodeName,l=!1,s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){(!a.prevObject||!M(u.getWorldTransform(),a.prevObject.getWorldTransform()))&&(this.applyWorldTransform(n,u),a.prevObject=null);var h=this.pathGeneratorFactory[u.nodeName];h&&(n.save(),l=!0,n.beginPath(),h(n,u.parsedStyle),n.closePath(),n.clip())}if(s){(!a.prevObject||!M(e.getWorldTransform(),a.prevObject.getWorldTransform()))&&this.applyWorldTransform(n,e);var d=!a.prevObject;if(!d){var f=a.prevObject.nodeName;d=o===t.Shape.TEXT?f!==t.Shape.TEXT:o===t.Shape.IMAGE?f!==t.Shape.IMAGE:f===t.Shape.TEXT||f===t.Shape.IMAGE}s.applyStyleToContext(n,e,d,a),a.prevObject=e}c&&(n.beginPath(),c(n,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&n.closePath()),s&&s.drawToContext(n,e,De(this,Ye)[Ye],this,i),l&&n.restore(),e.dirty(!1)}},{key:"renderDisplayObject",value:function(e,n,r,a,i){var o=e.nodeName,l=a.restoreStack[a.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),a.restoreStack.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(n,u);var h=this.pathGeneratorFactory[u.nodeName];h&&(n.save(),a.restoreStack.push(e),n.beginPath(),h(n,u.parsedStyle),n.closePath(),n.clip())}s&&(this.applyWorldTransform(n,e),n.save(),this.applyAttributesToContext(n,e)),c&&(n.beginPath(),c(n,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&n.closePath()),s&&(s.render(n,e.parsedStyle,e,r,this,i),n.restore()),e.dirty(!1)}},{key:"applyAttributesToContext",value:function(e,t){var n=t.parsedStyle,r=n.stroke,a=n.fill,i=n.opacity,o=n.lineDash,l=n.lineDashOffset;o&&e.setLineDash(o),m(l)||(e.lineDashOffset=l),m(i)||(e.globalAlpha*=i),m(r)||Array.isArray(r)||r.isNone||(e.strokeStyle=t.attributes.stroke),m(a)||Array.isArray(a)||a.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),n=e.getMax(),r=Math.floor(t[0]),a=Math.floor(t[1]);return{x:r,y:a,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-a}}},{key:"mergeDirtyAABBs",value:function(e){var n=new t.AABB;return e.forEach(function(e){var t=e.getRenderBounds();n.add(t);var r=e.renderable.dirtyRenderBounds;r&&n.add(r)}),n}},{key:"searchDirtyObjects",value:function(e){var t=y(e.getMin(),2),n=t[0],r=t[1],a=y(e.getMax(),2);return this.rBush.search({minX:n,minY:r,maxX:a[0],maxY:a[1]}).map(function(e){return e.displayObject})}},{key:"saveDirtyAABB",value:function(e){var n=e.renderable;n.dirtyRenderBounds||(n.dirtyRenderBounds=new t.AABB);var r=e.getRenderBounds();r&&n.dirtyRenderBounds.update(r.center,r.halfExtents)}},{key:"applyWorldTransform",value:function(e,t,n){n?(w(this.tmpMat4,t.getLocalTransform()),E(this.tmpMat4,n,this.tmpMat4),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,t.getWorldTransform()),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var e=new t.AABB,n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return r.forEach(function(t){e.add(t)}),e}}])}();function Xe(e,t,n,r,a,i,o){var l,s;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,h=c.height;s=r.contextService.getDPR();var d=r.config.offscreenCanvas;(l=i.offscreenCanvasCreator.getOrCreateCanvas(d)).width=u*s,l.height=h*s;var f=i.offscreenCanvasCreator.getOrCreateContext(d),v={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach(function(e){a.renderDisplayObject(e,f,r,v,i)}),v.restoreStack.forEach(function(){f.restore()})}return o.getOrCreatePatternSync(t,e,n,l,s,t.getGeometryBounds().min,function(){t.dirty(),r.renderingService.dirty()})}function qe(e,n,r,a){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var o=n.getGeometryBounds(),l=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1,c=o&&o.min||[0,0];i=a.getOrCreateGradient(le(le({type:e.type},e.value),{},{min:c,width:l,height:s}),r)}return i}Ve.tag="CanvasRenderer";var Qe=["shadowBlur","shadowOffsetX","shadowOffsetY"],Ze=["lineCap","lineJoin","miterLimit"],Je={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},Ke={};function et(e,t,n,r){var a=r.has(t)?r.get(t):Je[t];return a!==n&&("lineDash"===t?e.setLineDash(n):e[t]=n,r.set(t,n)),a}var tt=function(){return i(function e(t){o(this,e),this.imagePool=t},[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,n,r,a,i){}},{key:"applyCommonStyleToContext",value:function(e,t,n,r){var a=n?Ke:r.prevObject.parsedStyle,i=t.parsedStyle;(n||i.opacity!==a.opacity)&&et(e,"globalAlpha",m(i.opacity)?Je.globalAlpha:i.opacity,r.currentContext),(n||i.blend!==a.blend)&&et(e,"globalCompositeOperation",m(i.blend)?Je.globalCompositeOperation:i.blend,r.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,n,r){var a=n?Ke:r.prevObject.parsedStyle,i=t.parsedStyle,o=i.lineWidth,l=i.fill&&!i.fill.isNone;if(i.stroke&&!i.stroke.isNone&&(void 0===o?Je.lineWidth:o)>0){if(n||t.attributes.stroke!==r.prevObject.attributes.stroke)et(e,"strokeStyle",m(i.stroke)||Array.isArray(i.stroke)||i.stroke.isNone?Je.strokeStyle:t.attributes.stroke,r.currentContext);(n||i.lineWidth!==a.lineWidth)&&et(e,"lineWidth",m(i.lineWidth)?Je.lineWidth:i.lineWidth,r.currentContext),(n||i.lineDash!==a.lineDash)&&et(e,"lineDash",i.lineDash||Je.lineDash,r.currentContext),(n||i.lineDashOffset!==a.lineDashOffset)&&et(e,"lineDashOffset",m(i.lineDashOffset)?Je.lineDashOffset:i.lineDashOffset,r.currentContext);for(var s=0;Ze.length>s;s++){var c=Ze[s];(n||i[c]!==a[c])&&et(e,c,m(i[c])?Je[c]:i[c],r.currentContext)}}l&&(n||t.attributes.fill!==r.prevObject.attributes.fill)&&et(e,"fillStyle",m(i.fill)||Array.isArray(i.fill)||i.fill.isNone?Je.fillStyle:t.attributes.fill,r.currentContext)}},{key:"applyStyleToContext",value:function(e,n,r,a){var i=n.nodeName;this.applyCommonStyleToContext(e,n,r,a),i===t.Shape.IMAGE||this.applyStrokeFillStyleToContext(e,n,r,a)}},{key:"applyShadowAndFilterStyleToContext",value:function(e,t,n,r){var a=t.parsedStyle;if(n){et(e,"shadowColor",""+a.shadowColor,r.currentContext);for(var i=0;Qe.length>i;i++){var o=Qe[i];et(e,o,a[o]||Je[o],r.currentContext)}}a.filter&&a.filter.length&&et(e,"filter",t.attributes.filter,r.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t){et(e,"shadowColor",Je.shadowColor,r.currentContext);for(var i=0;Qe.length>i;i++){var o=Qe[i];et(e,o,Je[o],r.currentContext)}}if(n)if(t&&a){var l=e.filter;!m(l)&&l.indexOf("drop-shadow")>-1&&et(e,"filter",l.replace(/drop-shadow\([^)]*\)/,"").trim()||Je.filter,r.currentContext)}else et(e,"filter",Je.filter,r.currentContext)}},{key:"fillToContext",value:function(e,n,r,a,i){var o=this,l=n.parsedStyle,s=l.fill,c=l.fillRule,u=null;if(Array.isArray(s)&&s.length>0)s.forEach(function(t){var a=et(e,"fillStyle",qe(t,n,e,o.imagePool),r.currentContext);u=null!=u?u:a,c?e.fill(c):e.fill()});else{if(t.isPattern(s)){var h=Xe(s,n,e,n.ownerDocument.defaultView.context,a,i,this.imagePool);h&&(e.fillStyle=h,u=!0)}c?e.fill(c):e.fill()}null!==u&&et(e,"fillStyle",u,r.currentContext)}},{key:"strokeToContext",value:function(e,n,r,a,i){var o=this,l=n.parsedStyle.stroke,s=null;if(Array.isArray(l)&&l.length>0)l.forEach(function(t){var a=et(e,"strokeStyle",qe(t,n,e,o.imagePool),r.currentContext);s=null!=s?s:a,e.stroke()});else{if(t.isPattern(l)){var c=Xe(l,n,e,n.ownerDocument.defaultView.context,a,i,this.imagePool);if(c){var u=et(e,"strokeStyle",c,r.currentContext);s=null!=s?s:u}}e.stroke()}null!==s&&et(e,"strokeStyle",s,r.currentContext)}},{key:"drawToContext",value:function(e,n,r,a,i){var o,l=n.nodeName,s=n.parsedStyle,c=s.opacity,u=void 0===c?Je.globalAlpha:c,h=s.fillOpacity,d=void 0===h?Je.fillOpacity:h,f=s.strokeOpacity,v=void 0===f?Je.strokeOpacity:f,p=s.lineWidth,y=s.fill&&!s.fill.isNone,g=s.stroke&&!s.stroke.isNone&&(void 0===p?Je.lineWidth:p)>0;if(y||g){var b=!m(s.shadowColor)&&s.shadowBlur>0,S="inner"===s.shadowType,x=0===(null===(o=s.fill)||void 0===o?void 0:o.alpha),k=!(!s.filter||!s.filter.length),w=b&&g&&(l===t.Shape.PATH||l===t.Shape.LINE||l===t.Shape.POLYLINE||x||S),E=null;if(y)w||this.applyShadowAndFilterStyleToContext(e,n,b,r),E=et(e,"globalAlpha",u*d,r.currentContext),this.fillToContext(e,n,r,a,i),w||this.clearShadowAndFilterStyleForContext(e,b,k,r);if(g){var M=!1,C=et(e,"globalAlpha",u*v,r.currentContext);if(E=y?E:C,w&&(this.applyShadowAndFilterStyleToContext(e,n,b,r),M=!0,S)){var O=e.globalCompositeOperation;e.globalCompositeOperation="source-atop",this.strokeToContext(e,n,r,a,i),e.globalCompositeOperation=O,this.clearShadowAndFilterStyleForContext(e,b,k,r,!0)}this.strokeToContext(e,n,r,a,i),M&&this.clearShadowAndFilterStyleForContext(e,b,k,r)}null!==E&&et(e,"globalAlpha",E,r.currentContext)}}}])}(),nt=function(e){function n(){return o(this,n),u(this,n,arguments)}return d(n,e),i(n,[{key:"render",value:function(e,n,r,a,i,o){var l=n.fill,s=n.fillRule,c=n.opacity,u=void 0===c?1:c,h=n.fillOpacity,d=void 0===h?1:h,f=n.stroke,v=n.strokeOpacity,p=void 0===v?1:v,y=n.lineWidth,g=void 0===y?1:y,b=n.lineCap,S=n.lineJoin,x=n.shadowType,k=n.shadowBlur,w=n.filter,E=n.miterLimit,M=l&&!l.isNone,C=f&&!f.isNone&&g>0,O=0===(null==l?void 0:l.alpha),T=!(!w||!w.length),A=!m(n.shadowColor)&&k>0,P=r.nodeName,R="inner"===x,L=C&&A&&(P===t.Shape.PATH||P===t.Shape.LINE||P===t.Shape.POLYLINE||O||R);M&&(e.globalAlpha=u*d,L||rt(r,e,A),at(e,r,l,s,a,i,o,this.imagePool),L||this.clearShadowAndFilter(e,T,A)),C&&(e.globalAlpha=u*p,e.lineWidth=g,m(E)||(e.miterLimit=E),m(b)||(e.lineCap=b),m(S)||(e.lineJoin=S),L&&(R&&(e.globalCompositeOperation="source-atop"),rt(r,e,!0),R&&(it(e,r,f,a,i,o,this.imagePool),e.globalCompositeOperation=Je.globalCompositeOperation,this.clearShadowAndFilter(e,T,!0))),it(e,r,f,a,i,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(e,t,n){if(n&&(e.shadowColor="transparent",e.shadowBlur=0),t){var r=e.filter;!m(r)&&r.indexOf("drop-shadow")>-1&&(e.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(tt);function rt(e,t,n){var r=e.parsedStyle,a=r.filter,i=r.shadowColor,o=r.shadowBlur,l=r.shadowOffsetX,s=r.shadowOffsetY;a&&a.length&&(t.filter=e.style.filter),n&&(t.shadowColor=""+i,t.shadowBlur=o||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}function at(e,n,r,a,i,o,l,s){var c=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(r)?r.forEach(function(t){e.fillStyle=qe(t,n,e,s),c||(a?e.fill(a):e.fill())}):(t.isPattern(r)&&(e.fillStyle=Xe(r,n,e,i,o,l,s)),c||(a?e.fill(a):e.fill()))}function it(e,n,r,a,i,o,l){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(r)?r.forEach(function(t){e.strokeStyle=qe(t,n,e,l),s||e.stroke()}):(t.isPattern(r)&&(e.strokeStyle=Xe(r,n,e,a,i,o,l)),s||e.stroke())}var ot=function(e){function t(){return o(this,t),u(this,t,arguments)}return d(t,e),i(t,[{key:"renderDownSampled",value:function(e,t,n,r){var a=r.src,i=r.imageCache;i.downSampled?e.drawImage(i.downSampled,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3])):this.imagePool.createDownSampledImage(a,n).then(function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(e){console.error(e)})}},{key:"renderTile",value:function(e,t,n,r){var a=r.src,i=r.imageCache,o=r.imageRect,l=r.drawRect,s=i.size,c=e.getTransform(),u=c.a,h=c.b,d=c.c,f=c.d,v=c.e,p=c.f;if(e.resetTransform(),null!=i&&i.gridSize){for(var y=[s[0]/o[2],s[1]/o[3]],m=[i.tileSize[0]/y[0],i.tileSize[1]/y[1]],g=[Math.floor((l[0]-o[0])/m[0]),Math.ceil((l[0]+l[2]-o[0])/m[0])],b=g[0],S=g[1],x=[Math.floor((l[1]-o[1])/m[1]),Math.ceil((l[1]+l[3]-o[1])/m[1])],k=x[1],w=x[0];k>=w;w++)for(var E=b;S>=E;E++){var M=i.tiles[w][E];if(M){var C=[Math.floor(o[0]+M.tileX*m[0]),Math.floor(o[1]+M.tileY*m[1]),Math.ceil(m[0]),Math.ceil(m[1])];e.drawImage(M.data,C[0],C[1],C[2],C[3])}}e.setTransform(u,h,d,f,v,p)}else this.imagePool.createImageTiles(a,[],function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())},n).catch(function(e){console.error(e)})}},{key:"render",value:function(e,n,r){var a=n.x,i=void 0===a?0:a,o=n.y,l=void 0===o?0:o,s=n.width,c=n.height,u=n.src,h=n.shadowColor,d=n.shadowBlur,f=this.imagePool.getImageSync(u,r),v=null==f?void 0:f.img,p=s,g=c;if(v){var b,S,k,w,E,M,O,A,P,R,L,D,I,N,j,F,B,G,_,W,H,z,$,U,Y,V,X,q,Q,Z,J,K,ee,te,ne,re,ae,ie;p||(p=v.width),g||(g=v.height),rt(r,e,!m(h)&&d>0);try{var oe=r.ownerDocument.defaultView.getContextService().getDomElement(),le=oe.width,se=oe.height,ce=e.getTransform(),ue=(z=ce.a,$=ce.c,U=0,Y=0,V=ce.b,X=ce.d,q=0,Q=0,Z=0,J=0,K=1,ee=0,te=ce.e,ne=ce.f,re=0,ae=1,(ie=new x(16))[0]=z,ie[1]=$,ie[2]=U,ie[3]=Y,ie[4]=V,ie[5]=X,ie[6]=q,ie[7]=Q,ie[8]=Z,ie[9]=J,ie[10]=K,ie[11]=ee,ie[12]=te,ie[13]=ne,ie[14]=re,ie[15]=ae,ie),he=(F=[i,l,p,g],B=ue,G=T(C(),[F[0],F[1],0],B),_=T(C(),[F[0]+F[2],F[1],0],B),W=T(C(),[F[0],F[1]+F[3],0],B),H=T(C(),[F[0]+F[2],F[1]+F[3],0],B),[Math.min(G[0],_[0],W[0],H[0]),Math.min(G[1],_[1],W[1],H[1]),Math.max(G[0],_[0],W[0],H[0])-Math.min(G[0],_[0],W[0],H[0]),Math.max(G[1],_[1],W[1],H[1])-Math.min(G[1],_[1],W[1],H[1])]),de=(b=he,S=y([0,0,le,se],4),k=S[0],w=S[1],E=S[2],M=S[3],O=y(b,4),P=O[1],R=O[2],L=O[3],D=Math.max(k,A=O[0]),I=Math.max(w,P),N=Math.min(k+E,A+R),j=Math.min(w+M,P+L),N>D&&j>I?[D,I,N-D,j-I]:null);if(!de)return;if(!r.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void t.renderFull(e,n,r,{image:v,drawRect:[i,l,p,g]});if((f.downSamplingRate||.5)>he[2]/f.size[0])return void this.renderDownSampled(e,n,r,{src:u,imageCache:f,drawRect:[i,l,p,g]});if(!We.isSupportTile)return void t.renderFull(e,n,r,{image:v,drawRect:[i,l,p,g]});this.renderTile(e,n,r,{src:u,imageCache:f,imageRect:he,drawRect:de})}catch(e){}}}},{key:"drawToContext",value:function(e,t,n,r,a){this.render(e,t.parsedStyle,t)}}],[{key:"renderFull",value:function(e,t,n,r){e.drawImage(r.image,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3]))}}])}(nt),lt=function(e){function t(){return o(this,t),u(this,t,arguments)}return d(t,e),i(t,[{key:"render",value:function(e,t,n,r,a,i){n.getBounds();var o=t.lineWidth,l=void 0===o?1:o,s=t.textAlign,c=void 0===s?"start":s,u=t.textBaseline,h=void 0===u?"alphabetic":u,d=t.lineJoin,f=void 0===d?"miter":d,v=t.miterLimit,p=void 0===v?10:v,y=t.letterSpacing,g=void 0===y?0:y,b=t.stroke,S=t.fill,x=t.fillRule,k=t.fillOpacity,w=void 0===k?1:k,E=t.strokeOpacity,M=void 0===E?1:E,C=t.opacity,O=void 0===C?1:C,T=t.metrics,A=t.x,P=void 0===A?0:A,R=t.y,L=void 0===R?0:R,D=t.dx,I=t.dy,N=t.shadowColor,j=t.shadowBlur,F=t.textDecorationLine,B=T.lines,G=T.height,_=T.lineHeight,W=T.lineMetrics;e.font=T.font,e.lineWidth=l,e.textAlign="middle"===c?"center":c;var H=h;"alphabetic"===H&&(H="bottom"),e.lineJoin=f,m(p)||(e.miterLimit=p);var z=L;"middle"===h?z+=-G/2-_/2:"bottom"===h||"alphabetic"===h||"ideographic"===h?z+=-G:"top"!==h&&"hanging"!==h||(z+=-_);var $=P+(D||0);z+=I||0,1===B.length&&("bottom"===H?(H="middle",z-=.5*G):"top"===H&&(H="middle",z+=.5*G)),e.textBaseline=H,rt(n,e,!m(N)&&j>0);for(var U=0;B.length>U;U++){var Y=l/2+$;z+=_,m(b)||b.isNone||!l||this.drawLetterSpacing(e,n,B[U],W[U],c,Y,z,g,S,x,w,b,M,O,!0,r,a,i),m(S)||this.drawLetterSpacing(e,n,B[U],W[U],c,Y,z,g,S,x,w,b,M,O,!1,r,a,i)}F&&"none"!==F&&this.drawTextDecorations(e,t,n,B,_,$,L+(I||0),r,a,i)}},{key:"drawLetterSpacing",value:function(e,t,n,r,a,i,o,l,s,c,u,h,d,f,v,p,y,m){if(0!==l){var g=e.textAlign;e.textAlign="left";var b=i;"center"===a||"middle"===a?b=i-r.width/2:"right"!==a&&"end"!==a||(b=i-r.width);for(var S=Array.from(n),x=e.measureText(n).width,k=0,w=0;S.length>w;++w){var E=S[w];v?this.strokeText(e,t,E,b,o,h,d,p,y,m):this.fillText(e,t,E,b,o,s,c,u,f,p,y,m),b+=x-(k=e.measureText(n.substring(w+1)).width)+l,x=k}e.textAlign=g}else v?this.strokeText(e,t,n,i,o,h,d,p,y,m):this.fillText(e,t,n,i,o,s,c,u,f,p,y,m)}},{key:"fillText",value:function(e,t,n,r,a,i,o,l,s,c,u,h){var d;at(e,t,i,o,c,u,h,this.imagePool,!0);var f=!m(l)&&1!==l;f&&(d=e.globalAlpha,e.globalAlpha=l*s),e.fillText(n,r,a),f&&(e.globalAlpha=d)}},{key:"strokeText",value:function(e,t,n,r,a,i,o,l,s,c){var u;it(e,t,i,l,s,c,this.imagePool,!0);var h=!m(o)&&1!==o;h&&(u=e.globalAlpha,e.globalAlpha=o),e.strokeText(n,r,a),h&&(e.globalAlpha=u)}},{key:"drawTextDecorations",value:function(e,t,n,r,a,i,o,l,s,c){var u=t.textDecorationLine,h=t.textDecorationColor,d=t.textDecorationStyle,f=t.textDecorationThickness,v=void 0===f?1:f,p=t.textAlign,y=void 0===p?"start":p,m=t.lineWidth,g=void 0===m?1:m,b=t.metrics;if(u&&"none"!==u){var S=b.lineMetrics,x=u.split(" ");switch(e.lineWidth=v,h&&(e.strokeStyle="rgba(".concat(h.r,", ").concat(h.g,", ").concat(h.b,", ").concat(h.alpha,")")),d){case"dashed":e.setLineDash([5,5]);break;case"dotted":e.setLineDash([2,2]);break;default:e.setLineDash([])}var k=o,w=t.textBaseline,E=void 0===w?"alphabetic":w;"middle"===E?k+=-b.height/2-a/2:"bottom"===E||"alphabetic"===E||"ideographic"===E?k+=-b.height:"top"!==E&&"hanging"!==E||(k+=-a);for(var M=0;r.length>M;M++){k+=a;var C=S[M];if(C){var O=g/2,T=i,A=i+C.width;"center"===y||"middle"===y?(T=i-C.width/2,A=i+C.width/2):"right"!==y&&"end"!==y||(T=i-C.width,A=i),T+=O,A+=O;var P,R=_(x);try{for(R.s();!(P=R.n()).done;){var L=k;switch(P.value){case"underline":L+=2;break;case"overline":L-=a-2;break;case"line-through":L-=a/2;break;default:continue}"wavy"===d?this.drawWavyLine(e,T,A,L):(e.beginPath(),e.moveTo(T,L),e.lineTo(A,L),e.stroke())}}catch(e){R.e(e)}finally{R.f()}}}e.setLineDash([])}}},{key:"drawWavyLine",value:function(e,t,n,r){var a=10,i=Math.floor((n-t)/a);e.beginPath(),e.moveTo(t,r);for(var o=0;i>o;o++){e.quadraticCurveTo(t+o*a+2.5,r+2,t+o*a+5,r),e.quadraticCurveTo(t+o*a+7.5,r-2,t+(o+1)*a,r)}e.stroke()}},{key:"drawToContext",value:function(e,t,n,r,a){this.render(e,t.parsedStyle,t,t.ownerDocument.defaultView.context,r,a)}}])}(nt),st=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(this,n),(e=u(this,n)).name="canvas-renderer",e.options=t,e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=le({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),r=this.context.imagePool,a=new nt(r),i=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,a),t.Shape.ELLIPSE,a),t.Shape.RECT,a),t.Shape.IMAGE,new ot(r)),t.Shape.TEXT,new lt(r)),t.Shape.LINE,a),t.Shape.POLYLINE,a),t.Shape.POLYGON,a),t.Shape.PATH,a),t.Shape.GROUP,void 0),f(f(f(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=i,this.context.styleRendererFactory=i,this.addRenderingPlugin(new Ve(n))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(t.AbstractRendererPlugin),ct=Object.freeze({__proto__:null,CircleRenderer:nt,DefaultRenderer:nt,EllipseRenderer:nt,ImageRenderer:ot,LineRenderer:nt,PathRenderer:nt,Plugin:st,PolygonRenderer:nt,PolylineRenderer:nt,RectRenderer:nt,TextRenderer:lt}),ut=function(){function e(){o(this,e)}return i(e,[{key:"apply",value:function(t,n){var r=this,a=t.renderingService,i=t.renderingContext,o=t.config;this.context=t;var l=i.root.ownerDocument.defaultView,s=function(e){a.hooks.pointerMove.call(e)},c=function(e){a.hooks.pointerUp.call(e)},u=function(e){a.hooks.pointerDown.call(e)},h=function(e){a.hooks.pointerOver.call(e)},d=function(e){a.hooks.pointerOut.call(e)},f=function(e){a.hooks.pointerCancel.call(e)},v=function(e){a.hooks.pointerWheel.call(e)},p=function(e){a.hooks.click.call(e)};a.hooks.init.tap(e.tag,function(){var e=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):l.supportsPointerEvents&&(e.style.touchAction="none"),l.supportsPointerEvents?function(e){n.globalThis.document.addEventListener("pointermove",s,!0),e.addEventListener("pointerdown",u,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",h,!0),n.globalThis.addEventListener("pointerup",c,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(e):function(e){n.globalThis.document.addEventListener("mousemove",s,!0),e.addEventListener("mousedown",u,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",h,!0),n.globalThis.addEventListener("mouseup",c,!0)}(e),l.supportsTouchEvents&&function(e){e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",c,!0),e.addEventListener("touchmove",s,!0),e.addEventListener("touchcancel",f,!0)}(e),o.useNativeClickEvent&&e.addEventListener("click",p,!0),e.addEventListener("wheel",v,{passive:!0,capture:!0})}),a.hooks.destroy.tap(e.tag,function(){var e=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):l.supportsPointerEvents&&(e.style.touchAction=""),l.supportsPointerEvents?function(e){n.globalThis.document.removeEventListener("pointermove",s,!0),e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",h,!0),n.globalThis.removeEventListener("pointerup",c,!0),n.globalThis.removeEventListener("pointercancel",f,!0)}(e):function(e){n.globalThis.document.removeEventListener("mousemove",s,!0),e.removeEventListener("mousedown",u,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",h,!0),n.globalThis.removeEventListener("mouseup",c,!0)}(e),l.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",c,!0),e.removeEventListener("touchmove",s,!0),e.removeEventListener("touchcancel",f,!0)}(e),o.useNativeClickEvent&&e.removeEventListener("click",p,!0),e.removeEventListener("wheel",v,!0)})}}])}();ut.tag="DOMInteraction";var ht=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="dom-interaction",e}return d(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new ut)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),dt=Object.freeze({__proto__:null,Plugin:ht}),ft=function(){function e(){o(this,e),this.displayObjectHTMLElementMap=new WeakMap}return i(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(n,r){var a=this,i=n.camera,o=n.renderingContext,l=n.renderingService;this.context=n;var s=o.root.ownerDocument.defaultView,c=s.context.eventService.nativeHTMLMap,u=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},h=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(i));var r=a.getOrCreateEl(n);a.$camera.appendChild(r),Object.keys(n.attributes).forEach(function(e){a.updateAttribute(e,n)}),u(n,r),c.set(r,n)}},d=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML&&a.$camera){var r=a.getOrCreateEl(n);r&&(r.remove(),c.delete(r))}},f=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&a.updateAttribute(e.attrName,n)},v=function(e){for(var n=e.detail,r=0;n.length>r;r++){var i=n[r].target;(i.nodeName===t.Shape.FRAGMENT?i.childNodes:[i]).forEach(function(e){if(e.nodeName===t.Shape.HTML){var n=a.getOrCreateEl(e);u(e,n)}})}},p=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.parentElement.style.width="".concat(e.width||0,"px"),a.$camera.parentElement.style.height="".concat(t||0,"px")}};l.hooks.init.tap(e.tag,function(){s.addEventListener(t.CanvasEvent.RESIZE,p),s.addEventListener(t.ElementEvent.MOUNTED,h),s.addEventListener(t.ElementEvent.UNMOUNTED,d),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,v)}),l.hooks.endFrame.tap(e.tag,function(){a.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(i.getOrthoMatrix()))}),l.hooks.destroy.tap(e.tag,function(){a.$camera&&a.$camera.remove(),s.removeEventListener(t.CanvasEvent.RESIZE,p),s.removeEventListener(t.ElementEvent.MOUNTED,h),s.removeEventListener(t.ElementEvent.UNMOUNTED,d),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,v)})}},{key:"createCamera",value:function(e){var t=this.context.config,n=t.document,r=t.width,a=t.height,i=this.context.contextService.getDomElement(),o=i.parentNode;if(o){var l="g-canvas-camera",s=o.querySelector("#".concat(l));if(!s){var c=(n||document).createElement("div");c.style.overflow="hidden",c.style.pointerEvents="none",c.style.position="absolute",c.style.left="0px",c.style.top="0px",c.style.width="".concat(r||0,"px"),c.style.height="".concat(a||0,"px");var u=(n||document).createElement("div");s=u,u.id=l,u.style.position="absolute",u.style.left="".concat(i.offsetLeft||0,"px"),u.style.top="".concat(i.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.pointerEvents="none",u.style.width="100%",u.style.height="100%",c.appendChild(u),o.appendChild(c)}return s}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,n=this.displayObjectHTMLElementMap.get(e);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(e,n),e.id&&(n.id=e.id),e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),n}},{key:"updateAttribute",value:function(e,n){var r=this.getOrCreateEl(n);switch(e){case"innerHTML":var a=n.parsedStyle.innerHTML;g(a)?r.innerHTML=a:(r.innerHTML="",r.appendChild(a));break;case"x":r.style.left="".concat(n.parsedStyle.x,"px");break;case"y":r.style.top="".concat(n.parsedStyle.y,"px");break;case"transformOrigin":var i=n.parsedStyle.transformOrigin;r.style["transform-origin"]="".concat(i[0].buildCSSText(null,null,"")," ").concat(i[1].buildCSSText(null,null,""));break;case"width":var o=n.parsedStyle.width;r.style.width=S(o)?"".concat(o,"px"):""+o;break;case"height":var l=n.parsedStyle.height;r.style.height=S(l)?"".concat(l,"px"):""+l;break;case"zIndex":r.style["z-index"]="".concat(n.parsedStyle.zIndex);break;case"visibility":r.style.visibility=n.parsedStyle.visibility;break;case"pointerEvents":var s=n.parsedStyle.pointerEvents;r.style.pointerEvents=void 0===s?"auto":s;break;case"opacity":r.style.opacity="".concat(n.parsedStyle.opacity);break;case"fill":var c=n.parsedStyle.fill,u="";t.isCSSRGB(c)?u=c.isNone?"transparent":n.getAttribute("fill"):Array.isArray(c)?u=n.getAttribute("fill"):t.isPattern(c),r.style.background=u;break;case"stroke":var h=n.parsedStyle.stroke,d="";t.isCSSRGB(h)?d=h.isNone?"transparent":n.getAttribute("stroke"):Array.isArray(h)?d=n.getAttribute("stroke"):t.isPattern(h),r.style["border-color"]=d,r.style["border-style"]="solid";break;case"lineWidth":r.style["border-width"]="".concat(n.parsedStyle.lineWidth||0,"px");break;case"lineDash":r.style["border-style"]="dashed";break;case"filter":r.style.filter=n.style.filter;break;default:m(n.style[e])||""===n.style[e]||(r.style[e]=n.style[e])}}}])}();ft.tag="HTMLRendering";var vt=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="html-renderer",e}return d(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new ft)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),pt=Object.freeze({__proto__:null,Plugin:vt}),yt=function(){return i(function e(t){o(this,e),this.renderingContext=t.renderingContext,this.canvasConfig=t.config},[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,n=e.canvas;if(n)this.$canvas=n,t&&n.parentElement!==t&&t.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=g(t)?document.getElementById(t):t,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getContext",value:function(){return this.context}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,n){this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas&&(this.$canvas.width=this.dpr*e,this.$canvas.height=this.dpr*n,t.setDOMSize(this.$canvas,e,n)),this.renderingContext.renderReasons.add(t.RenderReason.CAMERA_CHANGED)}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=Z(q().mark(function e(){var t,n=arguments;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.context.canvas.toDataURL((t=n.length>0&&void 0!==n[0]?n[0]:{}).type,t.encoderOptions));case 1:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})}]);var e}(),mt=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="canvas-context-register",e}return d(t,e),i(t,[{key:"init",value:function(){this.context.ContextService=yt}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),gt=function(e){function t(e){var n;return o(this,t),(n=u(this,t,[e])).registerPlugin(new mt),n.registerPlugin(new $e),n.registerPlugin(new B),n.registerPlugin(new st),n.registerPlugin(new ht),n.registerPlugin(new Re),n.registerPlugin(new vt),n}return d(t,e),i(t)}(t.AbstractRenderer);e.CanvasPathGenerator=G,e.CanvasPicker=Le,e.CanvasRenderer=ct,e.DomInteraction=dt,e.HTMLRenderer=pt,e.ImageLoader=Ue,e.Renderer=gt});
|
|
19
|
+
*/
|
|
20
|
+
function ye(e,t,r,n){var i=e-r,a=t-n;return Math.sqrt(i*i+a*a)}pe.tag="CanvasPicker";function ge(e,t,r,n,i,a){var o=-1,l=1/0,c=[r,n],s=20;a&&a>200&&(s=a/10);for(var u=1/s,h=u/10,f=0;s>=f;f++){var d=f*u,v=[i.apply(void 0,b(e.concat([d]))),i.apply(void 0,b(t.concat([d])))],p=ye(c[0],c[1],v[0],v[1]);l>p&&(o=d,l=p)}if(0===o)return{x:e[0],y:t[0]};if(1===o){var y=e.length;return{x:e[y-1],y:t[y-1]}}l=1/0;for(var g=0;32>g&&1e-4<=h;g++){var m=o-h,x=o+h,S=[i.apply(void 0,b(e.concat([m]))),i.apply(void 0,b(t.concat([m])))],w=ye(c[0],c[1],S[0],S[1]);if(m>=0&&l>w)o=m,l=w;else{var M=[i.apply(void 0,b(e.concat([x]))),i.apply(void 0,b(t.concat([x])))],k=ye(c[0],c[1],M[0],M[1]);1>=x&&l>k?(o=x,l=k):h*=.5}}return{x:i.apply(void 0,b(e.concat([o]))),y:i.apply(void 0,b(t.concat([o])))}}function me(e,t,r,n,i,a){var o=[r-e,n-t];if(function(e,t){return e[0]===t[0]&&e[1]===t[1]}(o,[0,0]))return Math.sqrt((i-e)*(i-e)+(a-t)*(a-t));var l=[-o[1],o[0]];return function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i}(l,l),Math.abs(function(e,t){return e[0]*t[0]+e[1]*t[1]}([i-e,a-t],l))}function be(e,t,r,n,i){var a=1-i;return a*a*a*e+3*t*i*a*a+3*r*i*i*a+n*i*i*i}function xe(e,t,r,n,i,a,o,l,c,s,u){var h=function(e,t,r,n,i,a,o,l,c,s,u){return ge([e,r,i,o],[t,n,a,l],c,s,be,u)}(e,t,r,n,i,a,o,l,c,s,u);return ye(h.x,h.y,c,s)}function Se(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function we(e,t,r,n,i,a,o,l){var c=function(e,t,r,n,i,a,o,l){return ge([e,r,i],[t,n,a],o,l,Se)}(e,t,r,n,i,a,o,l);return ye(c.x,c.y,o,l)}function Me(e,r,n){var i=e.parsedStyle,a=i.cx,o=i.cy,l=i.r,c=i.fill,s=i.stroke,u=i.lineWidth,h=i.increasedLineWidthForHitTesting,f=i.pointerEvents,d=void 0===f?"auto":f,v=((void 0===u?1:u)+(void 0===h?0:h))/2,p=ye(void 0===a?0:a,void 0===o?0:o,r.x,r.y),y=m(t.isFillOrStrokeAffected(d,c,s),2),g=y[0],b=y[1];return g&&b||n?l+v>=p:g?l>=p:!!b&&(p>=l-v&&l+v>=p)}function ke(e,t,r,n){return e/(r*r)+t/(n*n)}function Oe(e,r,n){var i=e.parsedStyle,a=i.cx,o=void 0===a?0:a,l=i.cy,c=void 0===l?0:l,s=i.rx,u=i.ry,h=i.lineWidth,f=void 0===h?1:h,d=i.increasedLineWidthForHitTesting,v=void 0===d?0:d,p=i.pointerEvents,y=r.x,g=r.y,b=m(t.isFillOrStrokeAffected(void 0===p?"auto":p,i.fill,i.stroke),2),x=b[0],S=b[1],w=(f+v)/2,M=(y-o)*(y-o),k=(g-c)*(g-c);return x&&S||n?1>=ke(M,k,s+w,u+w):x?1>=ke(M,k,s,u):!!S&&(ke(M,k,s-w,u-w)>=1&&1>=ke(M,k,s+w,u+w))}function Ce(e,t,r,n,i,a){return!(e>i||i>e+r||t>a||a>t+n)}function Pe(e,t,r,n,i,a,o,l){var c=(Math.atan2(l-t,o-e)+2*Math.PI)%(2*Math.PI),s={x:e+r*Math.cos(c),y:t+r*Math.sin(c)};return ye(s.x,s.y,o,l)<=a/2}function Te(e,t,r,n,i,a,o){var l=i/2;return!(Math.min(e,r)-l>a||a>Math.max(e,r)+l||Math.min(t,n)-l>o||o>Math.max(t,n)+l)&&me(e,t,r,n,a,o)<=i/2}function Ae(e,t,r,n,i){var a=e.length;if(2>a)return!1;for(var o=0;a-1>o;o++){if(Te(e[o][0],e[o][1],e[o+1][0],e[o+1][1],t,r,n))return!0}if(i){var l=e[0],c=e[a-1];if(Te(l[0],l[1],c[0],c[1],t,r,n))return!0}return!1}function Ee(e){return 1e-6>Math.abs(e)?0:0>e?-1:1}function Re(e,t,r){return!((r[0]-e[0])*(t[1]-e[1])!==(t[0]-e[0])*(r[1]-e[1])||Math.min(e[0],t[0])>r[0]||r[0]>Math.max(e[0],t[0])||Math.min(e[1],t[1])>r[1]||r[1]>Math.max(e[1],t[1]))}function De(e,t,r){var n=!1,i=e.length;if(2>=i)return!1;for(var a=0;i>a;a++){var o=e[a],l=e[(a+1)%i];if(Re(o,l,[t,r]))return!0;Ee(o[1]-r)>0!=Ee(l[1]-r)>0&&0>Ee(t-(r-o[1])*(o[0]-l[0])/(o[1]-l[1])-o[0])&&(n=!n)}return n}function Le(e,t,r){for(var n=!1,i=0;e.length>i;i++){if(n=De(e[i],t,r))break}return n}function Ie(e,r,n){var i=e.parsedStyle,a=i.x1,o=i.y1,l=i.x2,c=i.y2,s=i.lineWidth,u=void 0===s?1:s,h=i.increasedLineWidthForHitTesting,f=void 0===h?0:h,d=i.pointerEvents;return!(!m(t.isFillOrStrokeAffected(void 0===d?"auto":d,i.fill,i.stroke),2)[1]&&!n||!u)&&Te(a,o,l,c,u+f,r.x,r.y)}function je(e,r,n,i,a,o){var l=e.parsedStyle,c=l.lineWidth,s=void 0===c?1:c,u=l.increasedLineWidthForHitTesting,h=void 0===u?0:u,f=l.d,d=l.pointerEvents,v=f.segments,p=f.hasArc,y=f.polylines,g=f.polygons,b=m(t.isFillOrStrokeAffected(void 0===d?"auto":d,(null==g?void 0:g.length)&&l.fill,l.stroke),2),x=b[0],S=b[1],w=t.getOrCalculatePathTotalLength(e),M=!1;return x||n?M=p?i(e,r):Le(g,r.x,r.y)||Le(y,r.x,r.y):((S||n)&&(M=function(e,t,r,n,i){for(var a=!1,o=t/2,l=0;e.length>l;l++){var c=e[l],s=c.currentPoint,u=c.params,h=c.prePoint,f=c.box;if(!f||Ce(f.x-o,f.y-o,f.width+t,f.height+t,r,n))switch(c.command){case"L":case"Z":if(a=Te(h[0],h[1],s[0],s[1],t,r,n))return!0;break;case"Q":if(a=t/2>=we(h[0],h[1],u[1],u[2],u[3],u[4],r,n))return!0;break;case"C":if(a=t/2>=xe(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],r,n,i))return!0;break;case"A":c.cubicParams||(c.cubicParams=I(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],u[7],void 0));for(var d=c.cubicParams,v=h,p=0;d.length>p;p+=6){var y=xe(v[0],v[1],d[p],d[p+1],d[p+2],d[p+3],d[p+4],d[p+5],r,n,i);if(v=[d[p+4],d[p+5]],a=t/2>=y)return!0}}}return a}(v,s+h,r.x,r.y,w)),M)}function Fe(e,r,n){var i=e.parsedStyle,a=i.lineWidth,o=void 0===a?1:a,l=i.increasedLineWidthForHitTesting,c=void 0===l?0:l,s=i.points,u=i.pointerEvents,h=m(t.isFillOrStrokeAffected(void 0===u?"auto":u,i.fill,i.stroke),2),f=h[0],d=!1;return(h[1]||n)&&(d=Ae(s.points,o+c,r.x,r.y,!0)),d||!f&&!n||(d=De(s.points,r.x,r.y)),d}function Be(e,r,n){var i=e.parsedStyle,a=i.lineWidth,o=void 0===a?1:a,l=i.increasedLineWidthForHitTesting,c=void 0===l?0:l,s=i.points,u=i.pointerEvents;return!(!m(t.isFillOrStrokeAffected(void 0===u?"auto":u,i.fill,i.stroke),2)[1]&&!n||!o)&&Ae(s.points,o+c,r.x,r.y,!1)}function Ne(e,r,n,i,a){var o=e.parsedStyle,l=o.radius,c=o.lineWidth,s=void 0===c?1:c,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,f=o.x,d=void 0===f?0:f,v=o.y,p=void 0===v?0:v,y=o.width,g=o.height,b=o.pointerEvents,x=m(t.isFillOrStrokeAffected(void 0===b?"auto":b,o.fill,o.stroke),2),S=x[0],w=x[1],M=s+h;if(l&&l.some(function(e){return 0!==e})){var k=!1;return(w||n)&&(k=function(e,t,r,n,i,a,o,l){var c=m(i,4),s=c[0],u=c[1],h=c[2],f=c[3];return Te(e+s,t,e+r-u,t,a,o,l)||Te(e+r,t+u,e+r,t+n-h,a,o,l)||Te(e+r-h,t+n,e+f,t+n,a,o,l)||Te(e,t+n-f,e,t+s,a,o,l)||Pe(e+r-u,t+u,u,0,0,a,o,l)||Pe(e+r-h,t+n-h,h,0,0,a,o,l)||Pe(e+f,t+n-f,f,0,0,a,o,l)||Pe(e+s,t+s,s,0,0,a,o,l)}(d,p,y,g,l.map(function(e){return D(e,0,Math.min(Math.abs(y)/2,Math.abs(g)/2))}),M,r.x,r.y)),k||!S&&!n||(k=i(e,r)),k}var O=M/2;return S&&w||n?Ce(d-O,p-O,y+O,g+O,r.x,r.y):S?Ce(d,p,y,g,r.x,r.y):!!w&&function(e,t,r,n,i,a,o){var l=i/2;return Ce(e-l,t-l,r,i,a,o)||Ce(e+r-l,t-l,i,n,a,o)||Ce(e+l,t+n-l,r,i,a,o)||Ce(e-l,t+l,i,n,a,o)}(d,p,y,g,M,r.x,r.y)}function Ge(e,r,n,i,a,o){var l=e.parsedStyle,c=l.pointerEvents,s=l.x,u=void 0===s?0:s,h=l.y,f=void 0===h?0:h,d=l.width,v=l.height;if("non-transparent-pixel"===(void 0===c?"auto":c)){var y=a.config.offscreenCanvas,g=o.offscreenCanvasCreator.getOrCreateCanvas(y),m=o.offscreenCanvasCreator.getOrCreateContext(y,{willReadFrequently:!0});return g.width=d,g.height=v,a.defaultStyleRendererFactory[t.Shape.IMAGE].render(m,p(p({},e.parsedStyle),{},{x:0,y:0}),e,void 0,void 0,void 0),m.getImageData(r.x-u,r.y-f,1,1).data.every(function(e){return 0!==e})}return!0}function We(e,t,r,n){var i=e.getGeometryBounds();return!(i.min[0]>t.x||i.min[1]>t.y||t.x>i.max[0]||t.y>i.max[1])}var _e=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=u(this,r,[].concat(n))).name="canvas-picker",e}return f(r,e),a(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,Me),t.Shape.ELLIPSE,Oe),t.Shape.RECT,Ne),t.Shape.LINE,Ie),t.Shape.POLYLINE,Be),t.Shape.POLYGON,Fe),t.Shape.PATH,je),t.Shape.TEXT,We),t.Shape.GROUP,null),t.Shape.IMAGE,Ge),d(d(e,t.Shape.HTML,null),t.Shape.MESH,null));this.context.pointInPathPickerFactory=r,this.addRenderingPlugin(new pe)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),He=Object.freeze({__proto__:null,Plugin:_e});function $e(e,t){var r=t.cx,n=t.cy;e.arc(void 0===r?0:r,void 0===n?0:n,t.r,0,2*Math.PI,!1)}function Ye(e,t){var r=t.cx,n=void 0===r?0:r,i=t.cy,a=void 0===i?0:i,o=t.rx,l=t.ry;if(e.ellipse)e.ellipse(n,a,o,l,0,0,2*Math.PI,!1);else{var c=o>l?o:l,s=o>l?1:o/l,u=o>l?l/o:1;e.save(),e.scale(s,u),e.arc(n,a,c,0,2*Math.PI)}}function ze(e,r){var n=r.x1,i=r.y1,a=r.x2,o=r.y2,l=r.markerStart,c=r.markerEnd,s=r.markerStartOffset,u=r.markerEndOffset,h=0,f=0,d=0,v=0,p=0;l&&t.isDisplayObject(l)&&s&&(h=Math.cos(p=Math.atan2(o-i,a-n))*(s||0),f=Math.sin(p)*(s||0)),c&&t.isDisplayObject(c)&&u&&(d=Math.cos(p=Math.atan2(i-o,n-a))*(u||0),v=Math.sin(p)*(u||0)),e.moveTo(n+h,i+f),e.lineTo(a+d,o+v)}function Xe(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,l=r.d,c=l.absolutePath,s=l.segments,u=0,h=0,f=0,d=0,v=0;if(n&&t.isDisplayObject(n)&&a){var p=m(n.parentNode.getStartTangent(),2),y=p[0],g=p[1];u=Math.cos(v=Math.atan2(y[1]-g[1],y[0]-g[0]))*(a||0),h=Math.sin(v)*(a||0)}if(i&&t.isDisplayObject(i)&&o){var b=m(i.parentNode.getEndTangent(),2),x=b[0],S=b[1];f=Math.cos(v=Math.atan2(x[1]-S[1],x[0]-S[0]))*(o||0),d=Math.sin(v)*(o||0)}for(var w=0;c.length>w;w++){var M=c[w],k=M[0],O=c[w+1],C=(w===c.length-1||O&&("M"===O[0]||"Z"===O[0]))&&0!==f&&0!==d,P=m(0===w&&(0!==u||0!==h)?[u,h]:[0,0],2),T=P[0],A=P[1],E=m(C?[f,d]:[0,0],2),R=E[0],D=E[1];switch(k){case"M":e.moveTo(M[1]+T,M[2]+A);break;case"L":e.lineTo(M[1]+R,M[2]+D);break;case"Q":e.quadraticCurveTo(M[1],M[2],M[3]+R,M[4]+D);break;case"C":e.bezierCurveTo(M[1],M[2],M[3],M[4],M[5]+R,M[6]+D);break;case"A":var L=s[w].arcParams,I=L.cx,j=L.cy,F=L.rx,B=L.ry,N=L.startAngle,G=L.endAngle,W=L.xRotation,_=L.sweepFlag;if(e.ellipse)e.ellipse(I,j,F,B,W,N,G,!!(1-_));else{var H=F>B?F:B,$=F>B?1:F/B,Y=F>B?B/F:1;e.translate(I,j),e.rotate(W),e.scale($,Y),e.arc(0,0,H,N,G,!!(1-_)),e.scale(1/$,1/Y),e.rotate(-W),e.translate(-I,-j)}C&&e.lineTo(M[6]+f,M[7]+d);break;case"Z":e.closePath()}}}function Ue(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,l=r.points.points,c=l.length,s=l[0][0],u=l[0][1],h=l[c-1][0],f=l[c-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&a&&(d=Math.cos(g=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(a||0),v=Math.sin(g)*(a||0)),i&&t.isDisplayObject(i)&&o&&(p=Math.cos(g=Math.atan2(l[c-1][1]-l[0][1],l[c-1][0]-l[0][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(s+(d||p),u+(v||y));for(var m=1;c-1>m;m++){var b=l[m];e.lineTo(b[0],b[1])}e.lineTo(h,f)}function qe(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,l=r.points.points,c=l.length,s=l[0][0],u=l[0][1],h=l[c-1][0],f=l[c-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&a&&(d=Math.cos(g=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(a||0),v=Math.sin(g)*(a||0)),i&&t.isDisplayObject(i)&&o&&(p=Math.cos(g=Math.atan2(l[c-2][1]-l[c-1][1],l[c-2][0]-l[c-1][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(s+d,u+v);for(var m=1;c-1>m;m++){var b=l[m];e.lineTo(b[0],b[1])}e.lineTo(h+p,f+y)}function Ve(e,t){var r=t.x,n=void 0===r?0:r,i=t.y,a=void 0===i?0:i,o=t.radius,l=t.width,c=t.height,s=l,u=c;if(o&&o.some(function(e){return 0!==e})){var h=l>0?1:-1,f=c>0?1:-1,d=h+f===0,v=m(o.map(function(e){return D(e,0,Math.min(Math.abs(s)/2,Math.abs(u)/2))}),4),p=v[0],y=v[1],g=v[2],b=v[3];e.moveTo(h*p+n,a),e.lineTo(s-h*y+n,a),0!==y&&e.arc(s-h*y+n,f*y+a,y,-f*Math.PI/2,h>0?0:Math.PI,d),e.lineTo(s+n,u-f*g+a),0!==g&&e.arc(s-h*g+n,u-f*g+a,g,h>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,d),e.lineTo(h*b+n,u+a),0!==b&&e.arc(h*b+n,u-f*b+a,b,f>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,d),e.lineTo(n,f*p+a),0!==p&&e.arc(h*p+n,f*p+a,p,h>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,d)}else e.rect(n,a,s,u)}var Qe=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=u(this,r,[].concat(n))).name="canvas-path-generator",e}return f(r,e),a(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,$e),t.Shape.ELLIPSE,Ye),t.Shape.RECT,Ve),t.Shape.LINE,ze),t.Shape.POLYLINE,qe),t.Shape.POLYGON,Ue),t.Shape.PATH,Xe),t.Shape.TEXT,void 0),t.Shape.GROUP,void 0),t.Shape.IMAGE,void 0),d(d(d(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.pathGeneratorFactory=r}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(t.AbstractRendererPlugin),Je=Object.freeze({__proto__:null,Plugin:Qe}),Ze=function(){return a(function e(t){o(this,e),this.renderingContext=t.renderingContext,this.canvasConfig=t.config},[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container="string"==typeof t?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getContext",value:function(){return this.context}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas&&(this.$canvas.width=this.dpr*e,this.$canvas.height=this.dpr*r,t.setDOMSize(this.$canvas,e,r)),this.renderingContext.renderReasons.add(t.RenderReason.CAMERA_CHANGED)}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=ue(ce().mark(function e(){var t,r=arguments;return ce().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.context.canvas.toDataURL((t=r.length>0&&void 0!==r[0]?r[0]:{}).type,t.encoderOptions));case 1:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})}]);var e}(),Ke=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=u(this,t,[].concat(n))).name="canvas-context-register",e}return f(t,e),a(t,[{key:"init",value:function(){this.context.ContextService=Ze}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),et=function(e){function r(e){var n;return o(this,r),(n=u(this,r,[e])).registerPlugin(new Ke),n.registerPlugin(new t.ImageLoader.Plugin),n.registerPlugin(new Qe),n.registerPlugin(new Z),n.registerPlugin(new t.DomInteraction.Plugin),n.registerPlugin(new _e),n.registerPlugin(new t.HTMLRenderer.Plugin),n}return f(r,e),a(r)}(t.AbstractRenderer);Object.defineProperty(e,"DomInteraction",{enumerable:!0,get:function(){return t.DomInteraction}}),Object.defineProperty(e,"HTMLRenderer",{enumerable:!0,get:function(){return t.HTMLRenderer}}),Object.defineProperty(e,"ImageLoader",{enumerable:!0,get:function(){return t.ImageLoader}}),e.CanvasPathGenerator=Je,e.CanvasPicker=He,e.CanvasRenderer=K,e.Renderer=et});
|
|
44
21
|
//# sourceMappingURL=index.umd.min.js.map
|