| 1 |
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPathGenerator={}),t.window.G)}(this,(function(t,e){"use strict";function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function r(t,e){var a=e.r;t.arc(a,a,a,0,2*Math.PI,!1)}function n(t,e){var a=e.rx,r=e.ry;if(t.ellipse)t.ellipse(a,r,a,r,0,0,2*Math.PI,!1);else{var n=a>r?a:r,o=a>r?1:a/r,i=a>r?r/a:1;t.save(),t.scale(o,i),t.arc(0,0,n,0,2*Math.PI)}}function o(t,a){var r=a.x1,n=a.y1,o=a.x2,i=a.y2,s=a.defX,h=void 0===s?0:s,c=a.defY,l=void 0===c?0:c,f=a.markerStart,p=a.markerEnd,d=a.markerStartOffset,v=a.markerEndOffset,M=0,u=0,T=0,m=0,y=0;f&&e.isDisplayObject(f)&&d&&(M=Math.cos(y=Math.atan2(i-n,o-r))*(d||0),u=Math.sin(y)*(d||0)),p&&e.isDisplayObject(p)&&v&&(T=Math.cos(y=Math.atan2(n-i,r-o))*(v||0),m=Math.sin(y)*(v||0)),t.moveTo(r-h+M,n-l+u),t.lineTo(o-h+T,i-l+m)}function i(t,a){var r=a.defX,n=void 0===r?0:r,o=a.defY,i=void 0===o?0:o,s=a.markerStart,h=a.markerEnd,c=a.markerStartOffset,l=a.markerEndOffset,f=a.path,p=f.absolutePath,d=f.segments,v=0,M=0,u=0,T=0,m=0;if(s&&e.isDisplayObject(s)&&c){var y=s.parentNode.getStartTangent(),P=y[0],b=y[1];v=Math.cos(m=Math.atan2(P[1]-b[1],P[0]-b[0]))*(c||0),M=Math.sin(m)*(c||0)}if(h&&e.isDisplayObject(h)&&l){var O=h.parentNode.getEndTangent(),S=O[0],g=O[1];u=Math.cos(m=Math.atan2(S[1]-g[1],S[0]-g[0]))*(l||0),T=Math.sin(m)*(l||0)}for(var k=0;p.length>k;k++){var I=p[k],E=p[k+1],j=0===k&&(0!==v||0!==M),x=(k===p.length-1||E&&("M"===E[0]||"Z"===E[0]))&&0!==u&&0!==T;switch(I[0]){case"M":j?(t.moveTo(I[1]-n+v,I[2]-i+M),t.lineTo(I[1]-n,I[2]-i)):t.moveTo(I[1]-n,I[2]-i);break;case"L":x?t.lineTo(I[1]-n+u,I[2]-i+T):t.lineTo(I[1]-n,I[2]-i);break;case"Q":t.quadraticCurveTo(I[1]-n,I[2]-i,I[3]-n,I[4]-i),x&&t.lineTo(I[3]-n+u,I[4]-i+T);break;case"C":t.bezierCurveTo(I[1]-n,I[2]-i,I[3]-n,I[4]-i,I[5]-n,I[6]-i),x&&t.lineTo(I[5]-n+u,I[6]-i+T);break;case"A":var G=d[k].arcParams,L=G.cx,D=G.cy,A=G.rx,C=G.ry,Y=G.startAngle,_=G.endAngle,w=G.xRotation,N=G.sweepFlag;if(t.ellipse)t.ellipse(L-n,D-i,A,C,w,Y,_,!!(1-N));else{var R=A>C?A:C,X=A>C?1:A/C,F=A>C?C/A:1;t.translate(L-n,D-i),t.rotate(w),t.scale(X,F),t.arc(0,0,R,Y,_,!!(1-N)),t.scale(1/X,1/F),t.rotate(-w),t.translate(-(L-n),-(D-i))}x&&t.lineTo(I[6]-n+u,I[7]-i+T);break;case"Z":t.closePath()}}}function s(t,a){var r=a.defX,n=void 0===r?0:r,o=a.defY,i=void 0===o?0:o,s=a.markerStart,h=a.markerEnd,c=a.markerStartOffset,l=a.markerEndOffset,f=a.points.points,p=f.length,d=f[0][0]-n,v=f[0][1]-i,M=f[p-1][0]-n,u=f[p-1][1]-i,T=0,m=0,y=0,P=0,b=0;s&&e.isDisplayObject(s)&&c&&(T=Math.cos(b=Math.atan2(f[1][1]-f[0][1],f[1][0]-f[0][0]))*(c||0),m=Math.sin(b)*(c||0)),h&&e.isDisplayObject(h)&&l&&(y=Math.cos(b=Math.atan2(f[p-1][1]-f[0][1],f[p-1][0]-f[0][0]))*(l||0),P=Math.sin(b)*(l||0)),t.moveTo(d+(T||y),v+(m||P));for(var O=1;p-1>O;O++){var S=f[O];t.lineTo(S[0]-n,S[1]-i)}t.lineTo(M,u)}function h(t,a){var r=a.defX,n=void 0===r?0:r,o=a.defY,i=void 0===o?0:o,s=a.markerStart,h=a.markerEnd,c=a.markerStartOffset,l=a.markerEndOffset,f=a.points.points,p=f.length,d=f[0][0]-n,v=f[0][1]-i,M=f[p-1][0]-n,u=f[p-1][1]-i,T=0,m=0,y=0,P=0,b=0;s&&e.isDisplayObject(s)&&c&&(T=Math.cos(b=Math.atan2(f[1][1]-f[0][1],f[1][0]-f[0][0]))*(c||0),m=Math.sin(b)*(c||0)),h&&e.isDisplayObject(h)&&l&&(y=Math.cos(b=Math.atan2(f[p-2][1]-f[p-1][1],f[p-2][0]-f[p-1][0]))*(l||0),P=Math.sin(b)*(l||0)),t.moveTo(d+T,v+m);for(var O=1;p-1>O;O++){var S=f[O];t.lineTo(S[0]-n,S[1]-i)}t.lineTo(M+y,u+P)}function c(t,e){var a=e.radius,r=e.width,n=e.height,o=r,i=n;if(a&&a.some((function(t){return 0!==t}))){var s=r>0?1:-1,h=n>0?1:-1,c=s+h===0,l=a.map((function(t){return e=t,a=0,r=Math.min(Math.abs(o)/2,Math.abs(i)/2),a>e?a:e>r?r:e;var e,a,r})),f=l[0],p=l[1],d=l[2],v=l[3];t.moveTo(s*f,0),t.lineTo(o-s*p,0),0!==p&&t.arc(o-s*p,h*p,p,-h*Math.PI/2,s>0?0:Math.PI,c),t.lineTo(o,i-h*d),0!==d&&t.arc(o-s*d,i-h*d,d,s>0?0:Math.PI,h>0?Math.PI/2:1.5*Math.PI,c),t.lineTo(s*v,i),0!==v&&t.arc(s*v,i-h*v,v,h>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,c),t.lineTo(0,h*f),0!==f&&t.arc(s*f,h*f,f,s>0?Math.PI:0,h>0?1.5*Math.PI:Math.PI/2,c)}else t.rect(0,0,o,i)}var l=function(t){var l,f;function p(){for(var e,a=arguments.length,r=Array(a),n=0;a>n;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).name="canvas-path-generator",e}(l=p).prototype=Object.create((f=t).prototype),l.prototype.constructor=l,a(l,f);var d=p.prototype;return d.init=function(){var t,a=((t={})[e.Shape.CIRCLE]=r,t[e.Shape.ELLIPSE]=n,t[e.Shape.RECT]=c,t[e.Shape.LINE]=o,t[e.Shape.POLYLINE]=h,t[e.Shape.POLYGON]=s,t[e.Shape.PATH]=i,t[e.Shape.TEXT]=void 0,t[e.Shape.GROUP]=void 0,t[e.Shape.IMAGE]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.pathGeneratorFactory=a},d.destroy=function(){delete this.context.pathGeneratorFactory},p}(e.AbstractRendererPlugin);t.Plugin=l,Object.defineProperty(t,"__esModule",{value:!0})}));
|