@antv/g-plugin-canvas-renderer
Advanced tools
Comparing version 1.9.23 to 1.10.0-next.0
@@ -524,3 +524,3 @@ import { __spreadArray, __read, __assign, __extends } from 'tslib'; | ||
} | ||
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, function () { | ||
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, object.getGeometryBounds().min, function () { | ||
// set dirty rectangle flag | ||
@@ -539,3 +539,4 @@ object.renderable.dirty = true; | ||
var height = (bounds && bounds.halfExtents[1] * 2) || 1; | ||
color = this.imagePool.getOrCreateGradient(__assign(__assign({ type: parsedColor.type }, parsedColor.value), { width: width, height: height }), context); | ||
var min = (bounds && bounds.min) || [0, 0]; | ||
color = this.imagePool.getOrCreateGradient(__assign(__assign({ type: parsedColor.type }, parsedColor.value), { min: min, width: width, height: height }), context); | ||
} | ||
@@ -568,3 +569,3 @@ return color; | ||
ImageRenderer.prototype.render = function (context, parsedStyle, object) { | ||
var width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var x = parsedStyle.x, y = parsedStyle.y, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var image; | ||
@@ -588,3 +589,3 @@ var iw = width; | ||
try { | ||
context.drawImage(image, 0, 0, iw, ih); | ||
context.drawImage(image, x, y, iw, ih); | ||
} | ||
@@ -601,3 +602,3 @@ catch (e) { } | ||
TextRenderer.prototype.render = function (context, parsedStyle, object, canvasContext, plugin, runtime) { | ||
var _a = parsedStyle, lineWidth = _a.lineWidth, textAlign = _a.textAlign, textBaseline = _a.textBaseline, lineJoin = _a.lineJoin, miterLimit = _a.miterLimit, letterSpacing = _a.letterSpacing, stroke = _a.stroke, fill = _a.fill, fillOpacity = _a.fillOpacity, strokeOpacity = _a.strokeOpacity, opacity = _a.opacity, metrics = _a.metrics, dx = _a.dx, dy = _a.dy, shadowColor = _a.shadowColor, shadowBlur = _a.shadowBlur; | ||
var _a = parsedStyle, lineWidth = _a.lineWidth, textAlign = _a.textAlign, textBaseline = _a.textBaseline, lineJoin = _a.lineJoin, miterLimit = _a.miterLimit, letterSpacing = _a.letterSpacing, stroke = _a.stroke, fill = _a.fill, fillOpacity = _a.fillOpacity, strokeOpacity = _a.strokeOpacity, opacity = _a.opacity, metrics = _a.metrics, _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, dx = _a.dx, dy = _a.dy, shadowColor = _a.shadowColor, shadowBlur = _a.shadowBlur; | ||
var font = metrics.font, lines = metrics.lines, height = metrics.height, lineHeight = metrics.lineHeight, lineMetrics = metrics.lineMetrics; | ||
@@ -618,6 +619,6 @@ context.font = font; | ||
} | ||
var linePositionY = 0; | ||
var linePositionY = y; | ||
// handle vertical text baseline | ||
if (textBaseline === 'middle') { | ||
linePositionY = -height / 2 - lineHeight / 2; | ||
linePositionY += -height / 2 - lineHeight / 2; | ||
} | ||
@@ -627,9 +628,9 @@ else if (textBaseline === 'bottom' || | ||
textBaseline === 'ideographic') { | ||
linePositionY = -height; | ||
linePositionY += -height; | ||
} | ||
else if (textBaseline === 'top' || textBaseline === 'hanging') { | ||
linePositionY = -lineHeight; | ||
linePositionY += -lineHeight; | ||
} | ||
// account for dx & dy | ||
var offsetX = dx || 0; | ||
var offsetX = x + (dx || 0); | ||
linePositionY += dy || 0; | ||
@@ -636,0 +637,0 @@ if (lines.length === 1) { |
@@ -526,3 +526,3 @@ 'use strict'; | ||
} | ||
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, function () { | ||
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, object.getGeometryBounds().min, function () { | ||
// set dirty rectangle flag | ||
@@ -541,3 +541,4 @@ object.renderable.dirty = true; | ||
var height = (bounds && bounds.halfExtents[1] * 2) || 1; | ||
color = this.imagePool.getOrCreateGradient(tslib.__assign(tslib.__assign({ type: parsedColor.type }, parsedColor.value), { width: width, height: height }), context); | ||
var min = (bounds && bounds.min) || [0, 0]; | ||
color = this.imagePool.getOrCreateGradient(tslib.__assign(tslib.__assign({ type: parsedColor.type }, parsedColor.value), { min: min, width: width, height: height }), context); | ||
} | ||
@@ -570,3 +571,3 @@ return color; | ||
ImageRenderer.prototype.render = function (context, parsedStyle, object) { | ||
var width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var x = parsedStyle.x, y = parsedStyle.y, width = parsedStyle.width, height = parsedStyle.height, img = parsedStyle.img, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur; | ||
var image; | ||
@@ -590,3 +591,3 @@ var iw = width; | ||
try { | ||
context.drawImage(image, 0, 0, iw, ih); | ||
context.drawImage(image, x, y, iw, ih); | ||
} | ||
@@ -603,3 +604,3 @@ catch (e) { } | ||
TextRenderer.prototype.render = function (context, parsedStyle, object, canvasContext, plugin, runtime) { | ||
var _a = parsedStyle, lineWidth = _a.lineWidth, textAlign = _a.textAlign, textBaseline = _a.textBaseline, lineJoin = _a.lineJoin, miterLimit = _a.miterLimit, letterSpacing = _a.letterSpacing, stroke = _a.stroke, fill = _a.fill, fillOpacity = _a.fillOpacity, strokeOpacity = _a.strokeOpacity, opacity = _a.opacity, metrics = _a.metrics, dx = _a.dx, dy = _a.dy, shadowColor = _a.shadowColor, shadowBlur = _a.shadowBlur; | ||
var _a = parsedStyle, lineWidth = _a.lineWidth, textAlign = _a.textAlign, textBaseline = _a.textBaseline, lineJoin = _a.lineJoin, miterLimit = _a.miterLimit, letterSpacing = _a.letterSpacing, stroke = _a.stroke, fill = _a.fill, fillOpacity = _a.fillOpacity, strokeOpacity = _a.strokeOpacity, opacity = _a.opacity, metrics = _a.metrics, _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, dx = _a.dx, dy = _a.dy, shadowColor = _a.shadowColor, shadowBlur = _a.shadowBlur; | ||
var font = metrics.font, lines = metrics.lines, height = metrics.height, lineHeight = metrics.lineHeight, lineMetrics = metrics.lineMetrics; | ||
@@ -620,6 +621,6 @@ context.font = font; | ||
} | ||
var linePositionY = 0; | ||
var linePositionY = y; | ||
// handle vertical text baseline | ||
if (textBaseline === 'middle') { | ||
linePositionY = -height / 2 - lineHeight / 2; | ||
linePositionY += -height / 2 - lineHeight / 2; | ||
} | ||
@@ -629,9 +630,9 @@ else if (textBaseline === 'bottom' || | ||
textBaseline === 'ideographic') { | ||
linePositionY = -height; | ||
linePositionY += -height; | ||
} | ||
else if (textBaseline === 'top' || textBaseline === 'hanging') { | ||
linePositionY = -lineHeight; | ||
linePositionY += -lineHeight; | ||
} | ||
// account for dx & dy | ||
var offsetX = dx || 0; | ||
var offsetX = x + (dx || 0); | ||
linePositionY += dy || 0; | ||
@@ -638,0 +639,0 @@ if (lines.length === 1) { |
@@ -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],p=e[8],d=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*p+S*y,t[1]=A*i+x*l+b*d+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])*p+(S=r[7])*y,t[5]=A*i+x*l+b*d+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])*p+(S=r[11])*y,t[9]=A*i+x*l+b*d+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])*p+(S=r[15])*y,t[13]=A*i+x*l+b*d+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,p,d,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],p=e[8],d=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]=p,t[9]=d,t[10]=u,t[11]=f,t[12]=n*y+s*v+p*g+e[12],t[13]=i*y+l*v+d*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 p(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function d(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)}),p();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=p(),this.vec3b=p(),this.vec3c=p(),this.vec3d=p()}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,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)};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(),p=c.rendered,d=p/c.total;i.clearFullScreen=l.disableDirtyRectangleRendering()||p>s&&d>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(),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,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=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]),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 p=this.pathGeneratorFactory[c.nodeName];p&&(r.save(),i.push(t),r.beginPath(),p(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 p=e.geometry.contentBounds;n=-o*(p&&2*p.halfExtents[0]||0),i=-s*(p&&2*p.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,p=r.stroke,d=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(p)&&!p.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*d,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,p,i,a,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,R,!0))),this.stroke(t,n,p,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 p=n.config.offscreenCanvas;(o=a.offscreenCanvasCreator.getOrCreateCanvas(p)).width=h*s,o.height=c*s;var d=a.offscreenCanvasCreator.getOrCreateContext(p),u=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,n,u,a)})),u.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,r,o,s,(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;a=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{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.img,a=e.shadowColor,o=e.shadowBlur,s=e.width,l=e.height;if(y(i,"String")?n=this.imagePool.getImageSync(i):(s||(s=i.width),l||(l=i.height),n=i),n){m(r,t,!u(a)&&o>0);try{t.drawImage(n,0,0,s,l)}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,p=e.letterSpacing,d=e.stroke,f=e.fill,y=e.fillOpacity,v=e.strokeOpacity,g=e.opacity,A=e.metrics,x=e.dx,b=e.dy,S=e.shadowColor,B=e.shadowBlur,M=A.lines,w=A.height,R=A.lineHeight,E=A.lineMetrics;t.font=A.font,t.lineWidth=o,t.textAlign="middle"===s?"center":s;var O=l;a.enableCSSParsing||"alphabetic"!==O||(O="bottom"),t.lineJoin=h,u(c)||(t.miterLimit=c);var C=0;"middle"===l?C=-w/2-R/2:"bottom"===l||"alphabetic"===l||"ideographic"===l?C=-w:"top"!==l&&"hanging"!==l||(C=-R);var T=x||0;C+=b||0,1===M.length&&("bottom"===O?(O="middle",C-=.5*w):"top"===O&&(O="middle",C+=.5*w)),t.textBaseline=O,m(r,t,!u(S)&&B>0);for(var P=0;M.length>P;P++){var N=o/2+T;C+=R,u(d)||d.isNone||!o||this.drawLetterSpacing(t,M[P],E[P],s,N,C,p,y,v,g,!0),u(f)||this.drawLetterSpacing(t,M[P],E[P],s,N,C,p,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 p=t.textAlign;t.textAlign="left";var d=i;"center"===n||"middle"===n?d=i-r.width/2:"right"!==n&&"end"!==n||(d=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,d,a,l):this.fillText(t,g,d,a,s,h),d+=f-(y=t.measureText(e.substring(v+1)).width)+o,f=y}t.textAlign=p}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 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})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-canvas-renderer", | ||
"version": "1.9.23", | ||
"version": "1.10.0-next.0", | ||
"description": "A G plugin of renderer implementation with Canvas2D API", | ||
@@ -38,5 +38,5 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "1.2.21", | ||
"@antv/g-plugin-canvas-path-generator": "1.3.21", | ||
"@antv/g-plugin-image-loader": "1.3.21", | ||
"@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-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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
287229
1840
2
+ Added@antv/g-lite@1.3.0-next.0(transitive)
+ Added@antv/g-plugin-canvas-path-generator@1.3.22-next.0(transitive)
+ Added@antv/g-plugin-image-loader@1.4.0-next.0(transitive)
- Removed@antv/g-lite@1.2.21(transitive)
- Removed@antv/g-plugin-canvas-path-generator@1.3.21(transitive)
- Removed@antv/g-plugin-image-loader@1.3.21(transitive)
Updated@antv/g-lite@1.3.0-next.0