@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.7.31 to 1.7.32
@@ -1,1 +0,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.CanvasRenderer={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),a=new O(n||[]);return i(o,"_invoke",{value:A(t,r,a)}),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f={};function d(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(B([])));m&&m!==e&&n.call(m,a)&&(y=m);var w=v.prototype=d.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(i,o,a,s){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return L()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function B(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=v,i(w,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=l(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},x(b.prototype),l(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new b(h(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),l(w,c,"Generator"),l(w,a,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=B,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===t||"continue"===t)&&e>=o.tryLoc&&o.finallyLoc>=e&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(i,o){var a=t.apply(e,r);function s(t){n(a,i,o,s,c,"next",t)}function c(t){n(a,i,o,s,c,"throw",t)}s(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,s(t,e)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}var c="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var t=new c(16);return c!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],w=r[0],x=r[1],b=r[2],A=r[3];return t[0]=w*n+x*s+b*u+A*v,t[1]=w*i+x*c+b*f+A*y,t[2]=w*o+x*l+b*d+A*g,t[3]=w*a+x*h+b*p+A*m,t[4]=(w=r[4])*n+(x=r[5])*s+(b=r[6])*u+(A=r[7])*v,t[5]=w*i+x*c+b*f+A*y,t[6]=w*o+x*l+b*d+A*g,t[7]=w*a+x*h+b*p+A*m,t[8]=(w=r[8])*n+(x=r[9])*s+(b=r[10])*u+(A=r[11])*v,t[9]=w*i+x*c+b*f+A*y,t[10]=w*o+x*l+b*d+A*g,t[11]=w*a+x*h+b*p+A*m,t[12]=(w=r[12])*n+(x=r[13])*s+(b=r[14])*u+(A=r[15])*v,t[13]=w*i+x*c+b*f+A*y,t[14]=w*o+x*l+b*d+A*g,t[15]=w*a+x*h+b*p+A*m,t}function f(t,e,r){var n,i,o,a,s,c,l,h,u,f,d,p,v=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],t[0]=n=e[0],t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=f,t[10]=d,t[11]=p,t[12]=n*v+s*y+u*g+e[12],t[13]=i*v+c*y+f*g+e[13],t[14]=o*v+l*y+d*g+e[14],t[15]=a*v+h*y+p*g+e[15]),t}function d(){var t=new c(3);return c!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function p(t,e,r){var n=new c(3);return n[0]=t,n[1]=e,n[2]=r,n}function v(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});y=d();var y,g=function(t){return null==t},m={}.toString,w=function(t){return e="String",m.call(t)==="[object "+e+"]";var e},x=function(){function t(t){this.canvasRendererPluginOptions=void 0,this.context=void 0,this.pathGeneratorFactory=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=l(),this.dprMatrix=l(),this.tmpMat4=l(),this.vec3a=d(),this.vec3b=d(),this.vec3c=d(),this.vec3d=d(),this.canvasRendererPluginOptions=t}var n=t.prototype;return n.apply=function(n){var o=this;this.context=n;var a=n.config,s=n.camera,c=n.renderingService,l=n.renderingContext,h=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=h;var f=n.contextService,d=l.root.ownerDocument.defaultView,y=function(t){var e=t.target.rBushNode;e.aabb&&o.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&o.removedRBushNodeAABBs.push(e.aabb)};c.hooks.init.tapPromise(t.tag,i(r().mark((function t(){var n,i,s,c;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:d.addEventListener(e.ElementEvent.UNMOUNTED,y),d.addEventListener(e.ElementEvent.CULLED,g),n=f.getDPR(),i=a.width,s=a.height,c=f.getContext(),o.clearRect(c,0,0,i*n,s*n,a.background);case 6:case"end":return t.stop()}}),t)})))),c.hooks.destroy.tap(t.tag,(function(){d.removeEventListener(e.ElementEvent.UNMOUNTED,y),d.removeEventListener(e.ElementEvent.CULLED,g)})),c.hooks.beginFrame.tap(t.tag,(function(){var t=f.getContext(),e=f.getDPR(),r=a.width,n=a.height,i=o.canvasRendererPluginOptions,s=i.dirtyObjectNumThreshold,l=i.dirtyObjectRatioThreshold,h=c.getStats(),u=h.rendered,d=u/h.total;o.clearFullScreen=c.disableDirtyRectangleRendering()||u>s&&d>l,t&&(t.resetTransform(),o.clearFullScreen&&o.clearRect(t,0,0,r*e,n*e,a.background))}));var m=function t(e){e.isVisible()&&!e.isCulled()&&(o.renderDisplayObject(e,f,c),o.saveDirtyAABB(e)),(e.sortable.sorted||e.childNodes).forEach((function(e){t(e)}))};c.hooks.endFrame.tap(t.tag,(function(){var t,r,n=f.getContext(),i=f.getDPR();if(t=o.dprMatrix,r=p(i,i,1),t[0]=r[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=r[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,u(o.vpMatrix,o.dprMatrix,s.getOrthoMatrix()),o.clearFullScreen)m(l.root);else{var h=o.safeMergeAABB.apply(o,[o.mergeDirtyAABBs(o.renderQueue)].concat(o.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,i=t.maxX,o=t.maxY,a=new e.AABB;return a.setMinMax(p(r,n,0),p(i,o,0)),a}))));if(o.removedRBushNodeAABBs=[],e.AABB.isEmpty(h))return void(o.renderQueue=[]);var y=o.convertAABB2Rect(h),g=y.x,w=y.y,x=y.width,b=y.height,A=v(o.vec3a,p(g,w,0),o.vpMatrix),E=v(o.vec3b,p(g+x,w,0),o.vpMatrix),S=v(o.vec3c,p(g,w+b,0),o.vpMatrix),M=v(o.vec3d,p(g+x,w+b,0),o.vpMatrix),O=Math.min(A[0],E[0],M[0],S[0]),B=Math.min(A[1],E[1],M[1],S[1]),L=Math.max(A[0],E[0],M[0],S[0]),R=Math.max(A[1],E[1],M[1],S[1]),P=Math.floor(O),T=Math.floor(B),N=Math.ceil(L-O),k=Math.ceil(R-B);n.save(),o.clearRect(n,P,T,N,k,a.background),n.beginPath(),n.rect(P,T,N,k),n.clip(),n.setTransform(o.vpMatrix[0],o.vpMatrix[1],o.vpMatrix[4],o.vpMatrix[5],o.vpMatrix[12],o.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&d.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:P,y:T,width:N,height:k}})),o.searchDirtyObjects(h).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&o.renderDisplayObject(t,f,c)})),n.restore(),o.renderQueue.forEach((function(t){o.saveDirtyAABB(t)})),o.renderQueue=[]}o.restoreStack.forEach((function(){n.restore()})),o.restoreStack=[]})),c.hooks.render.tap(t.tag,(function(t){o.clearFullScreen||o.renderQueue.push(t)}))},n.clearRect=function(t,e,r,n,i,o){t.clearRect(e,r,n,i),o&&(t.fillStyle=o,t.fillRect(e,r,n,i))},n.renderDisplayObject=function(t,r,n){var i=r.getContext(),o=t.nodeName,a=this.restoreStack[this.restoreStack.length-1];!a||t.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_CONTAINS||(i.restore(),this.restoreStack.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],l=t.parsedStyle.clipPath;if(l){this.applyWorldTransform(i,l);var h=this.pathGeneratorFactory[l.nodeName];h&&(i.save(),this.restoreStack.push(t),i.beginPath(),h(i,l.parsedStyle),i.closePath(),i.clip())}s&&(this.applyWorldTransform(i,t),i.save(),this.applyAttributesToContext(i,t)),c&&(i.beginPath(),c(i,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&i.closePath()),s&&(s.render(i,t.parsedStyle,t,n),i.restore()),t.renderable.dirty=!1},n.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),i=Math.floor(e[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(t){var r=t.getMin(),n=r[0],i=r[1],o=t.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[1]}).map((function(t){return e.runtime.displayObjectPool.getByEntity(t.id)}))},n.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,s=r.lineDashOffset;a&&t.setLineDash(a),g(s)||(t.lineDashOffset=s),g(o)||(t.globalAlpha*=o),g(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),g(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},n.applyWorldTransform=function(t,e,r){var n=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var c=e.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}r?(h(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,r,this.tmpMat4),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(h(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(e){t.add(e)})),t},t}();x.tag="CanvasRenderer";var b=function(){function t(t){this.imagePool=void 0,this.imagePool=t}var r=t.prototype;return r.render=function(t,r,n,i){var o=r.fill,a=r.fillRule,s=r.opacity,c=r.fillOpacity,l=r.stroke,h=r.strokeOpacity,u=r.lineWidth,f=r.lineCap,d=r.lineJoin,p=r.shadowType,v=r.shadowColor,y=r.shadowBlur,m=r.filter,w=r.miterLimit,x=!g(o)&&!o.isNone,b=!g(l)&&!l.isNone&&u>0,E=0===o.alpha,S=!(!m||!m.length),M=!g(v)&&y>0,O=n.nodeName,B="inner"===p,L=b&&M&&(O===e.Shape.PATH||O===e.Shape.LINE||O===e.Shape.POLYLINE||E||B);x&&(t.globalAlpha=s*c,L||A(n,t,M),this.fill(t,n,o,a,i),L||this.clearShadowAndFilter(t,S,M)),b&&(t.globalAlpha=s*h,t.lineWidth=u,g(w)||(t.miterLimit=w),g(f)||(t.lineCap=f),g(d)||(t.lineJoin=d),L&&(B&&(t.globalCompositeOperation="source-atop"),A(n,t,!0),B&&(this.stroke(t,n,l,i),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,S,!0))),this.stroke(t,n,l,i))},r.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!g(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.fill=function(t,r,n,i,o){var a=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=a.getColor(e,r,t),t.fill(i)})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o)),t.fill(i))},r.stroke=function(t,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=o.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,i)),t.stroke())},r.getPattern=function(t,e,r,n){return this.imagePool.getOrCreatePatternSync(t,r,(function(){e.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(t,r,n){var i;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:t.type},t.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},t}();function A(t,e,r){var n=t.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,s=n.shadowOffsetX,c=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=o.toString(),e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var E=function(){function t(t){this.imagePool=void 0,this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.img,o=e.shadowColor,a=e.shadowBlur,s=e.width,c=e.height;if(w(i)?n=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),n=i),n){A(r,t,!g(o)&&a>0);try{t.drawImage(n,0,0,s,c)}catch(t){}}},t}(),S=function(){function t(){}var e=t.prototype;return e.render=function(t,e,r){var n=e.lineWidth,i=e.textAlign,o=e.textBaseline,a=e.lineJoin,s=e.miterLimit,c=e.letterSpacing,l=e.stroke,h=e.fill,u=e.fillOpacity,f=e.strokeOpacity,d=e.opacity,p=e.metrics,v=e.dx,y=e.dy,m=e.shadowColor,w=e.shadowBlur,x=p.lines,b=p.height,E=p.lineHeight,S=p.lineMetrics;t.font=p.font,t.lineWidth=n,t.textAlign="middle"===i?"center":i,t.textBaseline=o,t.lineJoin=a,g(s)||(t.miterLimit=s);var M=0;"middle"===o?M=-b/2-E/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?M=-b:"top"!==o&&"hanging"!==o||(M=-E);var O=v||0;M+=y||0,A(r,t,!g(m)&&w>0);for(var B=0;x.length>B;B++){var L=n/2+O;M+=E,g(l)||l.isNone||!n||this.drawLetterSpacing(t,x[B],S[B],i,L,M,c,u,f,d,!0),g(h)||this.drawLetterSpacing(t,x[B],S[B],i,L,M,c,u,f,d)}},e.drawLetterSpacing=function(t,e,r,n,i,o,a,s,c,l,h){if(void 0===h&&(h=!1),0!==a){var u=t.textAlign;t.textAlign="left";var f=i;"center"===n||"middle"===n?f=i-r.width/2:"right"!==n&&"end"!==n||(f=i-r.width);for(var d=Array.from(e),p=t.measureText(e).width,v=0,y=0;d.length>y;++y){var g=d[y];h?this.strokeText(t,g,f,o,c):this.fillText(t,g,f,o,s,l),f+=p-(v=t.measureText(e.substring(y+1)).width)+a,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,o,c):this.fillText(t,e,i,o,s,l)},e.fillText=function(t,e,r,n,i,o){var a,s=!g(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,r,n),s&&(t.globalAlpha=a)},e.strokeText=function(t,e,r,n,i){var o,a=!g(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),a&&(t.globalAlpha=o)},t}(),M=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),O=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),B=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),L=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),R=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),P=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),T=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),N=function(t){function r(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=e,r}a(r,t);var n=r.prototype;return n.init=function(){var t,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new b(n),a=((t={})[e.Shape.CIRCLE]=i,t[e.Shape.ELLIPSE]=i,t[e.Shape.RECT]=i,t[e.Shape.IMAGE]=new E(n),t[e.Shape.TEXT]=new S,t[e.Shape.LINE]=i,t[e.Shape.POLYLINE]=i,t[e.Shape.POLYGON]=i,t[e.Shape.PATH]=i,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new x(r))},n.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=O,t.EllipseRenderer=B,t.ImageRenderer=E,t.LineRenderer=L,t.PathRenderer=T,t.Plugin=N,t.PolygonRenderer=P,t.PolylineRenderer=R,t.RectRenderer=M,t.TextRenderer=S,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!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.CanvasRenderer={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),a=new O(n||[]);return i(o,"_invoke",{value:A(t,r,a)}),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f={};function d(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(B([])));m&&m!==e&&n.call(m,a)&&(y=m);var x=v.prototype=d.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(i,o,a,s){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return L()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function B(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=v,i(x,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=l(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},w(b.prototype),l(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new b(h(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(x),l(x,c,"Generator"),l(x,a,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=B,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===t||"continue"===t)&&e>=o.tryLoc&&o.finallyLoc>=e&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(i,o){var a=t.apply(e,r);function s(t){n(a,i,o,s,c,"next",t)}function c(t){n(a,i,o,s,c,"throw",t)}s(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,s(t,e)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}var c="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var t=new c(16);return c!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],x=r[0],w=r[1],b=r[2],A=r[3];return t[0]=x*n+w*s+b*u+A*v,t[1]=x*i+w*c+b*f+A*y,t[2]=x*o+w*l+b*d+A*g,t[3]=x*a+w*h+b*p+A*m,t[4]=(x=r[4])*n+(w=r[5])*s+(b=r[6])*u+(A=r[7])*v,t[5]=x*i+w*c+b*f+A*y,t[6]=x*o+w*l+b*d+A*g,t[7]=x*a+w*h+b*p+A*m,t[8]=(x=r[8])*n+(w=r[9])*s+(b=r[10])*u+(A=r[11])*v,t[9]=x*i+w*c+b*f+A*y,t[10]=x*o+w*l+b*d+A*g,t[11]=x*a+w*h+b*p+A*m,t[12]=(x=r[12])*n+(w=r[13])*s+(b=r[14])*u+(A=r[15])*v,t[13]=x*i+w*c+b*f+A*y,t[14]=x*o+w*l+b*d+A*g,t[15]=x*a+w*h+b*p+A*m,t}function f(t,e,r){var n,i,o,a,s,c,l,h,u,f,d,p,v=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],t[0]=n=e[0],t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=f,t[10]=d,t[11]=p,t[12]=n*v+s*y+u*g+e[12],t[13]=i*v+c*y+f*g+e[13],t[14]=o*v+l*y+d*g+e[14],t[15]=a*v+h*y+p*g+e[15]),t}function d(){var t=new c(3);return c!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function p(t,e,r){var n=new c(3);return n[0]=t,n[1]=e,n[2]=r,n}function v(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});y=d();var y,g=function(t){return null==t},m={}.toString,x=function(t){return e="String",m.call(t)==="[object "+e+"]";var e},w=function(){function t(t){this.canvasRendererPluginOptions=void 0,this.context=void 0,this.pathGeneratorFactory=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=l(),this.dprMatrix=l(),this.tmpMat4=l(),this.vec3a=d(),this.vec3b=d(),this.vec3c=d(),this.vec3d=d(),this.canvasRendererPluginOptions=t}var n=t.prototype;return n.apply=function(n){var o=this;this.context=n;var a=n.config,s=n.camera,c=n.renderingService,l=n.renderingContext,h=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=h;var f=n.contextService,d=l.root.ownerDocument.defaultView,y=function(t){var e=t.target.rBushNode;e.aabb&&o.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&o.removedRBushNodeAABBs.push(e.aabb)};c.hooks.init.tapPromise(t.tag,i(r().mark((function t(){var n,i,s,c;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:d.addEventListener(e.ElementEvent.UNMOUNTED,y),d.addEventListener(e.ElementEvent.CULLED,g),n=f.getDPR(),i=a.width,s=a.height,c=f.getContext(),o.clearRect(c,0,0,i*n,s*n,a.background);case 6:case"end":return t.stop()}}),t)})))),c.hooks.destroy.tap(t.tag,(function(){d.removeEventListener(e.ElementEvent.UNMOUNTED,y),d.removeEventListener(e.ElementEvent.CULLED,g)})),c.hooks.beginFrame.tap(t.tag,(function(){var t=f.getContext(),e=f.getDPR(),r=a.width,n=a.height,i=o.canvasRendererPluginOptions,s=i.dirtyObjectNumThreshold,l=i.dirtyObjectRatioThreshold,h=c.getStats(),u=h.rendered,d=u/h.total;o.clearFullScreen=c.disableDirtyRectangleRendering()||u>s&&d>l,t&&(t.resetTransform(),o.clearFullScreen&&o.clearRect(t,0,0,r*e,n*e,a.background))}));var m=function t(e){e.isVisible()&&!e.isCulled()&&(o.renderDisplayObject(e,f,c),o.saveDirtyAABB(e)),(e.sortable.sorted||e.childNodes).forEach((function(e){t(e)}))};c.hooks.endFrame.tap(t.tag,(function(){var t,r,n=f.getContext(),i=f.getDPR();if(t=o.dprMatrix,r=p(i,i,1),t[0]=r[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=r[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,u(o.vpMatrix,o.dprMatrix,s.getOrthoMatrix()),o.clearFullScreen)m(l.root);else{var h=o.safeMergeAABB.apply(o,[o.mergeDirtyAABBs(o.renderQueue)].concat(o.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,i=t.maxX,o=t.maxY,a=new e.AABB;return a.setMinMax(p(r,n,0),p(i,o,0)),a}))));if(o.removedRBushNodeAABBs=[],e.AABB.isEmpty(h))return void(o.renderQueue=[]);var y=o.convertAABB2Rect(h),g=y.x,x=y.y,w=y.width,b=y.height,A=v(o.vec3a,p(g,x,0),o.vpMatrix),E=v(o.vec3b,p(g+w,x,0),o.vpMatrix),S=v(o.vec3c,p(g,x+b,0),o.vpMatrix),M=v(o.vec3d,p(g+w,x+b,0),o.vpMatrix),O=Math.min(A[0],E[0],M[0],S[0]),B=Math.min(A[1],E[1],M[1],S[1]),L=Math.max(A[0],E[0],M[0],S[0]),R=Math.max(A[1],E[1],M[1],S[1]),P=Math.floor(O),T=Math.floor(B),N=Math.ceil(L-O),k=Math.ceil(R-B);n.save(),o.clearRect(n,P,T,N,k,a.background),n.beginPath(),n.rect(P,T,N,k),n.clip(),n.setTransform(o.vpMatrix[0],o.vpMatrix[1],o.vpMatrix[4],o.vpMatrix[5],o.vpMatrix[12],o.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&d.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:P,y:T,width:N,height:k}})),o.searchDirtyObjects(h).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&o.renderDisplayObject(t,f,c)})),n.restore(),o.renderQueue.forEach((function(t){o.saveDirtyAABB(t)})),o.renderQueue=[]}o.restoreStack.forEach((function(){n.restore()})),o.restoreStack=[]})),c.hooks.render.tap(t.tag,(function(t){o.clearFullScreen||o.renderQueue.push(t)}))},n.clearRect=function(t,e,r,n,i,o){t.clearRect(e,r,n,i),o&&(t.fillStyle=o,t.fillRect(e,r,n,i))},n.renderDisplayObject=function(t,r,n){var i=r.getContext(),o=t.nodeName,a=this.restoreStack[this.restoreStack.length-1];!a||t.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_CONTAINS||(i.restore(),this.restoreStack.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],l=t.parsedStyle.clipPath;if(l){this.applyWorldTransform(i,l);var h=this.pathGeneratorFactory[l.nodeName];h&&(i.save(),this.restoreStack.push(t),i.beginPath(),h(i,l.parsedStyle),i.closePath(),i.clip())}s&&(this.applyWorldTransform(i,t),i.save(),this.applyAttributesToContext(i,t)),c&&(i.beginPath(),c(i,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&i.closePath()),s&&(s.render(i,t.parsedStyle,t,n),i.restore()),t.renderable.dirty=!1},n.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),i=Math.floor(e[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(t){var r=t.getMin(),n=r[0],i=r[1],o=t.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[1]}).map((function(t){return e.runtime.displayObjectPool.getByEntity(t.id)}))},n.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,s=r.lineDashOffset;a&&t.setLineDash(a),g(s)||(t.lineDashOffset=s),g(o)||(t.globalAlpha*=o),g(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),g(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},n.applyWorldTransform=function(t,e,r){var n=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var c=e.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}r?(h(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,r,this.tmpMat4),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(h(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(e){t.add(e)})),t},t}();w.tag="CanvasRenderer";var b=function(){function t(t){this.imagePool=void 0,this.imagePool=t}var r=t.prototype;return r.render=function(t,r,n,i){var o=r.fill,a=r.fillRule,s=r.opacity,c=r.fillOpacity,l=r.stroke,h=r.strokeOpacity,u=r.lineWidth,f=r.lineCap,d=r.lineJoin,p=r.shadowType,v=r.shadowColor,y=r.shadowBlur,m=r.filter,x=r.miterLimit,w=!g(o)&&!o.isNone,b=!g(l)&&!l.isNone&&u>0,E=0===o.alpha,S=!(!m||!m.length),M=!g(v)&&y>0,O=n.nodeName,B="inner"===p,L=b&&M&&(O===e.Shape.PATH||O===e.Shape.LINE||O===e.Shape.POLYLINE||E||B);w&&(t.globalAlpha=s*c,L||A(n,t,M),this.fill(t,n,o,a,i),L||this.clearShadowAndFilter(t,S,M)),b&&(t.globalAlpha=s*h,t.lineWidth=u,g(x)||(t.miterLimit=x),g(f)||(t.lineCap=f),g(d)||(t.lineJoin=d),L&&(B&&(t.globalCompositeOperation="source-atop"),A(n,t,!0),B&&(this.stroke(t,n,l,i),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,S,!0))),this.stroke(t,n,l,i))},r.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!g(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.fill=function(t,r,n,i,o){var a=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=a.getColor(e,r,t),t.fill(i)})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o)),t.fill(i))},r.stroke=function(t,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=o.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,i)),t.stroke())},r.getPattern=function(t,e,r,n){return this.imagePool.getOrCreatePatternSync(t,r,(function(){e.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(t,r,n){var i;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:t.type},t.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},t}();function A(t,e,r){var n=t.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,s=n.shadowOffsetX,c=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=""+o,e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var E=function(){function t(t){this.imagePool=void 0,this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.img,o=e.shadowColor,a=e.shadowBlur,s=e.width,c=e.height;if(x(i)?n=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),n=i),n){A(r,t,!g(o)&&a>0);try{t.drawImage(n,0,0,s,c)}catch(t){}}},t}(),S=function(){function t(){}var e=t.prototype;return e.render=function(t,e,r){var n=e.lineWidth,i=e.textAlign,o=e.textBaseline,a=e.lineJoin,s=e.miterLimit,c=e.letterSpacing,l=e.stroke,h=e.fill,u=e.fillOpacity,f=e.strokeOpacity,d=e.opacity,p=e.metrics,v=e.dx,y=e.dy,m=e.shadowColor,x=e.shadowBlur,w=p.lines,b=p.height,E=p.lineHeight,S=p.lineMetrics;t.font=p.font,t.lineWidth=n,t.textAlign="middle"===i?"center":i,t.textBaseline=o,t.lineJoin=a,g(s)||(t.miterLimit=s);var M=0;"middle"===o?M=-b/2-E/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?M=-b:"top"!==o&&"hanging"!==o||(M=-E);var O=v||0;M+=y||0,A(r,t,!g(m)&&x>0);for(var B=0;w.length>B;B++){var L=n/2+O;M+=E,g(l)||l.isNone||!n||this.drawLetterSpacing(t,w[B],S[B],i,L,M,c,u,f,d,!0),g(h)||this.drawLetterSpacing(t,w[B],S[B],i,L,M,c,u,f,d)}},e.drawLetterSpacing=function(t,e,r,n,i,o,a,s,c,l,h){if(void 0===h&&(h=!1),0!==a){var u=t.textAlign;t.textAlign="left";var f=i;"center"===n||"middle"===n?f=i-r.width/2:"right"!==n&&"end"!==n||(f=i-r.width);for(var d=Array.from(e),p=t.measureText(e).width,v=0,y=0;d.length>y;++y){var g=d[y];h?this.strokeText(t,g,f,o,c):this.fillText(t,g,f,o,s,l),f+=p-(v=t.measureText(e.substring(y+1)).width)+a,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,o,c):this.fillText(t,e,i,o,s,l)},e.fillText=function(t,e,r,n,i,o){var a,s=!g(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,r,n),s&&(t.globalAlpha=a)},e.strokeText=function(t,e,r,n,i){var o,a=!g(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),a&&(t.globalAlpha=o)},t}(),M=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),O=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),B=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),L=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),R=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),P=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),T=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),N=function(t){function r(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=e,r}a(r,t);var n=r.prototype;return n.init=function(){var t,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new b(n),a=((t={})[e.Shape.CIRCLE]=i,t[e.Shape.ELLIPSE]=i,t[e.Shape.RECT]=i,t[e.Shape.IMAGE]=new E(n),t[e.Shape.TEXT]=new S,t[e.Shape.LINE]=i,t[e.Shape.POLYLINE]=i,t[e.Shape.POLYGON]=i,t[e.Shape.PATH]=i,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new w(r))},n.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=O,t.EllipseRenderer=B,t.ImageRenderer=E,t.LineRenderer=L,t.PathRenderer=T,t.Plugin=N,t.PolygonRenderer=P,t.PolylineRenderer=R,t.RectRenderer=M,t.TextRenderer=S,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.7.31", | ||
"version": "1.7.32", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -33,5 +33,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@antv/g-math": "^1.7.28", | ||
"@antv/g-plugin-canvas-path-generator": "^1.1.28", | ||
"@antv/g-plugin-image-loader": "^1.1.29", | ||
"@antv/g-math": "^1.7.29", | ||
"@antv/g-plugin-canvas-path-generator": "^1.1.29", | ||
"@antv/g-plugin-image-loader": "^1.1.30", | ||
"@antv/util": "^3.3.1", | ||
@@ -50,3 +50,3 @@ "gl-matrix": "^3.1.0", | ||
}, | ||
"gitHead": "c92278756907344ff54ebc6f6a83630559ef36ff" | ||
"gitHead": "9c99243a29308d12fc22ab4f3290033771e53fcb" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191299