@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.1.8-alpha.1 to 1.1.8
!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 i(){ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new P(n||[]);return i._invoke=function(e,t,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 A()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var l=x(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 c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var h={};function d(){}function f(){}function p(){}var v={};c(v,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(S([])));g&&g!==t&&r.call(g,o)&&(v=g);var m=p.prototype=d.prototype=Object.create(v);function R(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(i,o,a,l){var c=u(e[i],e,o);if("throw"!==c.type){var s=c.arg,h=s.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){s.value=e,a(s)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function x(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,x(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 i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function b(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 C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return f.prototype=p,c(m,"constructor",p),c(p,"constructor",f),f.displayName=c(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,c(e,l,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},R(w.prototype),c(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new w(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(m),c(m,l,"Generator"),c(m,o,(function(){return this})),c(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,P.prototype={constructor:P,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(C),!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 i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(l){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.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),C(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 i=n.arg;C(r)}return i}}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 o(e,t,r,n,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function l(e){o(a,n,i,l,c,"next",e)}function c(e){o(a,n,i,l,c,"throw",e)}l(void 0)}))}}function l(){return l=Object.assign||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 c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function u(e,t,r,n){var i,o=arguments.length,a=3>o?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--)(i=e[l])&&(a=(3>o?i(a):o>3?i(t,r,a):i(t,r))||a);return o>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],i=t[6],o=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,i),e[2]=Math.hypot(o,a,l),e}function p(){var e=new d(3);return d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function v(e,t,r){var n=new d(3);return n[0]=e,n[1]=t,n[2]=r,n}function y(e,t,r){var n=t[0],i=t[1],o=t[2],a=r[0],l=r[1],c=r[2];return e[0]=i*c-o*l,e[1]=o*a-n*c,e[2]=n*l-i*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 w(e,t,r,n){var i,o,a,l,c,s=t[0],u=t[1],h=t[2],d=t[3],f=r[0],p=r[1],v=r[2],y=r[3];return 0>(o=s*f+u*p+h*v+d*y)&&(o=-o,f=-f,p=-p,v=-v,y=-y),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),l=Math.sin((1-n)*i)/a,c=Math.sin(n*i)/a):(l=1-n,c=n),e[0]=l*s+c*f,e[1]=l*u+c*p,e[2]=l*h+c*v,e[3]=l*d+c*y,e}var x,b,C,P,S,A,E,L=function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=r*r+n*n+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=o*a,e},N=(x=p(),b=v(1,0,0),C=v(0,1,0),P=R(),S=R(),A=new d(9),d!=Float32Array&&(A[1]=0,A[2]=0,A[3]=0,A[5]=0,A[6]=0,A[7]=0),A[0]=1,A[4]=1,A[8]=1,E=A,function(){function e(){this.gradientCache={}}var r=e.prototype;return r.getOrCreateGradient=function(e,r){var n=this.generateCacheKey(e),i=e.type,o=e.x0,a=e.y0,l=e.x1,c=e.y1,s=e.steps,u=e.width,h=e.height;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientPatternType.LinearGradient)d=r.createLinearGradient(o*u,a*h,l*u,c*h);else if(i===t.GradientPatternType.RadialGradient){var f=Math.sqrt(u*u+h*h)/2;d=r.createRadialGradient(o*u,a*h,0,l*u,c*h,e.r1*f)}return d&&(s.forEach((function(e){var t,r=e[1];null===(t=d)||void 0===t||t.addColorStop(Number(e[0]),r)})),this.gradientCache[n]=d),this.gradientCache[n]},r.generateCacheKey=function(e){return"gradient-"+e.type+"-"+e.x0+"-"+e.y0+"-"+e.x1+"-"+e.y1+"-"+(e.r1||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},e}());N=u([t.singleton()],N);var B=t.Syringe.defineToken("StyleRendererFactory"),k=t.Syringe.defineToken("CircleRenderer",{multiple:!1}),O=t.Syringe.defineToken("EllipseRenderer",{multiple:!1}),T=t.Syringe.defineToken("RectRenderer",{multiple:!1}),j=t.Syringe.defineToken("LineRenderer",{multiple:!1}),F=t.Syringe.defineToken("PolylineRenderer",{multiple:!1}),G=t.Syringe.defineToken("PolygonRenderer",{multiple:!1}),M=t.Syringe.defineToken("PathRenderer",{multiple:!1}),I=t.Syringe.defineToken("TextRenderer",{multiple:!1}),D=t.Syringe.defineToken("ImageRenderer",{multiple:!1});e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,i=r.img,o=r.width.value,a=r.height.value;if(t.isString(i)?n=this.imagePool.getImageSync(i):(o||(o=i.width),a||(a=i.height),n=i),n)try{e.drawImage(n,0,0,o,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:D})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var i=r.lineWidth,o=r.textAlign,a=r.textBaseline,l=r.lineJoin,c=r.miterLimit,s=void 0===c?0:c,u=r.letterSpacing,h=void 0===u?0:u,d=r.stroke,f=r.fill,p=r.fillOpacity,v=r.strokeOpacity,y=r.opacity,g=r.metrics,m=r.dx,R=r.dy,w=g.lines,x=g.height,b=g.lineHeight,C=g.lineMetrics;e.font=g.font,e.lineWidth=i.value,e.textAlign=o.value,e.textBaseline=a.value,e.lineJoin=l.value,e.miterLimit=s;var P=0;"middle"===a.value?P=-x/2-b/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?P=-x:"top"!==a.value&&"hanging"!==a.value||(P=-b);var S=0;m&&m.unit===t.UnitType.kPixels&&(S+=m.value),R&&R.unit===t.UnitType.kPixels&&(P+=R.value);for(var A=0;w.length>A;A++){var E=i.value/2+S;P+=b,!t.isNil(d)&&!d.isNone&&i&&i.value&&this.drawLetterSpacing(e,w[A],C[A],o.value,E,P,h,p.value,v.value,y.value,!0),t.isNil(f)||this.drawLetterSpacing(e,w[A],C[A],o.value,E,P,h,p.value,v.value,y.value)}},r.drawLetterSpacing=function(e,t,r,n,i,o,a,l,c,s,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=i;"center"===n?d=i-r.width/2:"right"!==n&&"end"!==n||(d=i-r.width);for(var f=Array.from(t),p=e.measureText(t).width,v=0,y=0;f.length>y;++y){var g=f[y];u?this.strokeText(e,g,d,o,c):this.fillText(e,g,d,o,l,s),d+=p-(v=e.measureText(t.substring(y+1)).width)+a,p=v}e.textAlign=h}else u?this.strokeText(e,t,i,o,c):this.fillText(e,t,i,o,l,s)},r.fillText=function(e,r,n,i,o,a){var l,c=!t.isNil(o)&&1!==o;c&&(l=e.globalAlpha,e.globalAlpha=o*a),e.fillText(r,n,i),c&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,i,o){var a,l=!t.isNil(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o),e.strokeText(r,n,i),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=u([t.singleton({token:I})],e.TextRenderer);var _,Y,q=function(){function e(){}return e.prototype.render=function(e,r){var n=r.fill,i=r.opacity,o=r.fillOpacity,a=r.stroke,l=r.strokeOpacity,c=r.lineWidth,s=r.lineCap,u=r.lineJoin,h=r.shadowColor,d=r.filter,f=r.miterLimit,p=!t.isNil(n)&&!n.isNone,v=!t.isNil(a)&&!a.isNone,y=0===n.alpha;if(p&&(t.isNil(o)||1===o.value?e.fill():(e.globalAlpha=o.value,e.fill(),e.globalAlpha=i.value)),v&&c&&c.value>0){var g,m,R;!t.isNil(l)&&1!==l.value&&(e.globalAlpha=l.value),e.lineWidth=c.value,t.isNil(f)||(e.miterLimit=f),t.isNil(s)||(e.lineCap=s.value),t.isNil(u)||(e.lineJoin=u.value);var w=!t.isNil(h),x=!t.isNil(d);w&&(m=e.shadowColor,t.isNil(g=e.shadowBlur)||(e.shadowColor="transparent",e.shadowBlur=0)),x&&!t.isNil(R=e.filter)&&R.indexOf("drop-shadow")>-1&&(e.filter=R.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var b=p&&!y;b&&e.stroke(),w&&(e.shadowColor=m,e.shadowBlur=g),x&&(e.filter=R),b||e.stroke()}},e}();q=u([t.singleton()],q),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.RectRenderer=u([t.singleton({token:T})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.CircleRenderer=u([t.singleton({token:k})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.EllipseRenderer=u([t.singleton({token:O})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.LineRenderer=u([t.singleton({token:j})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PolylineRenderer=u([t.singleton({token:F})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PolygonRenderer=u([t.singleton({token:G})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PathRenderer=u([t.singleton({token:M})],e.PathRenderer);var U=(_=function(){function e(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.imagePool=void 0,this.gradientPool=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)},o=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(Y.tag,a(i().mark((function e(){var a,l,c,s;return i().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,o),l=(a=r.canvasConfig).width,c=a.height,s=r.contextService.getContext(),r.clearRect(s,0,0,l,c);case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Y.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,o)})),e.hooks.beginFrame.tap(Y.tag,(function(){var e=r.contextService.getContext(),t=r.canvasConfig,n=t.width,i=t.height;r.clearFullScreen=r.shouldClearFullScreen(),e&&(e.save(),r.clearFullScreen&&r.clearRect(e,0,0,n,i),r.applyTransform(e,r.camera.getOrthoMatrix()))})),e.hooks.endFrame.tap(Y.tag,(function(){var n=r.contextService.getContext();if(r.clearFullScreen);else{var i=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax(v(r,n,0),v(i,o,0)),a}))));if(r.removedRBushNodeAABBs=[],t.AABB.isEmpty(i))return void(r.renderQueue=[]);var o=r.convertAABB2Rect(i),a=o.x,l=o.y,c=o.width,s=o.height;r.clearRect(n,a,l,c,s),n.beginPath(),n.rect(a,l,c,s),n.clip(),r.searchDirtyObjects(i).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(Y.tag,(function(t){r.clearFullScreen?t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e):r.renderQueue.push(t)}))},r.clearRect=function(e,t,r,n,i){e.clearRect(t,r,n,i);var o=this.canvasConfig.background;o&&(e.fillStyle=o,e.fillRect(t,r,n,i))},r.renderDisplayObject=function(e,r){for(var n=this.contextService.getContext(),i=this.restoreStack[this.restoreStack.length-1];i&&e.parentNode!==i;)n.restore(),this.restoreStack.pop(),i=this.restoreStack[this.restoreStack.length-1];var o=e.nodeName;void 0===this.styleRendererFactoryCache[o]&&(this.styleRendererFactoryCache[o]=this.styleRendererFactory(o));var a=this.styleRendererFactoryCache[o];n.save();var l=e.getLocalPosition(),c=l[0],s=l[1],u=e.getLocalScale(),h=u[0],d=u[1],f=e.getLocalRotation(),p=t.getEuler(this.tmpVec3,f),v=p[0],y=p[2],g=Math.cos(v||y),m=Math.sin(v||y);n.transform(h*g,d*m,-h*m,d*g,c,s);var R=e.style.clipPath;if(R){n.save(),this.applyTransform(n,R.getLocalTransform()),void 0===this.pathGeneratorFactoryCache[R.nodeName]&&(this.pathGeneratorFactoryCache[R.nodeName]=this.pathGeneratorFactory(R.nodeName));var w=this.pathGeneratorFactoryCache[R.nodeName];w&&(this.useAnchor(n,R),n.beginPath(),w(n,R.parsedStyle),n.closePath()),n.restore(),n.clip()}n.save(),this.applyAttributesToContext(n,e,r),this.useAnchor(n,e),void 0===this.pathGeneratorFactoryCache[e.nodeName]&&(this.pathGeneratorFactoryCache[e.nodeName]=this.pathGeneratorFactory(e.nodeName));var x=this.pathGeneratorFactoryCache[e.nodeName];x&&(n.beginPath(),x(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),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]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},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],i=r[1],o=e.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[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),i=n[0],o=n[1],a=f(p(),r),l=a[0],c=a[1],s=function(e,t){var r=new d(3);f(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],a=t[0]*n,l=t[1]*i,c=t[2]*o,s=t[4]*n,u=t[5]*i,h=t[6]*o,p=t[8]*n,v=t[9]*i,y=t[10]*o,g=a+u+y,m=0;return g>0?(m=2*Math.sqrt(g+1),e[3]=.25*m,e[0]=(h-v)/m,e[1]=(p-c)/m,e[2]=(l-s)/m):a>u&&a>y?(m=2*Math.sqrt(1+a-u-y),e[3]=(h-v)/m,e[0]=.25*m,e[1]=(l+s)/m,e[2]=(p+c)/m):u>y?(m=2*Math.sqrt(1+u-a-y),e[3]=(p-c)/m,e[0]=(l+s)/m,e[1]=.25*m,e[2]=(h+v)/m):(m=2*Math.sqrt(1+y-a-u),e[3]=(l-s)/m,e[0]=(p+c)/m,e[1]=(h+v)/m,e[2]=.25*m),e}(R(),r),u=t.getEuler(p(),s),h=t.fromRotationTranslationScale(u[0]||u[2],i,o,l,c);e.transform(h[0],h[1],h[3],h[4],h[6],h[7])},r.getColor=function(e,r,n,i,o){var a;if(e instanceof t.CSSGradientValue){if(e.type===t.GradientPatternType.LinearGradient||e.type===t.GradientPatternType.RadialGradient){var c=n.getGeometryBounds();a=this.gradientPool.getOrCreateGradient(l({type:e.type},e.value,{width:c&&2*c.halfExtents[0]||0,height:c&&2*c.halfExtents[1]||0}),i)}else if(e.type===t.GradientPatternType.Pattern){var s=this.imagePool.getPatternSync(e.value);s?a=s:this.imagePool.createPattern(e.value,i).then((function(){n.renderable.dirty=!0,o.dirtify()}))}}else a=n.attributes[r];return a},r.applyAttributesToContext=function(e,r,n){var i=r.parsedStyle,o=i.stroke,a=i.fill,l=i.opacity,c=i.lineDash,s=i.lineDashOffset,u=i.filter,h=i.shadowColor,d=i.shadowBlur,f=i.shadowOffsetX,p=i.shadowOffsetY;c&&Array.isArray(c)&&e.setLineDash(c.map((function(e){return e.value}))),t.isNil(s)||(e.lineDashOffset=s.value),t.isNil(l)||(e.globalAlpha*=l.value),t.isNil(o)||o.isNone||(e.strokeStyle=this.getColor(o,"stroke",r,e,n)),t.isNil(a)||a.isNone||(e.fillStyle=this.getColor(a,"fill",r,e,n)),t.isNil(u)||(e.filter=r.style.filter),t.isNil(h)||(e.shadowColor=h.toString(),e.shadowBlur=d&&d.value||0,e.shadowOffsetX=f&&f.value||0,e.shadowOffsetY=p&&p.value||0)},r.useAnchor=function(e,t){var r=(t.parsedStyle||{}).anchor;if(r&&(0!==r[0].value||0!==r[1].value)){var n=t.getGeometryBounds();if(n){var i=n.halfExtents;e.translate(-r[0].value*i[0]*2,-r[1].value*i[1]*2)}}},r.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e},e}(),_.tag="CanvasRenderer",Y=_);u([t.inject(t.CanvasConfig),h("design:type",Object)],U.prototype,"canvasConfig",void 0),u([t.inject(t.DefaultCamera),h("design:type",t.Camera)],U.prototype,"camera",void 0),u([t.inject(t.ContextService),h("design:type",Object)],U.prototype,"contextService",void 0),u([t.inject(t.RenderingContext),h("design:type",Object)],U.prototype,"renderingContext",void 0),u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],U.prototype,"imagePool",void 0),u([t.inject(N),h("design:type",N)],U.prototype,"gradientPool",void 0),u([t.inject(r.PathGeneratorFactory),h("design:type",Function)],U.prototype,"pathGeneratorFactory",void 0),u([t.inject(B),h("design:type",Function)],U.prototype,"styleRendererFactory",void 0),u([t.inject(t.DisplayObjectPool),h("design:type",t.DisplayObjectPool)],U.prototype,"displayObjectPool",void 0),u([t.inject(t.RBushRoot),h("design:type",Function)],U.prototype,"rBush",void 0),U=Y=u([t.singleton({contrib:t.RenderingPluginContribution})],U);var X=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 i=((n={})[t.Shape.CIRCLE]=k,n[t.Shape.ELLIPSE]=O,n[t.Shape.RECT]=T,n[t.Shape.IMAGE]=D,n[t.Shape.TEXT]=I,n[t.Shape.LINE]=j,n[t.Shape.POLYLINE]=F,n[t.Shape.POLYGON]=G,n[t.Shape.PATH]=M,n);r({token:B,useFactory:function(e){return function(t){var r=i[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(N),r(U)})),Q=function(){function e(){this.name="canvas-renderer"}var t=e.prototype;return t.init=function(e){e.load(X,!0)},t.destroy=function(e){e.unload(X)},e}();e.CircleRendererContribution=k,e.EllipseRendererContribution=O,e.ImageRendererContribution=D,e.LineRendererContribution=j,e.PathRendererContribution=M,e.Plugin=Q,e.PolygonRendererContribution=G,e.PolylineRendererContribution=F,e.RectRendererContribution=T,e.StyleRendererFactory=B,e.TextRendererContribution=I,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new P(n||[]);return i._invoke=function(e,t,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 S()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var l=x(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 c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var h={};function d(){}function f(){}function p(){}var v={};c(v,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(A([])));g&&g!==t&&r.call(g,o)&&(v=g);var m=p.prototype=d.prototype=Object.create(v);function R(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(i,o,a,l){var c=u(e[i],e,o);if("throw"!==c.type){var s=c.arg,h=s.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){s.value=e,a(s)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function x(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,x(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 i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function b(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 C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=p,c(m,"constructor",p),c(p,"constructor",f),f.displayName=c(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,c(e,l,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},R(w.prototype),c(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new w(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(m),c(m,l,"Generator"),c(m,o,(function(){return this})),c(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=A,P.prototype={constructor:P,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(C),!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 i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(l){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.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),C(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 i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function o(e,t,r,n,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function l(e){o(a,n,i,l,c,"next",e)}function c(e){o(a,n,i,l,c,"throw",e)}l(void 0)}))}}function l(){return l=Object.assign||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 c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function u(e,t,r,n){var i,o=arguments.length,a=3>o?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--)(i=e[l])&&(a=(3>o?i(a):o>3?i(t,r,a):i(t,r))||a);return o>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],i=t[6],o=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,i),e[2]=Math.hypot(o,a,l),e}function p(){var e=new d(3);return d!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function v(e,t,r){var n=new d(3);return n[0]=e,n[1]=t,n[2]=r,n}function y(e,t,r){var n=t[0],i=t[1],o=t[2],a=r[0],l=r[1],c=r[2];return e[0]=i*c-o*l,e[1]=o*a-n*c,e[2]=n*l-i*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 w(e,t,r,n){var i,o,a,l,c,s=t[0],u=t[1],h=t[2],d=t[3],f=r[0],p=r[1],v=r[2],y=r[3];return 0>(o=s*f+u*p+h*v+d*y)&&(o=-o,f=-f,p=-p,v=-v,y=-y),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),l=Math.sin((1-n)*i)/a,c=Math.sin(n*i)/a):(l=1-n,c=n),e[0]=l*s+c*f,e[1]=l*u+c*p,e[2]=l*h+c*v,e[3]=l*d+c*y,e}var x,b,C,P,A,S,E,L=function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=r*r+n*n+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=o*a,e},B=(x=p(),b=v(1,0,0),C=v(0,1,0),P=R(),A=R(),S=new d(9),d!=Float32Array&&(S[1]=0,S[2]=0,S[3]=0,S[5]=0,S[6]=0,S[7]=0),S[0]=1,S[4]=1,S[8]=1,E=S,function(){function e(){this.gradientCache={}}var r=e.prototype;return r.getOrCreateGradient=function(e,r){var n=this.generateCacheKey(e),i=e.type,o=e.x0,a=e.y0,l=e.x1,c=e.y1,s=e.steps,u=e.width,h=e.height;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientPatternType.LinearGradient)d=r.createLinearGradient(o*u,a*h,l*u,c*h);else if(i===t.GradientPatternType.RadialGradient){var f=Math.sqrt(u*u+h*h)/2;d=r.createRadialGradient(o*u,a*h,0,l*u,c*h,e.r1*f)}return d&&(s.forEach((function(e){var t,r=e[1];null===(t=d)||void 0===t||t.addColorStop(Number(e[0]),r)})),this.gradientCache[n]=d),this.gradientCache[n]},r.generateCacheKey=function(e){return"gradient-"+e.type+"-"+e.x0+"-"+e.y0+"-"+e.x1+"-"+e.y1+"-"+(e.r1||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},e}());B=u([t.singleton()],B);var N=t.Syringe.defineToken("StyleRendererFactory"),k=t.Syringe.defineToken("CircleRenderer",{multiple:!1}),O=t.Syringe.defineToken("EllipseRenderer",{multiple:!1}),T=t.Syringe.defineToken("RectRenderer",{multiple:!1}),j=t.Syringe.defineToken("LineRenderer",{multiple:!1}),F=t.Syringe.defineToken("PolylineRenderer",{multiple:!1}),G=t.Syringe.defineToken("PolygonRenderer",{multiple:!1}),M=t.Syringe.defineToken("PathRenderer",{multiple:!1}),I=t.Syringe.defineToken("TextRenderer",{multiple:!1}),D=t.Syringe.defineToken("ImageRenderer",{multiple:!1});e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,i=r.img,o=r.width.value,a=r.height.value;if(t.isString(i)?n=this.imagePool.getImageSync(i):(o||(o=i.width),a||(a=i.height),n=i),n)try{e.drawImage(n,0,0,o,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:D})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var i=r.lineWidth,o=r.textAlign,a=r.textBaseline,l=r.lineJoin,c=r.miterLimit,s=void 0===c?0:c,u=r.letterSpacing,h=void 0===u?0:u,d=r.stroke,f=r.fill,p=r.fillOpacity,v=r.strokeOpacity,y=r.opacity,g=r.metrics,m=r.dx,R=r.dy,w=g.lines,x=g.height,b=g.lineHeight,C=g.lineMetrics;e.font=g.font,e.lineWidth=i.value,e.textAlign=o.value,e.textBaseline=a.value,e.lineJoin=l.value,e.miterLimit=s;var P=0;"middle"===a.value?P=-x/2-b/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?P=-x:"top"!==a.value&&"hanging"!==a.value||(P=-b);var A=0;m&&m.unit===t.UnitType.kPixels&&(A+=m.value),R&&R.unit===t.UnitType.kPixels&&(P+=R.value);for(var S=0;w.length>S;S++){var E=i.value/2+A;P+=b,!t.isNil(d)&&!d.isNone&&i&&i.value&&this.drawLetterSpacing(e,w[S],C[S],o.value,E,P,h,p.value,v.value,y.value,!0),t.isNil(f)||this.drawLetterSpacing(e,w[S],C[S],o.value,E,P,h,p.value,v.value,y.value)}},r.drawLetterSpacing=function(e,t,r,n,i,o,a,l,c,s,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=i;"center"===n?d=i-r.width/2:"right"!==n&&"end"!==n||(d=i-r.width);for(var f=Array.from(t),p=e.measureText(t).width,v=0,y=0;f.length>y;++y){var g=f[y];u?this.strokeText(e,g,d,o,c):this.fillText(e,g,d,o,l,s),d+=p-(v=e.measureText(t.substring(y+1)).width)+a,p=v}e.textAlign=h}else u?this.strokeText(e,t,i,o,c):this.fillText(e,t,i,o,l,s)},r.fillText=function(e,r,n,i,o,a){var l,c=!t.isNil(o)&&1!==o;c&&(l=e.globalAlpha,e.globalAlpha=o*a),e.fillText(r,n,i),c&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,i,o){var a,l=!t.isNil(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o),e.strokeText(r,n,i),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=u([t.singleton({token:I})],e.TextRenderer);var _,Y,q=function(){function e(){}return e.prototype.render=function(e,r){var n=r.fill,i=r.opacity,o=r.fillOpacity,a=r.stroke,l=r.strokeOpacity,c=r.lineWidth,s=r.lineCap,u=r.lineJoin,h=r.shadowColor,d=r.filter,f=r.miterLimit,p=!t.isNil(n)&&!n.isNone,v=!t.isNil(a)&&!a.isNone,y=0===n.alpha;if(p&&(t.isNil(o)||1===o.value?e.fill():(e.globalAlpha=o.value,e.fill(),e.globalAlpha=i.value)),v&&c&&c.value>0){var g,m,R;!t.isNil(l)&&1!==l.value&&(e.globalAlpha=l.value),e.lineWidth=c.value,t.isNil(f)||(e.miterLimit=f),t.isNil(s)||(e.lineCap=s.value),t.isNil(u)||(e.lineJoin=u.value);var w=!t.isNil(h),x=!t.isNil(d);w&&(m=e.shadowColor,t.isNil(g=e.shadowBlur)||(e.shadowColor="transparent",e.shadowBlur=0)),x&&!t.isNil(R=e.filter)&&R.indexOf("drop-shadow")>-1&&(e.filter=R.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var b=p&&!y;b&&e.stroke(),w&&(e.shadowColor=m,e.shadowBlur=g),x&&(e.filter=R),b||e.stroke()}},e}();q=u([t.singleton()],q),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.RectRenderer=u([t.singleton({token:T})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.CircleRenderer=u([t.singleton({token:k})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.EllipseRenderer=u([t.singleton({token:O})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.LineRenderer=u([t.singleton({token:j})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PolylineRenderer=u([t.singleton({token:F})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PolygonRenderer=u([t.singleton({token:G})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(q),e.PathRenderer=u([t.singleton({token:M})],e.PathRenderer);var U=(_=function(){function e(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.imagePool=void 0,this.gradientPool=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)},o=function(e){var t=e.target.rBushNode;t.aabb&&r.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(Y.tag,a(i().mark((function e(){var a,l,c,s;return i().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,o),l=(a=r.canvasConfig).width,c=a.height,s=r.contextService.getContext(),r.clearRect(s,0,0,l,c);case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Y.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,o)})),e.hooks.beginFrame.tap(Y.tag,(function(){var e=r.contextService.getContext(),t=r.canvasConfig,n=t.width,i=t.height;r.clearFullScreen=r.shouldClearFullScreen(),e&&(e.save(),r.clearFullScreen&&r.clearRect(e,0,0,n,i),r.applyTransform(e,r.camera.getOrthoMatrix()))})),e.hooks.endFrame.tap(Y.tag,(function(){var n=r.contextService.getContext();if(r.clearFullScreen);else{var i=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax(v(r,n,0),v(i,o,0)),a}))));if(r.removedRBushNodeAABBs=[],t.AABB.isEmpty(i))return void(r.renderQueue=[]);var o=r.convertAABB2Rect(i),a=o.x,l=o.y,c=o.width,s=o.height;r.clearRect(n,a,l,c,s),n.beginPath(),n.rect(a,l,c,s),n.clip(),r.searchDirtyObjects(i).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(Y.tag,(function(t){r.clearFullScreen?t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e):r.renderQueue.push(t)}))},r.clearRect=function(e,t,r,n,i){e.clearRect(t,r,n,i);var o=this.canvasConfig.background;o&&(e.fillStyle=o,e.fillRect(t,r,n,i))},r.renderDisplayObject=function(e,r){for(var n=this.contextService.getContext(),i=this.restoreStack[this.restoreStack.length-1];i&&e.parentNode!==i;)n.restore(),this.restoreStack.pop(),i=this.restoreStack[this.restoreStack.length-1];var o=e.nodeName;void 0===this.styleRendererFactoryCache[o]&&(this.styleRendererFactoryCache[o]=this.styleRendererFactory(o));var a=this.styleRendererFactoryCache[o];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 c=this.pathGeneratorFactoryCache[l.nodeName];c&&(this.useAnchor(n,l),n.beginPath(),c(n,l.parsedStyle),n.closePath()),n.restore(),n.clip()}n.save(),this.applyAttributesToContext(n,e,r),this.useAnchor(n,e),void 0===this.pathGeneratorFactoryCache[e.nodeName]&&(this.pathGeneratorFactoryCache[e.nodeName]=this.pathGeneratorFactory(e.nodeName));var s=this.pathGeneratorFactoryCache[e.nodeName];s&&(n.beginPath(),s(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),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]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},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],i=r[1],o=e.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[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),i=n[0],o=n[1],a=f(p(),r),l=a[0],c=a[1],s=function(e,t){var r=new d(3);f(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],a=t[0]*n,l=t[1]*i,c=t[2]*o,s=t[4]*n,u=t[5]*i,h=t[6]*o,p=t[8]*n,v=t[9]*i,y=t[10]*o,g=a+u+y,m=0;return g>0?(m=2*Math.sqrt(g+1),e[3]=.25*m,e[0]=(h-v)/m,e[1]=(p-c)/m,e[2]=(l-s)/m):a>u&&a>y?(m=2*Math.sqrt(1+a-u-y),e[3]=(h-v)/m,e[0]=.25*m,e[1]=(l+s)/m,e[2]=(p+c)/m):u>y?(m=2*Math.sqrt(1+u-a-y),e[3]=(p-c)/m,e[0]=(l+s)/m,e[1]=.25*m,e[2]=(h+v)/m):(m=2*Math.sqrt(1+y-a-u),e[3]=(l-s)/m,e[0]=(p+c)/m,e[1]=(h+v)/m,e[2]=.25*m),e}(R(),r),u=t.getEuler(p(),s),h=t.fromRotationTranslationScale(u[0]||u[2],i,o,l,c);e.transform(h[0],h[1],h[3],h[4],h[6],h[7])},r.getColor=function(e,r,n,i,o){var a;if(e instanceof t.CSSGradientValue){if(e.type===t.GradientPatternType.LinearGradient||e.type===t.GradientPatternType.RadialGradient){var c=n.getGeometryBounds();a=this.gradientPool.getOrCreateGradient(l({type:e.type},e.value,{width:c&&2*c.halfExtents[0]||0,height:c&&2*c.halfExtents[1]||0}),i)}else if(e.type===t.GradientPatternType.Pattern){var s=this.imagePool.getPatternSync(e.value);s?a=s:this.imagePool.createPattern(e.value,i).then((function(){n.renderable.dirty=!0,o.dirtify()}))}}else a=n.attributes[r];return a},r.applyAttributesToContext=function(e,r,n){var i=r.parsedStyle,o=i.stroke,a=i.fill,l=i.opacity,c=i.lineDash,s=i.lineDashOffset,u=i.filter,h=i.shadowColor,d=i.shadowBlur,f=i.shadowOffsetX,p=i.shadowOffsetY;c&&Array.isArray(c)&&e.setLineDash(c.map((function(e){return e.value}))),t.isNil(s)||(e.lineDashOffset=s.value),t.isNil(l)||(e.globalAlpha*=l.value),t.isNil(o)||o.isNone||(e.strokeStyle=this.getColor(o,"stroke",r,e,n)),t.isNil(a)||a.isNone||(e.fillStyle=this.getColor(a,"fill",r,e,n)),t.isNil(u)||(e.filter=r.style.filter),t.isNil(h)||(e.shadowColor=h.toString(),e.shadowBlur=d&&d.value||0,e.shadowOffsetX=f&&f.value||0,e.shadowOffsetY=p&&p.value||0)},r.useAnchor=function(e,t){var r=(t.parsedStyle||{}).anchor;if(r&&(0!==r[0].value||0!==r[1].value)){var n=t.getGeometryBounds();if(n){var i=n.halfExtents;e.translate(-r[0].value*i[0]*2,-r[1].value*i[1]*2)}}},r.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e},e}(),_.tag="CanvasRenderer",Y=_);u([t.inject(t.CanvasConfig),h("design:type",Object)],U.prototype,"canvasConfig",void 0),u([t.inject(t.DefaultCamera),h("design:type",t.Camera)],U.prototype,"camera",void 0),u([t.inject(t.ContextService),h("design:type",Object)],U.prototype,"contextService",void 0),u([t.inject(t.RenderingContext),h("design:type",Object)],U.prototype,"renderingContext",void 0),u([t.inject(n.ImagePool),h("design:type",n.ImagePool)],U.prototype,"imagePool",void 0),u([t.inject(B),h("design:type",B)],U.prototype,"gradientPool",void 0),u([t.inject(r.PathGeneratorFactory),h("design:type",Function)],U.prototype,"pathGeneratorFactory",void 0),u([t.inject(N),h("design:type",Function)],U.prototype,"styleRendererFactory",void 0),u([t.inject(t.DisplayObjectPool),h("design:type",t.DisplayObjectPool)],U.prototype,"displayObjectPool",void 0),u([t.inject(t.RBushRoot),h("design:type",t.RBush)],U.prototype,"rBush",void 0),U=Y=u([t.singleton({contrib:t.RenderingPluginContribution})],U);var X=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 i=((n={})[t.Shape.CIRCLE]=k,n[t.Shape.ELLIPSE]=O,n[t.Shape.RECT]=T,n[t.Shape.IMAGE]=D,n[t.Shape.TEXT]=I,n[t.Shape.LINE]=j,n[t.Shape.POLYLINE]=F,n[t.Shape.POLYGON]=G,n[t.Shape.PATH]=M,n);r({token:N,useFactory:function(e){return function(t){var r=i[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(B),r(U)})),Q=function(){function e(){this.name="canvas-renderer"}var t=e.prototype;return t.init=function(e){e.load(X,!0)},t.destroy=function(e){e.unload(X)},e}();e.CircleRendererContribution=k,e.EllipseRendererContribution=O,e.ImageRendererContribution=D,e.LineRendererContribution=j,e.PathRendererContribution=M,e.Plugin=Q,e.PolygonRendererContribution=G,e.PolylineRendererContribution=F,e.RectRendererContribution=T,e.StyleRendererFactory=N,e.TextRendererContribution=I,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.1.8-alpha.1", | ||
"version": "1.1.8", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "a57232cfdc74aaf0a9812feea28d5b7c8ca243a8" | ||
"gitHead": "837340c2bd89a9b40f94602485647b0ee798ff43" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
247673
5733