@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.4.0 to 1.5.0
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g"),require("@antv/g-plugin-canvas-path-generator"),require("@antv/g-plugin-image-loader")):"function"==typeof define&&define.amd?define(["exports","@antv/g","@antv/g-plugin-canvas-path-generator","@antv/g-plugin-image-loader"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G,e.window.G.CanvasPathGenerator,e.window.G.ImageLoader)}(this,(function(e,t,r,n){"use strict";function o(){ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new C(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var l=w(a,r);if(l){if(l===h)continue;return l}}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 s=u(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,i),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function f(){}function p(){}var y={};s(y,i,(function(){return this}));var v=Object.getPrototypeOf,g=v&&v(v(S([])));g&&g!==t&&r.call(g,i)&&(y=g);var m=p.prototype=d.prototype=Object.create(y);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(o,i,a,l){var s=u(e[o],e,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(h).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,l)}))}l(s.arg)}var o;this._invoke=function(e,r){function i(){return new t((function(t,o){n(e,r,t,o)}))}return o=o?o.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return f.prototype=p,s(m,"constructor",p),s(p,"constructor",f),f.displayName=s(p,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,l,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},R(b.prototype),s(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(m),s(m,l,"Generator"),s(m,i,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,C.prototype={constructor:C,reset:function(e){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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var l=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(l&&s){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(l){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===e||"continue"===e)&&t>=i.tryLoc&&i.finallyLoc>=t&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function i(e,t,r,n,o,i,a){try{var l=e[i](a),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function l(e){i(a,n,o,l,s,"next",e)}function s(e){i(a,n,o,l,s,"throw",e)}l(void 0)}))}}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e,t,r,n){var o,i=arguments.length,a=3>i?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(a=(3>i?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var d="undefined"!=typeof Float32Array?Float32Array:Array;function f(e,t){var r=t[4],n=t[5],o=t[6],i=t[8],a=t[9],l=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(r,n,o),e[2]=Math.hypot(i,a,l),e}function p(){var e=new d(3);return d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function y(e,t,r){var n=new d(3);return n[0]=e,n[1]=t,n[2]=r,n}function v(e,t,r){var n=t[0],o=t[1],i=t[2],a=r[0],l=r[1],s=r[2];return e[0]=o*s-i*l,e[1]=i*a-n*s,e[2]=n*l-o*a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var g,m=function(e){return Math.hypot(e[0],e[1],e[2])};g=p();!function(){var e,t=(e=new d(4),d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();function R(){var e=new d(4);return d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function b(e,t,r,n){var o,i,a,l,s,c=t[0],u=t[1],h=t[2],d=t[3],f=r[0],p=r[1],y=r[2],v=r[3];return 0>(i=c*f+u*p+h*y+d*v)&&(i=-i,f=-f,p=-p,y=-y,v=-v),1-i>1e-6?(o=Math.acos(i),a=Math.sin(o),l=Math.sin((1-n)*o)/a,s=Math.sin(n*o)/a):(l=1-n,s=n),e[0]=l*c+s*f,e[1]=l*u+s*p,e[2]=l*h+s*y,e[3]=l*d+s*v,e}var w,x,A,C,S,P,E,B=function(e,t){var r=t[0],n=t[1],o=t[2],i=t[3],a=r*r+n*n+o*o+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=o*a,e[3]=i*a,e},k=(w=p(),x=y(1,0,0),A=y(0,1,0),C=R(),S=R(),P=new d(9),d!=Float32Array&&(P[1]=0,P[2]=0,P[3]=0,P[5]=0,P[6]=0,P[7]=0),P[0]=1,P[4]=1,P[8]=1,E=P,t.Syringe.defineToken("StyleRendererFactory")),L=t.Syringe.defineToken("CircleRenderer",{multiple:!1}),N=t.Syringe.defineToken("EllipseRenderer",{multiple:!1}),O=t.Syringe.defineToken("RectRenderer",{multiple:!1}),T=t.Syringe.defineToken("LineRenderer",{multiple:!1}),j=t.Syringe.defineToken("PolylineRenderer",{multiple:!1}),F=t.Syringe.defineToken("PolygonRenderer",{multiple:!1}),G=t.Syringe.defineToken("PathRenderer",{multiple:!1}),M=t.Syringe.defineToken("TextRenderer",{multiple:!1}),I=t.Syringe.defineToken("ImageRenderer",{multiple:!1});e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,o=r.img,i=r.width.value,a=r.height.value;if(t.isString(o)?n=this.imagePool.getImageSync(o):(i||(i=o.width),a||(a=o.height),n=o),n)try{e.drawImage(n,0,0,i,a)}catch(e){}},e}(),u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],e.ImageRenderer.prototype,"imagePool",void 0),e.ImageRenderer=u([t.singleton({token:I})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var o=r.lineWidth,i=r.textAlign,a=r.textBaseline,l=r.lineJoin,s=r.miterLimit,c=void 0===s?0:s,u=r.letterSpacing,h=void 0===u?0:u,d=r.stroke,f=r.fill,p=r.fillOpacity,y=r.strokeOpacity,v=r.opacity,g=r.metrics,m=r.dx,R=r.dy,b=g.lines,w=g.height,x=g.lineHeight,A=g.lineMetrics;e.font=g.font,e.lineWidth=o.value,e.textAlign=i.value,e.textBaseline=a.value,e.lineJoin=l.value,e.miterLimit=c;var C=0;"middle"===a.value?C=-w/2-x/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?C=-w:"top"!==a.value&&"hanging"!==a.value||(C=-x);var S=0;m&&m.unit===t.UnitType.kPixels&&(S+=m.value),R&&R.unit===t.UnitType.kPixels&&(C+=R.value);for(var P=0;b.length>P;P++){var E=o.value/2+S;C+=x,!t.isNil(d)&&!d.isNone&&o&&o.value&&this.drawLetterSpacing(e,b[P],A[P],i.value,E,C,h,p.value,y.value,v.value,!0),t.isNil(f)||this.drawLetterSpacing(e,b[P],A[P],i.value,E,C,h,p.value,y.value,v.value)}},r.drawLetterSpacing=function(e,t,r,n,o,i,a,l,s,c,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=o;"center"===n?d=o-r.width/2:"right"!==n&&"end"!==n||(d=o-r.width);for(var f=Array.from(t),p=e.measureText(t).width,y=0,v=0;f.length>v;++v){var g=f[v];u?this.strokeText(e,g,d,i,s):this.fillText(e,g,d,i,l,c),d+=p-(y=e.measureText(t.substring(v+1)).width)+a,p=y}e.textAlign=h}else u?this.strokeText(e,t,o,i,s):this.fillText(e,t,o,i,l,c)},r.fillText=function(e,r,n,o,i,a){var l,s=!t.isNil(i)&&1!==i;s&&(l=e.globalAlpha,e.globalAlpha=i*a),e.fillText(r,n,o),s&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,o,i){var a,l=!t.isNil(i)&&1!==i;l&&(a=e.globalAlpha,e.globalAlpha=i),e.strokeText(r,n,o),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=u([t.singleton({token:M})],e.TextRenderer);var D,_,Y=function(){function e(){this.imagePool=void 0}var r=e.prototype;return r.render=function(e,r,n,o){var i=r.fill,a=r.opacity,l=r.fillOpacity,s=r.stroke,c=r.strokeOpacity,u=r.lineWidth,h=r.lineCap,d=r.lineJoin,f=r.shadowColor,p=r.filter,y=r.miterLimit,v=!t.isNil(i)&&!i.isNone,g=!t.isNil(s)&&!s.isNone,m=0===i.alpha;if(v&&(t.isNil(l)||1===l.value?this.fill(e,n,i,o):(e.globalAlpha=l.value,this.fill(e,n,i,o),e.globalAlpha=a.value)),g&&u&&u.value>0){var R,b,w;!t.isNil(c)&&1!==c.value&&(e.globalAlpha=c.value),e.lineWidth=u.value,t.isNil(y)||(e.miterLimit=y),t.isNil(h)||(e.lineCap=h.value),t.isNil(d)||(e.lineJoin=d.value);var x=!t.isNil(f),A=!t.isNil(p);x&&(b=e.shadowColor,t.isNil(R=e.shadowBlur)||(e.shadowColor="transparent",e.shadowBlur=0)),A&&!t.isNil(w=e.filter)&&w.indexOf("drop-shadow")>-1&&(e.filter=w.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var C=v&&!m;C&&this.stroke(e,n,s,o),x&&(e.shadowColor=b,e.shadowBlur=R),A&&(e.filter=w),C||this.stroke(e,n,s,o)}},r.fill=function(e,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=i.getColor(t,r,e),e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,o)),e.fill())},r.stroke=function(e,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=i.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,o)),e.stroke())},r.getPattern=function(e,t,r,n){return this.imagePool.getOrCreatePatternSync(e,r,(function(){t.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(e,r,n){var o;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var i=r.getGeometryBounds();o=this.imagePool.getOrCreateGradient(l({type:e.type},e.value,{width:i&&2*i.halfExtents[0]||1,height:i&&2*i.halfExtents[1]||1}),n)}return o},e}();u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],Y.prototype,"imagePool",void 0),Y=u([t.singleton()],Y),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.RectRenderer=u([t.singleton({token:O})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.CircleRenderer=u([t.singleton({token:L})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.EllipseRenderer=u([t.singleton({token:N})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.LineRenderer=u([t.singleton({token:T})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.PolylineRenderer=u([t.singleton({token:j})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.PolygonRenderer=u([t.singleton({token:F})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(Y),e.PathRenderer=u([t.singleton({token:G})],e.PathRenderer);var q=(D=function(){function e(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.tmpVec3=p(),this.tmpMat4=function(){var e=new d(16);return d!=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}()}var r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)},i=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(_.tag,a(o().mark((function e(){var a,l,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.CULLED,i),l=(a=r.canvasConfig).width,s=a.height,c=r.contextService.getContext(),r.clearRect(c,0,0,l,s);case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(_.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,i)})),e.hooks.beginFrame.tap(_.tag,(function(){var e=r.contextService.getContext(),t=r.canvasConfig,n=t.width,o=t.height;r.clearFullScreen=r.shouldClearFullScreen(),e&&(e.save(),r.clearFullScreen&&r.clearRect(e,0,0,n,o),r.applyTransform(e,r.camera.getOrthoMatrix()))})),e.hooks.endFrame.tap(_.tag,(function(){var n=r.contextService.getContext();if(r.clearFullScreen);else{var o=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,o=e.maxX,i=e.maxY,a=new t.AABB;return a.setMinMax(y(r,n,0),y(o,i,0)),a}))));if(r.removedRBushNodeAABBs=[],t.AABB.isEmpty(o))return void(r.renderQueue=[]);var i=r.convertAABB2Rect(o),a=i.x,l=i.y,s=i.width,c=i.height;r.clearRect(n,a,l,s,c),n.beginPath(),n.rect(a,l,s,c),n.clip(),r.searchDirtyObjects(o).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e)})),r.renderQueue.forEach((function(e){r.saveDirtyAABB(e)})),r.renderQueue=[]}r.restoreStack.forEach((function(e){n.restore()})),r.restoreStack=[],r.clearFullScreen=!1,n.restore()})),e.hooks.render.tap(_.tag,(function(t){r.clearFullScreen?t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e):r.renderQueue.push(t)}))},r.clearRect=function(e,t,r,n,o){e.clearRect(t,r,n,o);var i=this.canvasConfig.background;i&&(e.fillStyle=i,e.fillRect(t,r,n,o))},r.renderDisplayObject=function(e,r){for(var n=this.contextService.getContext(),o=this.restoreStack[this.restoreStack.length-1];o&&e.parentNode!==o;)n.restore(),this.restoreStack.pop(),o=this.restoreStack[this.restoreStack.length-1];var i=e.nodeName;void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];n.save(),this.applyTransform(n,e.getLocalTransform());var l=e.style.clipPath;if(l){n.save(),this.applyTransform(n,l.getLocalTransform()),void 0===this.pathGeneratorFactoryCache[l.nodeName]&&(this.pathGeneratorFactoryCache[l.nodeName]=this.pathGeneratorFactory(l.nodeName));var s=this.pathGeneratorFactoryCache[l.nodeName];s&&(this.useAnchor(n,l),n.beginPath(),s(n,l.parsedStyle),n.closePath()),n.restore(),n.clip()}n.save(),this.applyAttributesToContext(n,e),this.useAnchor(n,e),void 0===this.pathGeneratorFactoryCache[e.nodeName]&&(this.pathGeneratorFactoryCache[e.nodeName]=this.pathGeneratorFactory(e.nodeName));var c=this.pathGeneratorFactoryCache[e.nodeName];c&&(n.beginPath(),c(n,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&n.closePath()),a&&a.render(n,e.parsedStyle,e,r),n.restore(),e.renderable.dirty=!1,this.restoreStack.push(e)},r.shouldClearFullScreen=function(){return!this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering||this.renderingContext.renderReasons.has(t.RenderReason.CAMERA_CHANGED)},r.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),o=Math.floor(t[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},r.mergeDirtyAABBs=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},r.searchDirtyObjects=function(e){var t=this,r=e.getMin(),n=r[0],o=r[1],i=e.getMax();return this.rBush.search({minX:n,minY:o,maxX:i[0],maxY:i[1]}).map((function(e){return t.displayObjectPool.getByEntity(e.id)}))},r.saveDirtyAABB=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)},r.applyTransform=function(e,r){var n=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}(p(),r),o=n[0],i=n[1],a=f(p(),r),l=a[0],s=a[1],c=function(e,t){var r=new d(3);f(r,t);var n=1/r[0],o=1/r[1],i=1/r[2],a=t[0]*n,l=t[1]*o,s=t[2]*i,c=t[4]*n,u=t[5]*o,h=t[6]*i,p=t[8]*n,y=t[9]*o,v=t[10]*i,g=a+u+v,m=0;return g>0?(m=2*Math.sqrt(g+1),e[3]=.25*m,e[0]=(h-y)/m,e[1]=(p-s)/m,e[2]=(l-c)/m):a>u&&a>v?(m=2*Math.sqrt(1+a-u-v),e[3]=(h-y)/m,e[0]=.25*m,e[1]=(l+c)/m,e[2]=(p+s)/m):u>v?(m=2*Math.sqrt(1+u-a-v),e[3]=(p-s)/m,e[0]=(l+c)/m,e[1]=.25*m,e[2]=(h+y)/m):(m=2*Math.sqrt(1+v-a-u),e[3]=(l-c)/m,e[0]=(p+s)/m,e[1]=(h+y)/m,e[2]=.25*m),e}(R(),r),u=t.getEuler(p(),c),h=t.fromRotationTranslationScale(u[0]||u[2],o,i,l,s);e.transform(h[0],h[1],h[3],h[4],h[6],h[7])},r.applyAttributesToContext=function(e,r){var n=r.parsedStyle,o=n.stroke,i=n.fill,a=n.opacity,l=n.lineDash,s=n.lineDashOffset,c=n.filter,u=n.shadowColor,h=n.shadowBlur,d=n.shadowOffsetX,f=n.shadowOffsetY;l&&Array.isArray(l)&&e.setLineDash(l.map((function(e){return e.value}))),t.isNil(s)||(e.lineDashOffset=s.value),t.isNil(a)||(e.globalAlpha*=a.value),t.isNil(o)||Array.isArray(o)||o.isNone||(e.strokeStyle=r.attributes.stroke),t.isNil(i)||Array.isArray(i)||i.isNone||(e.fillStyle=r.attributes.fill),t.isNil(c)||(e.filter=r.style.filter),t.isNil(u)||(e.shadowColor=u.toString(),e.shadowBlur=h&&h.value||0,e.shadowOffsetX=d&&d.value||0,e.shadowOffsetY=f&&f.value||0)},r.useAnchor=function(e,t){var r=(t.parsedStyle||{}).anchor,n=t.getGeometryBounds(),o=-(r&&r[0].value||0)*(n&&2*n.halfExtents[0]||0),i=-(r&&r[1].value||0)*(n&&2*n.halfExtents[1]||0);0===o&&0===i||e.translate(o,i)},r.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];return n.forEach((function(t){e.add(t)})),e},e}(),D.tag="CanvasRenderer",_=D);u([t.inject(t.CanvasConfig),h("design:type",Object)],q.prototype,"canvasConfig",void 0),u([t.inject(t.DefaultCamera),h("design:type",t.Camera)],q.prototype,"camera",void 0),u([t.inject(t.ContextService),h("design:type",Object)],q.prototype,"contextService",void 0),u([t.inject(t.RenderingContext),h("design:type",Object)],q.prototype,"renderingContext",void 0),u([t.inject(r.PathGeneratorFactory),h("design:type",Function)],q.prototype,"pathGeneratorFactory",void 0),u([t.inject(k),h("design:type",Function)],q.prototype,"styleRendererFactory",void 0),u([t.inject(t.DisplayObjectPool),h("design:type",t.DisplayObjectPool)],q.prototype,"displayObjectPool",void 0),u([t.inject(t.RBushRoot),h("design:type",t.RBush)],q.prototype,"rBush",void 0),q=_=u([t.singleton({contrib:t.RenderingPluginContribution})],q);var U=t.Module((function(r){var n;r(e.CircleRenderer),r(e.EllipseRenderer),r(e.RectRenderer),r(e.ImageRenderer),r(e.TextRenderer),r(e.LineRenderer),r(e.PolylineRenderer),r(e.PolygonRenderer),r(e.PathRenderer);var o=((n={})[t.Shape.CIRCLE]=L,n[t.Shape.ELLIPSE]=N,n[t.Shape.RECT]=O,n[t.Shape.IMAGE]=I,n[t.Shape.TEXT]=M,n[t.Shape.LINE]=T,n[t.Shape.POLYLINE]=j,n[t.Shape.POLYGON]=F,n[t.Shape.PATH]=G,n);r({token:k,useFactory:function(e){return function(t){var r=o[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(q)})),X=function(){function e(){this.name="canvas-renderer"}var t=e.prototype;return t.init=function(e){e.load(U,!0)},t.destroy=function(e){e.unload(U)},e}();e.CircleRendererContribution=L,e.EllipseRendererContribution=N,e.ImageRendererContribution=I,e.LineRendererContribution=T,e.PathRendererContribution=G,e.Plugin=X,e.PolygonRendererContribution=F,e.PolylineRendererContribution=j,e.RectRendererContribution=O,e.StyleRendererFactory=k,e.TextRendererContribution=M,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new C(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var l=w(a,r);if(l){if(l===h)continue;return l}}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 s=u(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,i),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function f(){}function p(){}var y={};s(y,i,(function(){return this}));var v=Object.getPrototypeOf,g=v&&v(v(S([])));g&&g!==t&&r.call(g,i)&&(y=g);var m=p.prototype=d.prototype=Object.create(y);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(o,i,a,l){var s=u(e[o],e,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(h).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,l)}))}l(s.arg)}var o;this._invoke=function(e,r){function i(){return new t((function(t,o){n(e,r,t,o)}))}return o=o?o.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return f.prototype=p,s(m,"constructor",p),s(p,"constructor",f),f.displayName=s(p,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,l,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},R(b.prototype),s(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(m),s(m,l,"Generator"),s(m,i,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,C.prototype={constructor:C,reset:function(e){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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var l=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(l&&s){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(l){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===e||"continue"===e)&&t>=i.tryLoc&&i.finallyLoc>=t&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function i(e,t,r,n,o,i,a){try{var l=e[i](a),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function l(e){i(a,n,o,l,s,"next",e)}function s(e){i(a,n,o,l,s,"throw",e)}l(void 0)}))}}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e,t,r,n){var o,i=arguments.length,a=3>i?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(a=(3>i?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var d="undefined"!=typeof Float32Array?Float32Array:Array;function f(){var e=new d(3);return d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function p(e,t,r){var n=new d(3);return n[0]=e,n[1]=t,n[2]=r,n}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});y=f();var y,v=t.Syringe.defineToken("StyleRendererFactory"),g=t.Syringe.defineToken("CircleRenderer",{multiple:!1}),m=t.Syringe.defineToken("EllipseRenderer",{multiple:!1}),R=t.Syringe.defineToken("RectRenderer",{multiple:!1}),b=t.Syringe.defineToken("LineRenderer",{multiple:!1}),w=t.Syringe.defineToken("PolylineRenderer",{multiple:!1}),x=t.Syringe.defineToken("PolygonRenderer",{multiple:!1}),A=t.Syringe.defineToken("PathRenderer",{multiple:!1}),C=t.Syringe.defineToken("TextRenderer",{multiple:!1}),S=t.Syringe.defineToken("ImageRenderer",{multiple:!1});e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,o=r.img,i=r.width.value,a=r.height.value;if(t.isString(o)?n=this.imagePool.getImageSync(o):(i||(i=o.width),a||(a=o.height),n=o),n)try{e.drawImage(n,0,0,i,a)}catch(e){}},e}(),u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],e.ImageRenderer.prototype,"imagePool",void 0),e.ImageRenderer=u([t.singleton({token:S})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var o=r.lineWidth,i=r.textAlign,a=r.textBaseline,l=r.lineJoin,s=r.miterLimit,c=void 0===s?0:s,u=r.letterSpacing,h=void 0===u?0:u,d=r.stroke,f=r.fill,p=r.fillOpacity,y=r.strokeOpacity,v=r.opacity,g=r.metrics,m=r.dx,R=r.dy,b=g.lines,w=g.height,x=g.lineHeight,A=g.lineMetrics;e.font=g.font,e.lineWidth=o.value,e.textAlign=i.value,e.textBaseline=a.value,e.lineJoin=l.value,e.miterLimit=c;var C=0;"middle"===a.value?C=-w/2-x/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?C=-w:"top"!==a.value&&"hanging"!==a.value||(C=-x);var S=0;m&&m.unit===t.UnitType.kPixels&&(S+=m.value),R&&R.unit===t.UnitType.kPixels&&(C+=R.value);for(var P=0;b.length>P;P++){var E=o.value/2+S;C+=x,!t.isNil(d)&&!d.isNone&&o&&o.value&&this.drawLetterSpacing(e,b[P],A[P],i.value,E,C,h,p.value,y.value,v.value,!0),t.isNil(f)||this.drawLetterSpacing(e,b[P],A[P],i.value,E,C,h,p.value,y.value,v.value)}},r.drawLetterSpacing=function(e,t,r,n,o,i,a,l,s,c,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=o;"center"===n?d=o-r.width/2:"right"!==n&&"end"!==n||(d=o-r.width);for(var f=Array.from(t),p=e.measureText(t).width,y=0,v=0;f.length>v;++v){var g=f[v];u?this.strokeText(e,g,d,i,s):this.fillText(e,g,d,i,l,c),d+=p-(y=e.measureText(t.substring(v+1)).width)+a,p=y}e.textAlign=h}else u?this.strokeText(e,t,o,i,s):this.fillText(e,t,o,i,l,c)},r.fillText=function(e,r,n,o,i,a){var l,s=!t.isNil(i)&&1!==i;s&&(l=e.globalAlpha,e.globalAlpha=i*a),e.fillText(r,n,o),s&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,o,i){var a,l=!t.isNil(i)&&1!==i;l&&(a=e.globalAlpha,e.globalAlpha=i),e.strokeText(r,n,o),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=u([t.singleton({token:C})],e.TextRenderer);var P,E,B=function(){function e(){this.imagePool=void 0}var r=e.prototype;return r.render=function(e,r,n,o){var i=r.fill,a=r.opacity,l=r.fillOpacity,s=r.stroke,c=r.strokeOpacity,u=r.lineWidth,h=r.lineCap,d=r.lineJoin,f=r.shadowColor,p=r.filter,y=r.miterLimit,v=!t.isNil(i)&&!i.isNone,g=!t.isNil(s)&&!s.isNone,m=0===i.alpha;if(v&&(t.isNil(l)||1===l.value?this.fill(e,n,i,o):(e.globalAlpha=l.value,this.fill(e,n,i,o),e.globalAlpha=a.value)),g&&u&&u.value>0){var R,b,w;!t.isNil(c)&&1!==c.value&&(e.globalAlpha=c.value),e.lineWidth=u.value,t.isNil(y)||(e.miterLimit=y),t.isNil(h)||(e.lineCap=h.value),t.isNil(d)||(e.lineJoin=d.value);var x=!t.isNil(f),A=!t.isNil(p);x&&(b=e.shadowColor,t.isNil(R=e.shadowBlur)||(e.shadowColor="transparent",e.shadowBlur=0)),A&&!t.isNil(w=e.filter)&&w.indexOf("drop-shadow")>-1&&(e.filter=w.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var C=v&&!m;C&&this.stroke(e,n,s,o),x&&(e.shadowColor=b,e.shadowBlur=R),A&&(e.filter=w),C||this.stroke(e,n,s,o)}},r.fill=function(e,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=i.getColor(t,r,e),e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,o)),e.fill())},r.stroke=function(e,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=i.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,o)),e.stroke())},r.getPattern=function(e,t,r,n){return this.imagePool.getOrCreatePatternSync(e,r,(function(){t.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(e,r,n){var o;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var i=r.getGeometryBounds();o=this.imagePool.getOrCreateGradient(l({type:e.type},e.value,{width:i&&2*i.halfExtents[0]||1,height:i&&2*i.halfExtents[1]||1}),n)}return o},e}();u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],B.prototype,"imagePool",void 0),B=u([t.singleton()],B),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.RectRenderer=u([t.singleton({token:R})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.CircleRenderer=u([t.singleton({token:g})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.EllipseRenderer=u([t.singleton({token:m})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.LineRenderer=u([t.singleton({token:b})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.PolylineRenderer=u([t.singleton({token:w})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.PolygonRenderer=u([t.singleton({token:x})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return s(t,e),t}(B),e.PathRenderer=u([t.singleton({token:A})],e.PathRenderer);var k=(P=function(){function e(){var e;this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.tmpVec3=f(),this.tmpMat4=(e=new d(16),d!=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)}var r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)},i=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(E.tag,a(o().mark((function e(){var a,l,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.CULLED,i),l=(a=r.canvasConfig).width,s=a.height,c=r.contextService.getContext(),r.clearRect(c,0,0,l,s);case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(E.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,i)})),e.hooks.beginFrame.tap(E.tag,(function(){var e=r.contextService.getContext(),t=r.canvasConfig,n=t.width,o=t.height;r.clearFullScreen=r.shouldClearFullScreen(),e&&(e.save(),r.clearFullScreen&&r.clearRect(e,0,0,n,o),r.applyTransform(e,r.camera.getOrthoMatrix()))})),e.hooks.endFrame.tap(E.tag,(function(){var n=r.contextService.getContext();if(r.clearFullScreen);else{var o=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,o=e.maxX,i=e.maxY,a=new t.AABB;return a.setMinMax(p(r,n,0),p(o,i,0)),a}))));if(r.removedRBushNodeAABBs=[],t.AABB.isEmpty(o))return void(r.renderQueue=[]);var i=r.convertAABB2Rect(o),a=i.x,l=i.y,s=i.width,c=i.height;r.clearRect(n,a,l,s,c),n.beginPath(),n.rect(a,l,s,c),n.clip(),r.searchDirtyObjects(o).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e)})),r.renderQueue.forEach((function(e){r.saveDirtyAABB(e)})),r.renderQueue=[]}r.restoreStack.forEach((function(e){n.restore()})),r.restoreStack=[],r.clearFullScreen=!1,n.restore()})),e.hooks.render.tap(E.tag,(function(t){r.clearFullScreen?t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e):r.renderQueue.push(t)}))},r.clearRect=function(e,t,r,n,o){e.clearRect(t,r,n,o);var i=this.canvasConfig.background;i&&(e.fillStyle=i,e.fillRect(t,r,n,o))},r.renderDisplayObject=function(e,r){for(var n=this.contextService.getContext(),o=this.restoreStack[this.restoreStack.length-1];o&&e.parentNode!==o;)n.restore(),this.restoreStack.pop(),o=this.restoreStack[this.restoreStack.length-1];var i=e.nodeName;void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];n.save(),this.applyTransform(n,e.getLocalTransform());var l=e.style.clipPath;if(l){n.save(),this.applyTransform(n,l.getLocalTransform()),void 0===this.pathGeneratorFactoryCache[l.nodeName]&&(this.pathGeneratorFactoryCache[l.nodeName]=this.pathGeneratorFactory(l.nodeName));var s=this.pathGeneratorFactoryCache[l.nodeName];s&&(this.useAnchor(n,l),n.beginPath(),s(n,l.parsedStyle),n.closePath()),n.restore(),n.clip()}n.save(),this.applyAttributesToContext(n,e),this.useAnchor(n,e),void 0===this.pathGeneratorFactoryCache[e.nodeName]&&(this.pathGeneratorFactoryCache[e.nodeName]=this.pathGeneratorFactory(e.nodeName));var c=this.pathGeneratorFactoryCache[e.nodeName];c&&(n.beginPath(),c(n,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&n.closePath()),a&&a.render(n,e.parsedStyle,e,r),n.restore(),e.renderable.dirty=!1,this.restoreStack.push(e)},r.shouldClearFullScreen=function(){return!this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering||this.renderingContext.renderReasons.has(t.RenderReason.CAMERA_CHANGED)},r.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),o=Math.floor(t[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},r.mergeDirtyAABBs=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},r.searchDirtyObjects=function(e){var t=this,r=e.getMin(),n=r[0],o=r[1],i=e.getMax();return this.rBush.search({minX:n,minY:o,maxX:i[0],maxY:i[1]}).map((function(e){return t.displayObjectPool.getByEntity(e.id)}))},r.saveDirtyAABB=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)},r.applyTransform=function(e,t){e.transform(t[0],t[1],t[4],t[5],t[12],t[13])},r.applyAttributesToContext=function(e,r){var n=r.parsedStyle,o=n.stroke,i=n.fill,a=n.opacity,l=n.lineDash,s=n.lineDashOffset,c=n.filter,u=n.shadowColor,h=n.shadowBlur,d=n.shadowOffsetX,f=n.shadowOffsetY;l&&Array.isArray(l)&&e.setLineDash(l.map((function(e){return e.value}))),t.isNil(s)||(e.lineDashOffset=s.value),t.isNil(a)||(e.globalAlpha*=a.value),t.isNil(o)||Array.isArray(o)||o.isNone||(e.strokeStyle=r.attributes.stroke),t.isNil(i)||Array.isArray(i)||i.isNone||(e.fillStyle=r.attributes.fill),t.isNil(c)||(e.filter=r.style.filter),!t.isNil(u)&&h.value>0&&(e.shadowColor=u.toString(),e.shadowBlur=h&&h.value||0,e.shadowOffsetX=d&&d.value||0,e.shadowOffsetY=f&&f.value||0)},r.useAnchor=function(e,t){var r=(t.parsedStyle||{}).anchor,n=t.getGeometryBounds(),o=-(r&&r[0].value||0)*(n&&2*n.halfExtents[0]||0),i=-(r&&r[1].value||0)*(n&&2*n.halfExtents[1]||0);0===o&&0===i||e.translate(o,i)},r.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];return n.forEach((function(t){e.add(t)})),e},e}(),P.tag="CanvasRenderer",E=P);u([t.inject(t.CanvasConfig),h("design:type",Object)],k.prototype,"canvasConfig",void 0),u([t.inject(t.DefaultCamera),h("design:type",t.Camera)],k.prototype,"camera",void 0),u([t.inject(t.ContextService),h("design:type",Object)],k.prototype,"contextService",void 0),u([t.inject(t.RenderingContext),h("design:type",Object)],k.prototype,"renderingContext",void 0),u([t.inject(r.PathGeneratorFactory),h("design:type",Function)],k.prototype,"pathGeneratorFactory",void 0),u([t.inject(v),h("design:type",Function)],k.prototype,"styleRendererFactory",void 0),u([t.inject(t.DisplayObjectPool),h("design:type",t.DisplayObjectPool)],k.prototype,"displayObjectPool",void 0),u([t.inject(t.RBushRoot),h("design:type",t.RBush)],k.prototype,"rBush",void 0),k=E=u([t.singleton({contrib:t.RenderingPluginContribution})],k);var L=t.Module((function(r){var n;r(e.CircleRenderer),r(e.EllipseRenderer),r(e.RectRenderer),r(e.ImageRenderer),r(e.TextRenderer),r(e.LineRenderer),r(e.PolylineRenderer),r(e.PolygonRenderer),r(e.PathRenderer);var o=((n={})[t.Shape.CIRCLE]=g,n[t.Shape.ELLIPSE]=m,n[t.Shape.RECT]=R,n[t.Shape.IMAGE]=S,n[t.Shape.TEXT]=C,n[t.Shape.LINE]=b,n[t.Shape.POLYLINE]=w,n[t.Shape.POLYGON]=x,n[t.Shape.PATH]=A,n);r({token:v,useFactory:function(e){return function(t){var r=o[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(k)})),N=function(){function e(){this.name="canvas-renderer"}var t=e.prototype;return t.init=function(e){e.load(L,!0)},t.destroy=function(e){e.unload(L)},e}();e.CircleRendererContribution=g,e.EllipseRendererContribution=m,e.ImageRendererContribution=S,e.LineRendererContribution=b,e.PathRendererContribution=A,e.Plugin=N,e.PolygonRendererContribution=x,e.PolylineRendererContribution=w,e.RectRendererContribution=R,e.StyleRendererFactory=v,e.TextRendererContribution=C,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@antv/g-math": "^1.4.0", | ||
"@antv/g-math": "^1.5.0", | ||
"tslib": "^2.3.1" | ||
@@ -45,3 +45,3 @@ }, | ||
}, | ||
"gitHead": "e080a6f903694e931383943c5ad8fbf84731c460" | ||
"gitHead": "464ea5f09af7cd041434233f113feeec3912357e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
198321
4109
Updated@antv/g-math@^1.5.0