@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.7.43 to 1.7.44
@@ -490,3 +490,3 @@ import { ElementEvent, AABB, CustomEvent, CanvasEvent, Shape, isPattern, GradientType, AbstractRendererPlugin } from '@antv/g-lite'; | ||
var dpr = contextService.getDPR(); | ||
mat4.fromScaling(_this.dprMatrix, vec3.fromValues(dpr, dpr, 1)); | ||
mat4.fromScaling(_this.dprMatrix, [dpr, dpr, 1]); | ||
mat4.multiply(_this.vpMatrix, _this.dprMatrix, camera.getOrthoMatrix()); | ||
@@ -503,3 +503,6 @@ if (_this.clearFullScreen) { | ||
var aabb = new AABB(); | ||
aabb.setMinMax(vec3.fromValues(minX, minY, 0), vec3.fromValues(maxX, maxY, 0)); | ||
aabb.setMinMax( | ||
// vec3.fromValues(minX, minY, 0), | ||
// vec3.fromValues(maxX, maxY, 0), | ||
[minX, minY, 0], [maxX, maxY, 0]); | ||
return aabb; | ||
@@ -517,6 +520,6 @@ }))); | ||
height = dirtyRect.height; | ||
var tl = vec3.transformMat4(_this.vec3a, vec3.fromValues(x, y, 0), _this.vpMatrix); | ||
var tr = vec3.transformMat4(_this.vec3b, vec3.fromValues(x + width, y, 0), _this.vpMatrix); | ||
var bl = vec3.transformMat4(_this.vec3c, vec3.fromValues(x, y + height, 0), _this.vpMatrix); | ||
var br = vec3.transformMat4(_this.vec3d, vec3.fromValues(x + width, y + height, 0), _this.vpMatrix); | ||
var tl = vec3.transformMat4(_this.vec3a, [x, y, 0], _this.vpMatrix); | ||
var tr = vec3.transformMat4(_this.vec3b, [x + width, y, 0], _this.vpMatrix); | ||
var bl = vec3.transformMat4(_this.vec3c, [x, y + height, 0], _this.vpMatrix); | ||
var br = vec3.transformMat4(_this.vec3d, [x + width, y + height, 0], _this.vpMatrix); | ||
var minx = Math.min(tl[0], tr[0], br[0], bl[0]); | ||
@@ -523,0 +526,0 @@ var miny = Math.min(tl[1], tr[1], br[1], bl[1]); |
@@ -494,3 +494,3 @@ 'use strict'; | ||
var dpr = contextService.getDPR(); | ||
glMatrix.mat4.fromScaling(_this.dprMatrix, glMatrix.vec3.fromValues(dpr, dpr, 1)); | ||
glMatrix.mat4.fromScaling(_this.dprMatrix, [dpr, dpr, 1]); | ||
glMatrix.mat4.multiply(_this.vpMatrix, _this.dprMatrix, camera.getOrthoMatrix()); | ||
@@ -507,3 +507,6 @@ if (_this.clearFullScreen) { | ||
var aabb = new gLite.AABB(); | ||
aabb.setMinMax(glMatrix.vec3.fromValues(minX, minY, 0), glMatrix.vec3.fromValues(maxX, maxY, 0)); | ||
aabb.setMinMax( | ||
// vec3.fromValues(minX, minY, 0), | ||
// vec3.fromValues(maxX, maxY, 0), | ||
[minX, minY, 0], [maxX, maxY, 0]); | ||
return aabb; | ||
@@ -521,6 +524,6 @@ }))); | ||
height = dirtyRect.height; | ||
var tl = glMatrix.vec3.transformMat4(_this.vec3a, glMatrix.vec3.fromValues(x, y, 0), _this.vpMatrix); | ||
var tr = glMatrix.vec3.transformMat4(_this.vec3b, glMatrix.vec3.fromValues(x + width, y, 0), _this.vpMatrix); | ||
var bl = glMatrix.vec3.transformMat4(_this.vec3c, glMatrix.vec3.fromValues(x, y + height, 0), _this.vpMatrix); | ||
var br = glMatrix.vec3.transformMat4(_this.vec3d, glMatrix.vec3.fromValues(x + width, y + height, 0), _this.vpMatrix); | ||
var tl = glMatrix.vec3.transformMat4(_this.vec3a, [x, y, 0], _this.vpMatrix); | ||
var tr = glMatrix.vec3.transformMat4(_this.vec3b, [x + width, y, 0], _this.vpMatrix); | ||
var bl = glMatrix.vec3.transformMat4(_this.vec3c, [x, y + height, 0], _this.vpMatrix); | ||
var br = glMatrix.vec3.transformMat4(_this.vec3d, [x + width, y + height, 0], _this.vpMatrix); | ||
var minx = Math.min(tl[0], tr[0], br[0], bl[0]); | ||
@@ -527,0 +530,0 @@ var miny = Math.min(tl[1], tr[1], br[1], bl[1]); |
@@ -614,18 +614,2 @@ (function (global, factory) { | ||
/** | ||
* Creates a new vec3 initialized with the given values | ||
* | ||
* @param {Number} x X component | ||
* @param {Number} y Y component | ||
* @param {Number} z Z component | ||
* @returns {vec3} a new 3D vector | ||
*/ | ||
function fromValues(x, y, z) { | ||
var out = new ARRAY_TYPE(3); | ||
out[0] = x; | ||
out[1] = y; | ||
out[2] = z; | ||
return out; | ||
} | ||
/** | ||
* Transforms the vec3 with a mat4. | ||
@@ -840,3 +824,3 @@ * 4th vector component is implicitly '1' | ||
var dpr = contextService.getDPR(); | ||
fromScaling(_this.dprMatrix, fromValues(dpr, dpr, 1)); | ||
fromScaling(_this.dprMatrix, [dpr, dpr, 1]); | ||
multiply(_this.vpMatrix, _this.dprMatrix, camera.getOrthoMatrix()); | ||
@@ -853,3 +837,6 @@ if (_this.clearFullScreen) { | ||
var aabb = new gLite.AABB(); | ||
aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0)); | ||
aabb.setMinMax( | ||
// vec3.fromValues(minX, minY, 0), | ||
// vec3.fromValues(maxX, maxY, 0), | ||
[minX, minY, 0], [maxX, maxY, 0]); | ||
return aabb; | ||
@@ -867,6 +854,6 @@ }))); | ||
height = dirtyRect.height; | ||
var tl = transformMat4(_this.vec3a, fromValues(x, y, 0), _this.vpMatrix); | ||
var tr = transformMat4(_this.vec3b, fromValues(x + width, y, 0), _this.vpMatrix); | ||
var bl = transformMat4(_this.vec3c, fromValues(x, y + height, 0), _this.vpMatrix); | ||
var br = transformMat4(_this.vec3d, fromValues(x + width, y + height, 0), _this.vpMatrix); | ||
var tl = transformMat4(_this.vec3a, [x, y, 0], _this.vpMatrix); | ||
var tr = transformMat4(_this.vec3b, [x + width, y, 0], _this.vpMatrix); | ||
var bl = transformMat4(_this.vec3c, [x, y + height, 0], _this.vpMatrix); | ||
var br = transformMat4(_this.vec3d, [x + width, y + height, 0], _this.vpMatrix); | ||
var minx = Math.min(tl[0], tr[0], br[0], bl[0]); | ||
@@ -873,0 +860,0 @@ var miny = Math.min(tl[1], tr[1], br[1], bl[1]); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasRenderer={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),a=new M(n||[]);return i(o,"_invoke",{value:A(t,r,a)}),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f={};function d(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(B([])));m&&m!==e&&n.call(m,a)&&(y=m);var x=v.prototype=d.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(i,o,a,s){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return L()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=u(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function B(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=v,i(x,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=l(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},w(b.prototype),l(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new b(h(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(x),l(x,c,"Generator"),l(x,a,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=B,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===t||"continue"===t)&&e>=o.tryLoc&&o.finallyLoc>=e&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(i,o){var a=t.apply(e,r);function s(t){n(a,i,o,s,c,"next",t)}function c(t){n(a,i,o,s,c,"throw",t)}s(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,s(t,e)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}var c="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var t=new c(16);return c!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],x=r[0],w=r[1],b=r[2],A=r[3];return t[0]=x*n+w*s+b*u+A*v,t[1]=x*i+w*c+b*f+A*y,t[2]=x*o+w*l+b*d+A*g,t[3]=x*a+w*h+b*p+A*m,t[4]=(x=r[4])*n+(w=r[5])*s+(b=r[6])*u+(A=r[7])*v,t[5]=x*i+w*c+b*f+A*y,t[6]=x*o+w*l+b*d+A*g,t[7]=x*a+w*h+b*p+A*m,t[8]=(x=r[8])*n+(w=r[9])*s+(b=r[10])*u+(A=r[11])*v,t[9]=x*i+w*c+b*f+A*y,t[10]=x*o+w*l+b*d+A*g,t[11]=x*a+w*h+b*p+A*m,t[12]=(x=r[12])*n+(w=r[13])*s+(b=r[14])*u+(A=r[15])*v,t[13]=x*i+w*c+b*f+A*y,t[14]=x*o+w*l+b*d+A*g,t[15]=x*a+w*h+b*p+A*m,t}function f(t,e,r){var n,i,o,a,s,c,l,h,u,f,d,p,v=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],t[0]=n=e[0],t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=f,t[10]=d,t[11]=p,t[12]=n*v+s*y+u*g+e[12],t[13]=i*v+c*y+f*g+e[13],t[14]=o*v+l*y+d*g+e[14],t[15]=a*v+h*y+p*g+e[15]),t}function d(){var t=new c(3);return c!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function p(t,e,r){var n=new c(3);return n[0]=t,n[1]=e,n[2]=r,n}function v(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});y=d();var y,g=function(t){return null==t},m={}.toString,x=function(t){return e="String",m.call(t)==="[object "+e+"]";var e},w=function(){function t(t){this.canvasRendererPluginOptions=void 0,this.context=void 0,this.pathGeneratorFactory=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=l(),this.dprMatrix=l(),this.tmpMat4=l(),this.vec3a=d(),this.vec3b=d(),this.vec3c=d(),this.vec3d=d(),this.canvasRendererPluginOptions=t}var n=t.prototype;return n.apply=function(n,o){var a=this;this.context=n;var s=n.config,c=n.camera,l=n.renderingService,h=n.renderingContext,f=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=f;var d=n.contextService,y=h.root.ownerDocument.defaultView,g=function(t){var e=t.target.rBushNode;e.aabb&&a.removedRBushNodeAABBs.push(e.aabb)},m=function(t){var e=t.target.rBushNode;e.aabb&&a.removedRBushNodeAABBs.push(e.aabb)};l.hooks.init.tapPromise(t.tag,i(r().mark((function t(){var n,i,o,c;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:y.addEventListener(e.ElementEvent.UNMOUNTED,g),y.addEventListener(e.ElementEvent.CULLED,m),n=d.getDPR(),i=s.width,o=s.height,c=d.getContext(),a.clearRect(c,0,0,i*n,o*n,s.background);case 6:case"end":return t.stop()}}),t)})))),l.hooks.destroy.tap(t.tag,(function(){y.removeEventListener(e.ElementEvent.UNMOUNTED,g),y.removeEventListener(e.ElementEvent.CULLED,m)})),l.hooks.beginFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR(),r=s.width,n=s.height,i=a.canvasRendererPluginOptions,o=i.dirtyObjectNumThreshold,c=i.dirtyObjectRatioThreshold,h=l.getStats(),u=h.rendered,f=u/h.total;a.clearFullScreen=l.disableDirtyRectangleRendering()||u>o&&f>c,t&&(t.resetTransform(),a.clearFullScreen&&a.clearRect(t,0,0,r*e,n*e,s.background))}));var x=function t(e,r){e.isVisible()&&!e.isCulled()&&(a.renderDisplayObject(e,r,a.context,a.restoreStack,o),a.saveDirtyAABB(e)),(e.sortable.sorted||e.childNodes).forEach((function(e){t(e,r)}))};l.hooks.endFrame.tap(t.tag,(function(){var t,r,n=d.getContext(),i=d.getDPR();if(t=a.dprMatrix,r=p(i,i,1),t[0]=r[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=r[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,u(a.vpMatrix,a.dprMatrix,c.getOrthoMatrix()),a.clearFullScreen)x(h.root,n);else{var l=a.safeMergeAABB.apply(a,[a.mergeDirtyAABBs(a.renderQueue)].concat(a.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,i=t.maxX,o=t.maxY,a=new e.AABB;return a.setMinMax(p(r,n,0),p(i,o,0)),a}))));if(a.removedRBushNodeAABBs=[],e.AABB.isEmpty(l))return void(a.renderQueue=[]);var f=a.convertAABB2Rect(l),g=f.x,m=f.y,w=f.width,b=f.height,A=v(a.vec3a,p(g,m,0),a.vpMatrix),E=v(a.vec3b,p(g+w,m,0),a.vpMatrix),S=v(a.vec3c,p(g,m+b,0),a.vpMatrix),O=v(a.vec3d,p(g+w,m+b,0),a.vpMatrix),M=Math.min(A[0],E[0],O[0],S[0]),B=Math.min(A[1],E[1],O[1],S[1]),L=Math.max(A[0],E[0],O[0],S[0]),R=Math.max(A[1],E[1],O[1],S[1]),P=Math.floor(M),T=Math.floor(B),N=Math.ceil(L-M),C=Math.ceil(R-B);n.save(),a.clearRect(n,P,T,N,C,s.background),n.beginPath(),n.rect(P,T,N,C),n.clip(),n.setTransform(a.vpMatrix[0],a.vpMatrix[1],a.vpMatrix[4],a.vpMatrix[5],a.vpMatrix[12],a.vpMatrix[13]),s.renderer.getConfig().enableDirtyRectangleRenderingDebug&&y.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:P,y:T,width:N,height:C}})),a.searchDirtyObjects(o,l).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&a.renderDisplayObject(t,n,a.context,a.restoreStack,o)})),n.restore(),a.renderQueue.forEach((function(t){a.saveDirtyAABB(t)})),a.renderQueue=[]}a.restoreStack.forEach((function(){n.restore()})),a.restoreStack=[]})),l.hooks.render.tap(t.tag,(function(t){a.clearFullScreen||a.renderQueue.push(t)}))},n.clearRect=function(t,e,r,n,i,o){t.clearRect(e,r,n,i),o&&(t.fillStyle=o,t.fillRect(e,r,n,i))},n.renderDisplayObject=function(t,r,n,i,o){var a=t.nodeName,s=i[i.length-1];!s||t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.pop());var c=this.context.styleRendererFactory[a],l=this.pathGeneratorFactory[a],h=t.parsedStyle.clipPath;if(h){this.applyWorldTransform(r,h);var u=this.pathGeneratorFactory[h.nodeName];u&&(r.save(),i.push(t),r.beginPath(),u(r,h.parsedStyle),r.closePath(),r.clip())}c&&(this.applyWorldTransform(r,t),r.save(),this.applyAttributesToContext(r,t)),l&&(r.beginPath(),l(r,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&r.closePath()),c&&(c.render(r,t.parsedStyle,t,n,this,o),r.restore()),t.renderable.dirty=!1},n.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),i=Math.floor(e[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(t,e){var 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)}))},n.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,s=r.lineDashOffset;a&&t.setLineDash(a),g(s)||(t.lineDashOffset=s),g(o)||(t.globalAlpha*=o),g(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),g(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},n.applyWorldTransform=function(t,e,r){var n=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var c=e.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}r?(h(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,r,this.tmpMat4),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(h(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(e){t.add(e)})),t},t}();w.tag="CanvasRenderer";var b=function(){function t(t){this.imagePool=void 0,this.imagePool=t}var r=t.prototype;return r.render=function(t,r,n,i,o,a){var s=r.fill,c=r.fillRule,l=r.opacity,h=r.fillOpacity,u=r.stroke,f=r.strokeOpacity,d=r.lineWidth,p=r.lineCap,v=r.lineJoin,y=r.shadowType,m=r.shadowColor,x=r.shadowBlur,w=r.filter,b=r.miterLimit,E=!g(s)&&!s.isNone,S=!g(u)&&!u.isNone&&d>0,O=0===s.alpha,M=!(!w||!w.length),B=!g(m)&&x>0,L=n.nodeName,R="inner"===y,P=S&&B&&(L===e.Shape.PATH||L===e.Shape.LINE||L===e.Shape.POLYLINE||O||R);E&&(t.globalAlpha=l*h,P||A(n,t,B),this.fill(t,n,s,c,i,o,a),P||this.clearShadowAndFilter(t,M,B)),S&&(t.globalAlpha=l*f,t.lineWidth=d,g(b)||(t.miterLimit=b),g(p)||(t.lineCap=p),g(v)||(t.lineJoin=v),P&&(R&&(t.globalCompositeOperation="source-atop"),A(n,t,!0),R&&(this.stroke(t,n,u,i,o,a),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,M,!0))),this.stroke(t,n,u,i,o,a))},r.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!g(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.fill=function(t,r,n,i,o,a,s){var c=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=c.getColor(e,r,t),t.fill(i)})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o,a,s)),t.fill(i))},r.stroke=function(t,r,n,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=s.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,i,o,a)),t.stroke())},r.getPattern=function(t,e,r,n,i,o){var a,s;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,h=c.height;s=n.contextService.getDPR();var u=n.config.offscreenCanvas;(a=o.offscreenCanvas.getOrCreateCanvas(u)).width=l*s,a.height=h*s;var f=o.offscreenCanvas.getOrCreateContext(u),d=[];t.image.forEach((function(t){i.renderDisplayObject(t,f,n,d,o)})),d.forEach((function(){f.restore()}))}return this.imagePool.getOrCreatePatternSync(t,r,a,s,(function(){e.renderable.dirty=!0,n.renderingService.dirtify()}))},r.getColor=function(t,r,n){var i;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:t.type},t.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},t}();function A(t,e,r){var n=t.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,s=n.shadowOffsetX,c=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=""+o,e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var E=function(){function t(t){this.imagePool=void 0,this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.img,o=e.shadowColor,a=e.shadowBlur,s=e.width,c=e.height;if(x(i)?n=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),n=i),n){A(r,t,!g(o)&&a>0);try{t.drawImage(n,0,0,s,c)}catch(t){}}},t}(),S=function(){function t(){}var e=t.prototype;return e.render=function(t,e,r){var n=e.lineWidth,i=e.textAlign,o=e.textBaseline,a=e.lineJoin,s=e.miterLimit,c=e.letterSpacing,l=e.stroke,h=e.fill,u=e.fillOpacity,f=e.strokeOpacity,d=e.opacity,p=e.metrics,v=e.dx,y=e.dy,m=e.shadowColor,x=e.shadowBlur,w=p.lines,b=p.height,E=p.lineHeight,S=p.lineMetrics;t.font=p.font,t.lineWidth=n,t.textAlign="middle"===i?"center":i,t.textBaseline=o,t.lineJoin=a,g(s)||(t.miterLimit=s);var O=0;"middle"===o?O=-b/2-E/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?O=-b:"top"!==o&&"hanging"!==o||(O=-E);var M=v||0;O+=y||0,A(r,t,!g(m)&&x>0);for(var B=0;w.length>B;B++){var L=n/2+M;O+=E,g(l)||l.isNone||!n||this.drawLetterSpacing(t,w[B],S[B],i,L,O,c,u,f,d,!0),g(h)||this.drawLetterSpacing(t,w[B],S[B],i,L,O,c,u,f,d)}},e.drawLetterSpacing=function(t,e,r,n,i,o,a,s,c,l,h){if(void 0===h&&(h=!1),0!==a){var u=t.textAlign;t.textAlign="left";var f=i;"center"===n||"middle"===n?f=i-r.width/2:"right"!==n&&"end"!==n||(f=i-r.width);for(var d=Array.from(e),p=t.measureText(e).width,v=0,y=0;d.length>y;++y){var g=d[y];h?this.strokeText(t,g,f,o,c):this.fillText(t,g,f,o,s,l),f+=p-(v=t.measureText(e.substring(y+1)).width)+a,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,o,c):this.fillText(t,e,i,o,s,l)},e.fillText=function(t,e,r,n,i,o){var a,s=!g(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,r,n),s&&(t.globalAlpha=a)},e.strokeText=function(t,e,r,n,i){var o,a=!g(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),a&&(t.globalAlpha=o)},t}(),O=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),M=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),B=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),L=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),R=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),P=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),T=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(b),N=function(t){function r(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=e,r}a(r,t);var n=r.prototype;return n.init=function(){var t,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new b(n),a=((t={})[e.Shape.CIRCLE]=i,t[e.Shape.ELLIPSE]=i,t[e.Shape.RECT]=i,t[e.Shape.IMAGE]=new E(n),t[e.Shape.TEXT]=new S,t[e.Shape.LINE]=i,t[e.Shape.POLYLINE]=i,t[e.Shape.POLYGON]=i,t[e.Shape.PATH]=i,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new w(r))},n.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=M,t.EllipseRenderer=B,t.ImageRenderer=E,t.LineRenderer=L,t.PathRenderer=T,t.Plugin=N,t.PolygonRenderer=P,t.PolylineRenderer=R,t.RectRenderer=O,t.TextRenderer=S,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasRenderer={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),a=new M(n||[]);return i(o,"_invoke",{value:A(t,r,a)}),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f={};function d(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(B([])));m&&m!==e&&n.call(m,a)&&(y=m);var x=v.prototype=d.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(i,o,a,s){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return L()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=u(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function B(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=v,i(x,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=l(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},w(b.prototype),l(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new b(h(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(x),l(x,c,"Generator"),l(x,a,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=B,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===t||"continue"===t)&&e>=o.tryLoc&&o.finallyLoc>=e&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(i,o){var a=t.apply(e,r);function s(t){n(a,i,o,s,c,"next",t)}function c(t){n(a,i,o,s,c,"throw",t)}s(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,s(t,e)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}var c="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var t=new c(16);return c!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],x=r[0],w=r[1],b=r[2],A=r[3];return t[0]=x*n+w*s+b*u+A*v,t[1]=x*i+w*c+b*f+A*y,t[2]=x*o+w*l+b*d+A*g,t[3]=x*a+w*h+b*p+A*m,t[4]=(x=r[4])*n+(w=r[5])*s+(b=r[6])*u+(A=r[7])*v,t[5]=x*i+w*c+b*f+A*y,t[6]=x*o+w*l+b*d+A*g,t[7]=x*a+w*h+b*p+A*m,t[8]=(x=r[8])*n+(w=r[9])*s+(b=r[10])*u+(A=r[11])*v,t[9]=x*i+w*c+b*f+A*y,t[10]=x*o+w*l+b*d+A*g,t[11]=x*a+w*h+b*p+A*m,t[12]=(x=r[12])*n+(w=r[13])*s+(b=r[14])*u+(A=r[15])*v,t[13]=x*i+w*c+b*f+A*y,t[14]=x*o+w*l+b*d+A*g,t[15]=x*a+w*h+b*p+A*m,t}function f(t,e,r){var n,i,o,a,s,c,l,h,u,f,d,p,v=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],p=e[11],t[0]=n=e[0],t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=f,t[10]=d,t[11]=p,t[12]=n*v+s*y+u*g+e[12],t[13]=i*v+c*y+f*g+e[13],t[14]=o*v+l*y+d*g+e[14],t[15]=a*v+h*y+p*g+e[15]),t}function d(){var t=new c(3);return c!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function p(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});v=d();var v,y=function(t){return null==t},g={}.toString,m=function(t){return e="String",g.call(t)==="[object "+e+"]";var e},x=function(){function t(t){this.canvasRendererPluginOptions=void 0,this.context=void 0,this.pathGeneratorFactory=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=l(),this.dprMatrix=l(),this.tmpMat4=l(),this.vec3a=d(),this.vec3b=d(),this.vec3c=d(),this.vec3d=d(),this.canvasRendererPluginOptions=t}var n=t.prototype;return n.apply=function(n,o){var a=this;this.context=n;var s=n.config,c=n.camera,l=n.renderingService,h=n.renderingContext,f=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=f;var d=n.contextService,v=h.root.ownerDocument.defaultView,y=function(t){var e=t.target.rBushNode;e.aabb&&a.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&a.removedRBushNodeAABBs.push(e.aabb)};l.hooks.init.tapPromise(t.tag,i(r().mark((function t(){var n,i,o,c;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:v.addEventListener(e.ElementEvent.UNMOUNTED,y),v.addEventListener(e.ElementEvent.CULLED,g),n=d.getDPR(),i=s.width,o=s.height,c=d.getContext(),a.clearRect(c,0,0,i*n,o*n,s.background);case 6:case"end":return t.stop()}}),t)})))),l.hooks.destroy.tap(t.tag,(function(){v.removeEventListener(e.ElementEvent.UNMOUNTED,y),v.removeEventListener(e.ElementEvent.CULLED,g)})),l.hooks.beginFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR(),r=s.width,n=s.height,i=a.canvasRendererPluginOptions,o=i.dirtyObjectNumThreshold,c=i.dirtyObjectRatioThreshold,h=l.getStats(),u=h.rendered,f=u/h.total;a.clearFullScreen=l.disableDirtyRectangleRendering()||u>o&&f>c,t&&(t.resetTransform(),a.clearFullScreen&&a.clearRect(t,0,0,r*e,n*e,s.background))}));var m=function t(e,r){e.isVisible()&&!e.isCulled()&&(a.renderDisplayObject(e,r,a.context,a.restoreStack,o),a.saveDirtyAABB(e)),(e.sortable.sorted||e.childNodes).forEach((function(e){t(e,r)}))};l.hooks.endFrame.tap(t.tag,(function(){var t,r,n=d.getContext(),i=d.getDPR();if((t=a.dprMatrix)[0]=(r=[i,i,1])[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=r[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,u(a.vpMatrix,a.dprMatrix,c.getOrthoMatrix()),a.clearFullScreen)m(h.root,n);else{var l=a.safeMergeAABB.apply(a,[a.mergeDirtyAABBs(a.renderQueue)].concat(a.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,i=t.maxX,o=t.maxY,a=new e.AABB;return a.setMinMax([r,n,0],[i,o,0]),a}))));if(a.removedRBushNodeAABBs=[],e.AABB.isEmpty(l))return void(a.renderQueue=[]);var f=a.convertAABB2Rect(l),y=f.x,g=f.y,x=f.width,w=f.height,b=p(a.vec3a,[y,g,0],a.vpMatrix),A=p(a.vec3b,[y+x,g,0],a.vpMatrix),E=p(a.vec3c,[y,g+w,0],a.vpMatrix),S=p(a.vec3d,[y+x,g+w,0],a.vpMatrix),O=Math.min(b[0],A[0],S[0],E[0]),M=Math.min(b[1],A[1],S[1],E[1]),B=Math.max(b[0],A[0],S[0],E[0]),L=Math.max(b[1],A[1],S[1],E[1]),R=Math.floor(O),P=Math.floor(M),T=Math.ceil(B-O),N=Math.ceil(L-M);n.save(),a.clearRect(n,R,P,T,N,s.background),n.beginPath(),n.rect(R,P,T,N),n.clip(),n.setTransform(a.vpMatrix[0],a.vpMatrix[1],a.vpMatrix[4],a.vpMatrix[5],a.vpMatrix[12],a.vpMatrix[13]),s.renderer.getConfig().enableDirtyRectangleRenderingDebug&&v.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:R,y:P,width:T,height:N}})),a.searchDirtyObjects(o,l).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&a.renderDisplayObject(t,n,a.context,a.restoreStack,o)})),n.restore(),a.renderQueue.forEach((function(t){a.saveDirtyAABB(t)})),a.renderQueue=[]}a.restoreStack.forEach((function(){n.restore()})),a.restoreStack=[]})),l.hooks.render.tap(t.tag,(function(t){a.clearFullScreen||a.renderQueue.push(t)}))},n.clearRect=function(t,e,r,n,i,o){t.clearRect(e,r,n,i),o&&(t.fillStyle=o,t.fillRect(e,r,n,i))},n.renderDisplayObject=function(t,r,n,i,o){var a=t.nodeName,s=i[i.length-1];!s||t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.pop());var c=this.context.styleRendererFactory[a],l=this.pathGeneratorFactory[a],h=t.parsedStyle.clipPath;if(h){this.applyWorldTransform(r,h);var u=this.pathGeneratorFactory[h.nodeName];u&&(r.save(),i.push(t),r.beginPath(),u(r,h.parsedStyle),r.closePath(),r.clip())}c&&(this.applyWorldTransform(r,t),r.save(),this.applyAttributesToContext(r,t)),l&&(r.beginPath(),l(r,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&r.closePath()),c&&(c.render(r,t.parsedStyle,t,n,this,o),r.restore()),t.renderable.dirty=!1},n.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),i=Math.floor(e[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(t,e){var 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)}))},n.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,s=r.lineDashOffset;a&&t.setLineDash(a),y(s)||(t.lineDashOffset=s),y(o)||(t.globalAlpha*=o),y(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),y(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},n.applyWorldTransform=function(t,e,r){var n=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var c=e.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}r?(h(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,r,this.tmpMat4),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(h(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,f(this.tmpMat4,this.tmpMat4,this.vec3a),u(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(e){t.add(e)})),t},t}();x.tag="CanvasRenderer";var w=function(){function t(t){this.imagePool=void 0,this.imagePool=t}var r=t.prototype;return r.render=function(t,r,n,i,o,a){var s=r.fill,c=r.fillRule,l=r.opacity,h=r.fillOpacity,u=r.stroke,f=r.strokeOpacity,d=r.lineWidth,p=r.lineCap,v=r.lineJoin,g=r.shadowType,m=r.shadowColor,x=r.shadowBlur,w=r.filter,A=r.miterLimit,E=!y(s)&&!s.isNone,S=!y(u)&&!u.isNone&&d>0,O=0===s.alpha,M=!(!w||!w.length),B=!y(m)&&x>0,L=n.nodeName,R="inner"===g,P=S&&B&&(L===e.Shape.PATH||L===e.Shape.LINE||L===e.Shape.POLYLINE||O||R);E&&(t.globalAlpha=l*h,P||b(n,t,B),this.fill(t,n,s,c,i,o,a),P||this.clearShadowAndFilter(t,M,B)),S&&(t.globalAlpha=l*f,t.lineWidth=d,y(A)||(t.miterLimit=A),y(p)||(t.lineCap=p),y(v)||(t.lineJoin=v),P&&(R&&(t.globalCompositeOperation="source-atop"),b(n,t,!0),R&&(this.stroke(t,n,u,i,o,a),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,M,!0))),this.stroke(t,n,u,i,o,a))},r.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!y(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.fill=function(t,r,n,i,o,a,s){var c=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=c.getColor(e,r,t),t.fill(i)})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o,a,s)),t.fill(i))},r.stroke=function(t,r,n,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=s.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,i,o,a)),t.stroke())},r.getPattern=function(t,e,r,n,i,o){var a,s;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,h=c.height;s=n.contextService.getDPR();var u=n.config.offscreenCanvas;(a=o.offscreenCanvas.getOrCreateCanvas(u)).width=l*s,a.height=h*s;var f=o.offscreenCanvas.getOrCreateContext(u),d=[];t.image.forEach((function(t){i.renderDisplayObject(t,f,n,d,o)})),d.forEach((function(){f.restore()}))}return this.imagePool.getOrCreatePatternSync(t,r,a,s,(function(){e.renderable.dirty=!0,n.renderingService.dirtify()}))},r.getColor=function(t,r,n){var i;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:t.type},t.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},t}();function b(t,e,r){var n=t.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,s=n.shadowOffsetX,c=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=""+o,e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var A=function(){function t(t){this.imagePool=void 0,this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.img,o=e.shadowColor,a=e.shadowBlur,s=e.width,c=e.height;if(m(i)?n=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),n=i),n){b(r,t,!y(o)&&a>0);try{t.drawImage(n,0,0,s,c)}catch(t){}}},t}(),E=function(){function t(){}var e=t.prototype;return e.render=function(t,e,r){var n=e.lineWidth,i=e.textAlign,o=e.textBaseline,a=e.lineJoin,s=e.miterLimit,c=e.letterSpacing,l=e.stroke,h=e.fill,u=e.fillOpacity,f=e.strokeOpacity,d=e.opacity,p=e.metrics,v=e.dx,g=e.dy,m=e.shadowColor,x=e.shadowBlur,w=p.lines,A=p.height,E=p.lineHeight,S=p.lineMetrics;t.font=p.font,t.lineWidth=n,t.textAlign="middle"===i?"center":i,t.textBaseline=o,t.lineJoin=a,y(s)||(t.miterLimit=s);var O=0;"middle"===o?O=-A/2-E/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?O=-A:"top"!==o&&"hanging"!==o||(O=-E);var M=v||0;O+=g||0,b(r,t,!y(m)&&x>0);for(var B=0;w.length>B;B++){var L=n/2+M;O+=E,y(l)||l.isNone||!n||this.drawLetterSpacing(t,w[B],S[B],i,L,O,c,u,f,d,!0),y(h)||this.drawLetterSpacing(t,w[B],S[B],i,L,O,c,u,f,d)}},e.drawLetterSpacing=function(t,e,r,n,i,o,a,s,c,l,h){if(void 0===h&&(h=!1),0!==a){var u=t.textAlign;t.textAlign="left";var f=i;"center"===n||"middle"===n?f=i-r.width/2:"right"!==n&&"end"!==n||(f=i-r.width);for(var d=Array.from(e),p=t.measureText(e).width,v=0,y=0;d.length>y;++y){var g=d[y];h?this.strokeText(t,g,f,o,c):this.fillText(t,g,f,o,s,l),f+=p-(v=t.measureText(e.substring(y+1)).width)+a,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,o,c):this.fillText(t,e,i,o,s,l)},e.fillText=function(t,e,r,n,i,o){var a,s=!y(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,r,n),s&&(t.globalAlpha=a)},e.strokeText=function(t,e,r,n,i){var o,a=!y(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),a&&(t.globalAlpha=o)},t}(),S=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),O=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),M=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),B=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),L=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),R=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),P=function(t){function e(){return t.apply(this,arguments)||this}return a(e,t),e}(w),T=function(t){function r(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=e,r}a(r,t);var n=r.prototype;return n.init=function(){var t,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new w(n),a=((t={})[e.Shape.CIRCLE]=i,t[e.Shape.ELLIPSE]=i,t[e.Shape.RECT]=i,t[e.Shape.IMAGE]=new A(n),t[e.Shape.TEXT]=new E,t[e.Shape.LINE]=i,t[e.Shape.POLYLINE]=i,t[e.Shape.POLYGON]=i,t[e.Shape.PATH]=i,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new x(r))},n.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=O,t.EllipseRenderer=M,t.ImageRenderer=A,t.LineRenderer=B,t.PathRenderer=P,t.Plugin=T,t.PolygonRenderer=R,t.PolylineRenderer=L,t.RectRenderer=S,t.TextRenderer=E,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.7.43", | ||
"version": "1.7.44", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -33,5 +33,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@antv/g-math": "^1.7.38", | ||
"@antv/g-plugin-canvas-path-generator": "^1.1.40", | ||
"@antv/g-plugin-image-loader": "^1.1.41", | ||
"@antv/g-math": "^1.7.39", | ||
"@antv/g-plugin-canvas-path-generator": "^1.1.41", | ||
"@antv/g-plugin-image-loader": "^1.1.42", | ||
"@antv/util": "^3.3.1", | ||
@@ -50,3 +50,3 @@ "gl-matrix": "^3.1.0", | ||
}, | ||
"gitHead": "5a9d7d6c7d8fe5cdb2a8f40521c30752251b8e94" | ||
"gitHead": "9cf36b5ea1951c9d6ee5da4e54d458f83900cb2f" | ||
} |
Sorry, the diff of this file is not supported yet
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
195867
4169