@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.10.0-next.0 to 1.10.0-next.1
@@ -354,22 +354,5 @@ import { __spreadArray, __read, __assign, __extends } from 'tslib'; | ||
CanvasRendererPlugin.prototype.applyWorldTransform = function (context, object, matrix) { | ||
var tx = 0; | ||
var ty = 0; | ||
var anchor = (object.parsedStyle || {}).anchor; | ||
var anchorX = (anchor && anchor[0]) || 0; | ||
var anchorY = (anchor && anchor[1]) || 0; | ||
if (anchorX !== 0 || anchorY !== 0) { | ||
// const bounds = object.getGeometryBounds(); | ||
var bounds = object.geometry.contentBounds; | ||
var width = (bounds && bounds.halfExtents[0] * 2) || 0; | ||
var height = (bounds && bounds.halfExtents[1] * 2) || 0; | ||
tx = -(anchorX * width); | ||
ty = -(anchorY * height); | ||
} | ||
// apply clip shape's RTS | ||
if (matrix) { | ||
mat4.copy(this.tmpMat4, object.getLocalTransform()); | ||
this.vec3a[0] = tx; | ||
this.vec3a[1] = ty; | ||
this.vec3a[2] = 0; | ||
mat4.translate(this.tmpMat4, this.tmpMat4, this.vec3a); | ||
mat4.multiply(this.tmpMat4, matrix, this.tmpMat4); | ||
@@ -381,6 +364,2 @@ mat4.multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4); | ||
mat4.copy(this.tmpMat4, object.getWorldTransform()); | ||
this.vec3a[0] = tx; | ||
this.vec3a[1] = ty; | ||
this.vec3a[2] = 0; | ||
mat4.translate(this.tmpMat4, this.tmpMat4, this.vec3a); | ||
mat4.multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4); | ||
@@ -569,3 +548,3 @@ } | ||
ImageRenderer.prototype.render = function (context, parsedStyle, object) { | ||
var x = parsedStyle.x, y = parsedStyle.y, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var image; | ||
@@ -572,0 +551,0 @@ var iw = width; |
@@ -356,22 +356,5 @@ 'use strict'; | ||
CanvasRendererPlugin.prototype.applyWorldTransform = function (context, object, matrix) { | ||
var tx = 0; | ||
var ty = 0; | ||
var anchor = (object.parsedStyle || {}).anchor; | ||
var anchorX = (anchor && anchor[0]) || 0; | ||
var anchorY = (anchor && anchor[1]) || 0; | ||
if (anchorX !== 0 || anchorY !== 0) { | ||
// const bounds = object.getGeometryBounds(); | ||
var bounds = object.geometry.contentBounds; | ||
var width = (bounds && bounds.halfExtents[0] * 2) || 0; | ||
var height = (bounds && bounds.halfExtents[1] * 2) || 0; | ||
tx = -(anchorX * width); | ||
ty = -(anchorY * height); | ||
} | ||
// apply clip shape's RTS | ||
if (matrix) { | ||
glMatrix.mat4.copy(this.tmpMat4, object.getLocalTransform()); | ||
this.vec3a[0] = tx; | ||
this.vec3a[1] = ty; | ||
this.vec3a[2] = 0; | ||
glMatrix.mat4.translate(this.tmpMat4, this.tmpMat4, this.vec3a); | ||
glMatrix.mat4.multiply(this.tmpMat4, matrix, this.tmpMat4); | ||
@@ -383,6 +366,2 @@ glMatrix.mat4.multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4); | ||
glMatrix.mat4.copy(this.tmpMat4, object.getWorldTransform()); | ||
this.vec3a[0] = tx; | ||
this.vec3a[1] = ty; | ||
this.vec3a[2] = 0; | ||
glMatrix.mat4.translate(this.tmpMat4, this.tmpMat4, this.vec3a); | ||
glMatrix.mat4.multiply(this.tmpMat4, this.vpMatrix, this.tmpMat4); | ||
@@ -571,3 +550,3 @@ } | ||
ImageRenderer.prototype.render = function (context, parsedStyle, object) { | ||
var x = parsedStyle.x, y = parsedStyle.y, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var image; | ||
@@ -574,0 +553,0 @@ var iw = width; |
@@ -1,2 +0,2 @@ | ||
!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";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;n>r;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,a=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var o="undefined"!=typeof Float32Array?Float32Array:Array;function s(){var t=new o(16);return o!=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 l(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 h(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],c=e[7],d=e[8],p=e[9],u=e[10],f=e[11],y=e[12],v=e[13],g=e[14],m=e[15],A=r[0],x=r[1],b=r[2],S=r[3];return t[0]=A*n+x*s+b*d+S*y,t[1]=A*i+x*l+b*p+S*v,t[2]=A*a+x*h+b*u+S*g,t[3]=A*o+x*c+b*f+S*m,t[4]=(A=r[4])*n+(x=r[5])*s+(b=r[6])*d+(S=r[7])*y,t[5]=A*i+x*l+b*p+S*v,t[6]=A*a+x*h+b*u+S*g,t[7]=A*o+x*c+b*f+S*m,t[8]=(A=r[8])*n+(x=r[9])*s+(b=r[10])*d+(S=r[11])*y,t[9]=A*i+x*l+b*p+S*v,t[10]=A*a+x*h+b*u+S*g,t[11]=A*o+x*c+b*f+S*m,t[12]=(A=r[12])*n+(x=r[13])*s+(b=r[14])*d+(S=r[15])*y,t[13]=A*i+x*l+b*p+S*v,t[14]=A*a+x*h+b*u+S*g,t[15]=A*o+x*c+b*f+S*m,t}function c(t,e,r){var n,i,a,o,s,l,h,c,d,p,u,f,y=r[0],v=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*v+e[8]*g+e[12],t[13]=e[1]*y+e[5]*v+e[9]*g+e[13],t[14]=e[2]*y+e[6]*v+e[10]*g+e[14],t[15]=e[3]*y+e[7]*v+e[11]*g+e[15]):(i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],c=e[7],d=e[8],p=e[9],u=e[10],f=e[11],t[0]=n=e[0],t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=h,t[7]=c,t[8]=d,t[9]=p,t[10]=u,t[11]=f,t[12]=n*y+s*v+d*g+e[12],t[13]=i*y+l*v+p*g+e[13],t[14]=a*y+h*v+u*g+e[14],t[15]=o*y+c*v+f*g+e[15]),t}function d(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function p(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/(o=o||1),t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),d();var u=function(t){return null==t},f={}.toString,y=function(t,e){return f.call(t)==="[object "+e+"]"},v=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=s(),this.dprMatrix=s(),this.tmpMat4=s(),this.vec3a=d(),this.vec3b=d(),this.vec3c=d(),this.vec3d=d()}return t.prototype.apply=function(r,n){var i=this;this.context=r;var o=r.config,s=r.camera,l=r.renderingService,c=r.renderingContext,d=r.pathGeneratorFactory;this.rBush=r.rBushRoot,this.pathGeneratorFactory=d;var u=r.contextService,f=c.root.ownerDocument.defaultView,y=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)},v=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)};l.hooks.init.tap(t.tag,(function(){f.addEventListener(e.ElementEvent.UNMOUNTED,y),f.addEventListener(e.ElementEvent.CULLED,v);var t=u.getDPR(),r=o.width,n=o.height,a=u.getContext();i.clearRect(a,0,0,r*t,n*t,o.background)})),l.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(e.ElementEvent.UNMOUNTED,y),f.removeEventListener(e.ElementEvent.CULLED,v),i.renderQueue=[],i.removedRBushNodeAABBs=[],i.restoreStack=[]})),l.hooks.beginFrame.tap(t.tag,(function(){var t=u.getContext(),e=u.getDPR(),r=o.width,n=o.height,a=i.canvasRendererPluginOptions,s=a.dirtyObjectNumThreshold,h=a.dirtyObjectRatioThreshold,c=l.getStats(),d=c.rendered,p=d/c.total;i.clearFullScreen=l.disableDirtyRectangleRendering()||d>s&&p>h,t&&(t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,r*e,n*e,o.background))}));var g=function(t,e){t.isVisible()&&!t.isCulled()&&(i.renderDisplayObject(t,e,i.context,i.restoreStack,n),i.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){g(t,e)}))};l.hooks.endFrame.tap(t.tag,(function(){var t,r,l=u.getContext(),d=u.getDPR();if((t=i.dprMatrix)[0]=(r=[d,d,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,h(i.vpMatrix,i.dprMatrix,s.getOrthoMatrix()),i.clearFullScreen)g(c.root,l);else{var y=i.safeMergeAABB.apply(i,function(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;a>i;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([i.mergeDirtyAABBs(i.renderQueue)],a(i.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,i=t.maxX,a=t.maxY,o=new e.AABB;return o.setMinMax([r,n,0],[i,a,0]),o}))),!1));if(i.removedRBushNodeAABBs=[],e.AABB.isEmpty(y))return void(i.renderQueue=[]);var v=i.convertAABB2Rect(y),m=v.x,A=v.y,x=v.width,b=v.height,S=p(i.vec3a,[m,A,0],i.vpMatrix),B=p(i.vec3b,[m+x,A,0],i.vpMatrix),M=p(i.vec3c,[m,A+b,0],i.vpMatrix),w=p(i.vec3d,[m+x,A+b,0],i.vpMatrix),R=Math.min(S[0],B[0],w[0],M[0]),E=Math.min(S[1],B[1],w[1],M[1]),O=Math.max(S[0],B[0],w[0],M[0]),C=Math.max(S[1],B[1],w[1],M[1]),T=Math.floor(R),P=Math.floor(E),N=Math.ceil(O-R),L=Math.ceil(C-E);l.save(),i.clearRect(l,T,P,N,L,o.background),l.beginPath(),l.rect(T,P,N,L),l.clip(),l.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:P,width:N,height:L}})),i.searchDirtyObjects(y).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&i.renderDisplayObject(t,l,i.context,i.restoreStack,n)})),l.restore(),i.renderQueue.forEach((function(t){i.saveDirtyAABB(t)})),i.renderQueue=[]}i.restoreStack.forEach((function(){l.restore()})),i.restoreStack=[]})),l.hooks.render.tap(t.tag,(function(t){i.clearFullScreen||i.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,r,n,i,a){t.clearRect(e,r,n,i),a&&(t.fillStyle=a,t.fillRect(e,r,n,i))},t.prototype.renderDisplayObject=function(t,r,n,i,a){var o=t.nodeName,s=i[i.length-1];!s||t.compareDocumentPosition(s)&e.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.pop());var l=this.context.styleRendererFactory[o],h=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(r,c);var d=this.pathGeneratorFactory[c.nodeName];d&&(r.save(),i.push(t),r.beginPath(),d(r,c.parsedStyle),r.closePath(),r.clip())}l&&(this.applyWorldTransform(r,t),r.save(),this.applyAttributesToContext(r,t)),h&&(r.beginPath(),h(r,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&r.closePath()),l&&(l.render(r,t.parsedStyle,t,n,this,a),r.restore()),t.renderable.dirty=!1},t.prototype.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}},t.prototype.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},t.prototype.searchDirtyObjects=function(t){var e=a(t.getMin(),2),r=e[0],n=e[1],i=a(t.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[1]}).map((function(t){return t.displayObject}))},t.prototype.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)},t.prototype.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,a=r.opacity,o=r.lineDash,s=r.lineDashOffset;o&&t.setLineDash(o),u(s)||(t.lineDashOffset=s),u(a)||(t.globalAlpha*=a),u(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),u(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,r){var n=0,i=0,a=(e.parsedStyle||{}).anchor,o=a&&a[0]||0,s=a&&a[1]||0;if(0!==o||0!==s){var d=e.geometry.contentBounds;n=-o*(d&&2*d.halfExtents[0]||0),i=-s*(d&&2*d.halfExtents[1]||0)}r?(l(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,c(this.tmpMat4,this.tmpMat4,this.vec3a),h(this.tmpMat4,r,this.tmpMat4),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(l(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=n,this.vec3a[1]=i,this.vec3a[2]=0,c(this.tmpMat4,this.tmpMat4,this.vec3a),h(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])},t.prototype.safeMergeAABB=function(){for(var t=[],r=0;arguments.length>r;r++)t[r]=arguments[r];var n=new e.AABB;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),g=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,r,n,i,a,o){var s=r.fill,l=r.fillRule,h=r.opacity,c=r.fillOpacity,d=r.stroke,p=r.strokeOpacity,f=r.lineWidth,y=r.lineCap,v=r.lineJoin,g=r.shadowType,A=r.shadowColor,x=r.shadowBlur,b=r.filter,S=r.miterLimit,B=!u(s)&&!s.isNone,M=!u(d)&&!d.isNone&&f>0,w=0===s.alpha,R=!(!b||!b.length),E=!u(A)&&x>0,O=n.nodeName,C="inner"===g,T=M&&E&&(O===e.Shape.PATH||O===e.Shape.LINE||O===e.Shape.POLYLINE||w||C);B&&(t.globalAlpha=h*c,T||m(n,t,E),this.fill(t,n,s,l,i,a,o),T||this.clearShadowAndFilter(t,R,E)),M&&(t.globalAlpha=h*p,t.lineWidth=f,u(S)||(t.miterLimit=S),u(y)||(t.lineCap=y),u(v)||(t.lineJoin=v),T&&(C&&(t.globalCompositeOperation="source-atop"),m(n,t,!0),C&&(this.stroke(t,n,d,i,a,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,R,!0))),this.stroke(t,n,d,i,a,o))},t.prototype.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!u(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,r,n,i,a,o,s){var l=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=l.getColor(e,r,t),i?t.fill(i):t.fill()})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,a,o,s)),i?t.fill(i):t.fill())},t.prototype.stroke=function(t,r,n,i,a,o){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,a,o)),t.stroke())},t.prototype.getPattern=function(t,e,r,n,i,a){var o,s;if("rect"===t.image.nodeName){var l=t.image.parsedStyle,h=l.width,c=l.height;s=n.contextService.getDPR();var d=n.config.offscreenCanvas;(o=a.offscreenCanvasCreator.getOrCreateCanvas(d)).width=h*s,o.height=c*s;var p=a.offscreenCanvasCreator.getOrCreateContext(d),u=[];t.image.forEach((function(t){i.renderDisplayObject(t,p,n,u,a)})),u.forEach((function(){p.restore()}))}return this.imagePool.getOrCreatePatternSync(t,r,o,s,e.getGeometryBounds().min,(function(){e.renderable.dirty=!0,n.renderingService.dirtify()}))},t.prototype.getColor=function(t,r,n){var a;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var o=r.getGeometryBounds(),s=o&&2*o.halfExtents[0]||1,l=o&&2*o.halfExtents[1]||1,h=o&&o.min||[0,0];a=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{min:h,width:s,height:l}),n)}return a},t}();function m(t,e,r){var n=t.parsedStyle,i=n.filter,a=n.shadowColor,o=n.shadowBlur,s=n.shadowOffsetX,l=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=""+a,e.shadowBlur=o||0,e.shadowOffsetX=s||0,e.shadowOffsetY=l||0)}var A=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.x,a=e.y,o=e.img,s=e.shadowColor,l=e.shadowBlur,h=e.width,c=e.height;if(y(o,"String")?n=this.imagePool.getImageSync(o):(h||(h=o.width),c||(c=o.height),n=o),n){m(r,t,!u(s)&&l>0);try{t.drawImage(n,i,a,h,c)}catch(t){}}},t}(),x=function(){function t(){}return t.prototype.render=function(t,e,r,n,i,a){var o=e.lineWidth,s=e.textAlign,l=e.textBaseline,h=e.lineJoin,c=e.miterLimit,d=e.letterSpacing,p=e.stroke,f=e.fill,y=e.fillOpacity,v=e.strokeOpacity,g=e.opacity,A=e.metrics,x=e.x,b=void 0===x?0:x,S=e.y,B=void 0===S?0:S,M=e.dx,w=e.dy,R=e.shadowColor,E=e.shadowBlur,O=A.lines,C=A.height,T=A.lineHeight,P=A.lineMetrics;t.font=A.font,t.lineWidth=o,t.textAlign="middle"===s?"center":s;var N=l;a.enableCSSParsing||"alphabetic"!==N||(N="bottom"),t.lineJoin=h,u(c)||(t.miterLimit=c);var L=B;"middle"===l?L+=-C/2-T/2:"bottom"===l||"alphabetic"===l||"ideographic"===l?L+=-C:"top"!==l&&"hanging"!==l||(L+=-T);var k=b+(M||0);L+=w||0,1===O.length&&("bottom"===N?(N="middle",L-=.5*C):"top"===N&&(N="middle",L+=.5*C)),t.textBaseline=N,m(r,t,!u(R)&&E>0);for(var D=0;O.length>D;D++){var F=o/2+k;L+=T,u(p)||p.isNone||!o||this.drawLetterSpacing(t,O[D],P[D],s,F,L,d,y,v,g,!0),u(f)||this.drawLetterSpacing(t,O[D],P[D],s,F,L,d,y,v,g)}},t.prototype.drawLetterSpacing=function(t,e,r,n,i,a,o,s,l,h,c){if(void 0===c&&(c=!1),0!==o){var d=t.textAlign;t.textAlign="left";var p=i;"center"===n||"middle"===n?p=i-r.width/2:"right"!==n&&"end"!==n||(p=i-r.width);for(var u=Array.from(e),f=t.measureText(e).width,y=0,v=0;u.length>v;++v){var g=u[v];c?this.strokeText(t,g,p,a,l):this.fillText(t,g,p,a,s,h),p+=f-(y=t.measureText(e.substring(v+1)).width)+o,f=y}t.textAlign=d}else c?this.strokeText(t,e,i,a,l):this.fillText(t,e,i,a,s,h)},t.prototype.fillText=function(t,e,r,n,i,a){var o,s=!u(i)&&1!==i;s&&(o=t.globalAlpha,t.globalAlpha=i*a),t.fillText(e,r,n),s&&(t.globalAlpha=o)},t.prototype.strokeText=function(t,e,r,n,i){var a,o=!u(i)&&1!==i;o&&(a=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),o&&(t.globalAlpha=a)},t}(),b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),M=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),w=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),E=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(g),O=function(t){function r(e){void 0===e&&(e={});var r=t.call(this)||this;return r.options=e,r.name="canvas-renderer",r}return n(r,t),r.prototype.init=function(){var t,r=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,a=new g(n),o=((t={})[e.Shape.CIRCLE]=a,t[e.Shape.ELLIPSE]=a,t[e.Shape.RECT]=a,t[e.Shape.IMAGE]=new A(n),t[e.Shape.TEXT]=new x,t[e.Shape.LINE]=a,t[e.Shape.POLYLINE]=a,t[e.Shape.POLYGON]=a,t[e.Shape.PATH]=a,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new v(r))},r.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=S,t.EllipseRenderer=B,t.ImageRenderer=A,t.LineRenderer=M,t.PathRenderer=E,t.Plugin=O,t.PolygonRenderer=R,t.PolylineRenderer=w,t.RectRenderer=b,t.TextRenderer=x})); | ||
!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";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;n>r;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}var a="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var t=new a(16);return a!=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 s(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 h(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],l=e[4],s=e[5],h=e[6],c=e[7],d=e[8],p=e[9],u=e[10],f=e[11],y=e[12],v=e[13],g=e[14],m=e[15],A=r[0],x=r[1],b=r[2],S=r[3];return t[0]=A*n+x*l+b*d+S*y,t[1]=A*i+x*s+b*p+S*v,t[2]=A*o+x*h+b*u+S*g,t[3]=A*a+x*c+b*f+S*m,t[4]=(A=r[4])*n+(x=r[5])*l+(b=r[6])*d+(S=r[7])*y,t[5]=A*i+x*s+b*p+S*v,t[6]=A*o+x*h+b*u+S*g,t[7]=A*a+x*c+b*f+S*m,t[8]=(A=r[8])*n+(x=r[9])*l+(b=r[10])*d+(S=r[11])*y,t[9]=A*i+x*s+b*p+S*v,t[10]=A*o+x*h+b*u+S*g,t[11]=A*a+x*c+b*f+S*m,t[12]=(A=r[12])*n+(x=r[13])*l+(b=r[14])*d+(S=r[15])*y,t[13]=A*i+x*s+b*p+S*v,t[14]=A*o+x*h+b*u+S*g,t[15]=A*a+x*c+b*f+S*m,t}function c(){var t=new a(3);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function d(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)}),c();var p=function(t){return null==t},u={}.toString,f=function(t,e){return u.call(t)==="[object "+e+"]"},y=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=l(),this.dprMatrix=l(),this.tmpMat4=l(),this.vec3a=c(),this.vec3b=c(),this.vec3c=c(),this.vec3d=c()}return t.prototype.apply=function(r,n){var i=this;this.context=r;var a=r.config,l=r.camera,s=r.renderingService,c=r.renderingContext,p=r.pathGeneratorFactory;this.rBush=r.rBushRoot,this.pathGeneratorFactory=p;var u=r.contextService,f=c.root.ownerDocument.defaultView,y=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)},v=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)};s.hooks.init.tap(t.tag,(function(){f.addEventListener(e.ElementEvent.UNMOUNTED,y),f.addEventListener(e.ElementEvent.CULLED,v);var t=u.getDPR(),r=a.width,n=a.height,o=u.getContext();i.clearRect(o,0,0,r*t,n*t,a.background)})),s.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(e.ElementEvent.UNMOUNTED,y),f.removeEventListener(e.ElementEvent.CULLED,v),i.renderQueue=[],i.removedRBushNodeAABBs=[],i.restoreStack=[]})),s.hooks.beginFrame.tap(t.tag,(function(){var t=u.getContext(),e=u.getDPR(),r=a.width,n=a.height,o=i.canvasRendererPluginOptions,l=o.dirtyObjectNumThreshold,h=o.dirtyObjectRatioThreshold,c=s.getStats(),d=c.rendered,p=d/c.total;i.clearFullScreen=s.disableDirtyRectangleRendering()||d>l&&p>h,t&&(t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,r*e,n*e,a.background))}));var g=function(t,e){t.isVisible()&&!t.isCulled()&&(i.renderDisplayObject(t,e,i.context,i.restoreStack,n),i.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){g(t,e)}))};s.hooks.endFrame.tap(t.tag,(function(){var t,r,s=u.getContext(),p=u.getDPR();if((t=i.dprMatrix)[0]=(r=[p,p,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,h(i.vpMatrix,i.dprMatrix,l.getOrthoMatrix()),i.clearFullScreen)g(c.root,s);else{var y=i.safeMergeAABB.apply(i,function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;o>i;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([i.mergeDirtyAABBs(i.renderQueue)],o(i.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}))),!1));if(i.removedRBushNodeAABBs=[],e.AABB.isEmpty(y))return void(i.renderQueue=[]);var v=i.convertAABB2Rect(y),m=v.x,A=v.y,x=v.width,b=v.height,S=d(i.vec3a,[m,A,0],i.vpMatrix),B=d(i.vec3b,[m+x,A,0],i.vpMatrix),M=d(i.vec3c,[m,A+b,0],i.vpMatrix),w=d(i.vec3d,[m+x,A+b,0],i.vpMatrix),R=Math.min(S[0],B[0],w[0],M[0]),O=Math.min(S[1],B[1],w[1],M[1]),E=Math.max(S[0],B[0],w[0],M[0]),C=Math.max(S[1],B[1],w[1],M[1]),T=Math.floor(R),P=Math.floor(O),N=Math.ceil(E-R),L=Math.ceil(C-O);s.save(),i.clearRect(s,T,P,N,L,a.background),s.beginPath(),s.rect(T,P,N,L),s.clip(),s.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:P,width:N,height:L}})),i.searchDirtyObjects(y).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&i.renderDisplayObject(t,s,i.context,i.restoreStack,n)})),s.restore(),i.renderQueue.forEach((function(t){i.saveDirtyAABB(t)})),i.renderQueue=[]}i.restoreStack.forEach((function(){s.restore()})),i.restoreStack=[]})),s.hooks.render.tap(t.tag,(function(t){i.clearFullScreen||i.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,r,n,i,o){t.clearRect(e,r,n,i),o&&(t.fillStyle=o,t.fillRect(e,r,n,i))},t.prototype.renderDisplayObject=function(t,r,n,i,o){var a=t.nodeName,l=i[i.length-1];!l||t.compareDocumentPosition(l)&e.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.pop());var s=this.context.styleRendererFactory[a],h=this.pathGeneratorFactory[a],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(r,c);var d=this.pathGeneratorFactory[c.nodeName];d&&(r.save(),i.push(t),r.beginPath(),d(r,c.parsedStyle),r.closePath(),r.clip())}s&&(this.applyWorldTransform(r,t),r.save(),this.applyAttributesToContext(r,t)),h&&(r.beginPath(),h(r,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,t.parsedStyle,t,n,this,o),r.restore()),t.renderable.dirty=!1},t.prototype.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}},t.prototype.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},t.prototype.searchDirtyObjects=function(t){var e=o(t.getMin(),2),r=e[0],n=e[1],i=o(t.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[1]}).map((function(t){return t.displayObject}))},t.prototype.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)},t.prototype.applyAttributesToContext=function(t,e){var r=e.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,l=r.lineDashOffset;a&&t.setLineDash(a),p(l)||(t.lineDashOffset=l),p(o)||(t.globalAlpha*=o),p(n)||Array.isArray(n)||n.isNone||(t.strokeStyle=e.attributes.stroke),p(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,r){r?(s(this.tmpMat4,e.getLocalTransform()),h(this.tmpMat4,r,this.tmpMat4),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(s(this.tmpMat4,e.getWorldTransform()),h(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])},t.prototype.safeMergeAABB=function(){for(var t=[],r=0;arguments.length>r;r++)t[r]=arguments[r];var n=new e.AABB;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),v=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,r,n,i,o,a){var l=r.fill,s=r.fillRule,h=r.opacity,c=r.fillOpacity,d=r.stroke,u=r.strokeOpacity,f=r.lineWidth,y=r.lineCap,v=r.lineJoin,m=r.shadowType,A=r.shadowColor,x=r.shadowBlur,b=r.filter,S=r.miterLimit,B=!p(l)&&!l.isNone,M=!p(d)&&!d.isNone&&f>0,w=0===l.alpha,R=!(!b||!b.length),O=!p(A)&&x>0,E=n.nodeName,C="inner"===m,T=M&&O&&(E===e.Shape.PATH||E===e.Shape.LINE||E===e.Shape.POLYLINE||w||C);B&&(t.globalAlpha=h*c,T||g(n,t,O),this.fill(t,n,l,s,i,o,a),T||this.clearShadowAndFilter(t,R,O)),M&&(t.globalAlpha=h*u,t.lineWidth=f,p(S)||(t.miterLimit=S),p(y)||(t.lineCap=y),p(v)||(t.lineJoin=v),T&&(C&&(t.globalCompositeOperation="source-atop"),g(n,t,!0),C&&(this.stroke(t,n,d,i,o,a),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,R,!0))),this.stroke(t,n,d,i,o,a))},t.prototype.clearShadowAndFilter=function(t,e,r){if(r&&(t.shadowColor="transparent",t.shadowBlur=0),e){var n=t.filter;!p(n)&&n.indexOf("drop-shadow")>-1&&(t.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,r,n,i,o,a,l){var s=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=s.getColor(e,r,t),i?t.fill(i):t.fill()})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o,a,l)),i?t.fill(i):t.fill())},t.prototype.stroke=function(t,r,n,i,o,a){var l=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=l.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,i,o,a)),t.stroke())},t.prototype.getPattern=function(t,e,r,n,i,o){var a,l;if("rect"===t.image.nodeName){var s=t.image.parsedStyle,h=s.width,c=s.height;l=n.contextService.getDPR();var d=n.config.offscreenCanvas;(a=o.offscreenCanvasCreator.getOrCreateCanvas(d)).width=h*l,a.height=c*l;var p=o.offscreenCanvasCreator.getOrCreateContext(d),u=[];t.image.forEach((function(t){i.renderDisplayObject(t,p,n,u,o)})),u.forEach((function(){p.restore()}))}return this.imagePool.getOrCreatePatternSync(t,r,a,l,e.getGeometryBounds().min,(function(){e.renderable.dirty=!0,n.renderingService.dirtify()}))},t.prototype.getColor=function(t,r,n){var o;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var a=r.getGeometryBounds(),l=a&&2*a.halfExtents[0]||1,s=a&&2*a.halfExtents[1]||1,h=a&&a.min||[0,0];o=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{min:h,width:l,height:s}),n)}return o},t}();function g(t,e,r){var n=t.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,l=n.shadowOffsetX,s=n.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),r&&(e.shadowColor=""+o,e.shadowBlur=a||0,e.shadowOffsetX=l||0,e.shadowOffsetY=s||0)}var m=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,r){var n,i=e.x,o=void 0===i?0:i,a=e.y,l=void 0===a?0:a,s=e.img,h=e.shadowColor,c=e.shadowBlur,d=e.width,u=e.height;if(f(s,"String")?n=this.imagePool.getImageSync(s):(d||(d=s.width),u||(u=s.height),n=s),n){g(r,t,!p(h)&&c>0);try{t.drawImage(n,o,l,d,u)}catch(t){}}},t}(),A=function(){function t(){}return t.prototype.render=function(t,e,r,n,i,o){var a=e.lineWidth,l=e.textAlign,s=e.textBaseline,h=e.lineJoin,c=e.miterLimit,d=e.letterSpacing,u=e.stroke,f=e.fill,y=e.fillOpacity,v=e.strokeOpacity,m=e.opacity,A=e.metrics,x=e.x,b=void 0===x?0:x,S=e.y,B=void 0===S?0:S,M=e.dx,w=e.dy,R=e.shadowColor,O=e.shadowBlur,E=A.lines,C=A.height,T=A.lineHeight,P=A.lineMetrics;t.font=A.font,t.lineWidth=a,t.textAlign="middle"===l?"center":l;var N=s;o.enableCSSParsing||"alphabetic"!==N||(N="bottom"),t.lineJoin=h,p(c)||(t.miterLimit=c);var L=B;"middle"===s?L+=-C/2-T/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?L+=-C:"top"!==s&&"hanging"!==s||(L+=-T);var k=b+(M||0);L+=w||0,1===E.length&&("bottom"===N?(N="middle",L-=.5*C):"top"===N&&(N="middle",L+=.5*C)),t.textBaseline=N,g(r,t,!p(R)&&O>0);for(var D=0;E.length>D;D++){var F=a/2+k;L+=T,p(u)||u.isNone||!a||this.drawLetterSpacing(t,E[D],P[D],l,F,L,d,y,v,m,!0),p(f)||this.drawLetterSpacing(t,E[D],P[D],l,F,L,d,y,v,m)}},t.prototype.drawLetterSpacing=function(t,e,r,n,i,o,a,l,s,h,c){if(void 0===c&&(c=!1),0!==a){var d=t.textAlign;t.textAlign="left";var p=i;"center"===n||"middle"===n?p=i-r.width/2:"right"!==n&&"end"!==n||(p=i-r.width);for(var u=Array.from(e),f=t.measureText(e).width,y=0,v=0;u.length>v;++v){var g=u[v];c?this.strokeText(t,g,p,o,s):this.fillText(t,g,p,o,l,h),p+=f-(y=t.measureText(e.substring(v+1)).width)+a,f=y}t.textAlign=d}else c?this.strokeText(t,e,i,o,s):this.fillText(t,e,i,o,l,h)},t.prototype.fillText=function(t,e,r,n,i,o){var a,l=!p(i)&&1!==i;l&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,r,n),l&&(t.globalAlpha=a)},t.prototype.strokeText=function(t,e,r,n,i){var o,a=!p(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,r,n),a&&(t.globalAlpha=o)},t}(),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),M=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),w=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),O=function(t){function r(e){void 0===e&&(e={});var r=t.call(this)||this;return r.options=e,r.name="canvas-renderer",r}return n(r,t),r.prototype.init=function(){var t,r=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,o=new v(n),a=((t={})[e.Shape.CIRCLE]=o,t[e.Shape.ELLIPSE]=o,t[e.Shape.RECT]=o,t[e.Shape.IMAGE]=new m(n),t[e.Shape.TEXT]=new A,t[e.Shape.LINE]=o,t[e.Shape.POLYLINE]=o,t[e.Shape.POLYGON]=o,t[e.Shape.PATH]=o,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 y(r))},r.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},r}(e.AbstractRendererPlugin);t.CircleRenderer=b,t.EllipseRenderer=S,t.ImageRenderer=m,t.LineRenderer=B,t.PathRenderer=R,t.Plugin=O,t.PolygonRenderer=w,t.PolylineRenderer=M,t.RectRenderer=x,t.TextRenderer=A})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.10.0-next.0", | ||
"version": "1.10.0-next.1", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -38,5 +38,5 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "1.3.0-next.0", | ||
"@antv/g-plugin-image-loader": "1.4.0-next.0", | ||
"@antv/g-plugin-canvas-path-generator": "1.3.22-next.0", | ||
"@antv/g-lite": "1.3.0-next.1", | ||
"@antv/g-plugin-canvas-path-generator": "1.3.22-next.1", | ||
"@antv/g-plugin-image-loader": "1.4.0-next.1", | ||
"@antv/g-math": "2.0.2" | ||
@@ -43,0 +43,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
280697
1795
+ Added@antv/g-lite@1.3.0-next.1(transitive)
+ Added@antv/g-plugin-canvas-path-generator@1.3.22-next.1(transitive)
+ Added@antv/g-plugin-image-loader@1.4.0-next.1(transitive)
- Removed@antv/g-lite@1.3.0-next.0(transitive)
- Removed@antv/g-plugin-canvas-path-generator@1.3.22-next.0(transitive)
- Removed@antv/g-plugin-image-loader@1.4.0-next.0(transitive)
Updated@antv/g-lite@1.3.0-next.1