Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-plugin-canvas-renderer

Package Overview
Dependencies
Maintainers
64
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-canvas-renderer - npm Package Compare versions

Comparing version 1.10.0-next.12 to 1.10.0-next.13

21

dist/index.esm.js

@@ -103,6 +103,2 @@ import { __spreadArray, __read, __assign, __extends } from 'tslib';

_this.renderDisplayObject(object, context, _this.context, _this.restoreStack, runtime);
// if (object.renderable.) {
// if we did a full screen rendering last frame
// this.saveDirtyAABB(object);
// }
}

@@ -184,3 +180,2 @@ var sorted = object.sortable.sorted || object.childNodes;

var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds);
console.log(dirtyObjects, dirtyRenderBounds);
// do rendering

@@ -398,3 +393,3 @@ dirtyObjects

DefaultRenderer.prototype.render = function (context, parsedStyle, object, canvasContext, plugin, runtime) {
var fill = parsedStyle.fill, fillRule = parsedStyle.fillRule, opacity = parsedStyle.opacity, fillOpacity = parsedStyle.fillOpacity, stroke = parsedStyle.stroke, strokeOpacity = parsedStyle.strokeOpacity, lineWidth = parsedStyle.lineWidth, lineCap = parsedStyle.lineCap, lineJoin = parsedStyle.lineJoin, shadowType = parsedStyle.shadowType, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur, filter = parsedStyle.filter, miterLimit = parsedStyle.miterLimit;
var fill = parsedStyle.fill, fillRule = parsedStyle.fillRule, opacity = parsedStyle.opacity, fillOpacity = parsedStyle.fillOpacity, stroke = parsedStyle.stroke, strokeOpacity = parsedStyle.strokeOpacity, _a = parsedStyle.lineWidth, lineWidth = _a === void 0 ? 1 : _a, lineCap = parsedStyle.lineCap, lineJoin = parsedStyle.lineJoin, shadowType = parsedStyle.shadowType, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur, filter = parsedStyle.filter, miterLimit = parsedStyle.miterLimit;
var hasFill = !isNil(fill) && !fill.isNone;

@@ -557,14 +552,14 @@ var hasStroke = !isNil(stroke) && !stroke.isNone && lineWidth > 0;

ImageRenderer.prototype.render = function (context, parsedStyle, object) {
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 _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, width = parsedStyle.width, height = parsedStyle.height, src = parsedStyle.src, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur;
var image;
var iw = width;
var ih = height;
if (isString(img)) {
if (isString(src)) {
// image has been loaded in `mounted` hook
image = this.imagePool.getImageSync(img);
image = this.imagePool.getImageSync(src);
}
else {
iw || (iw = img.width);
ih || (ih = img.height);
image = img;
iw || (iw = src.width);
ih || (ih = src.height);
image = src;
}

@@ -591,3 +586,3 @@ if (image) {

object.getBounds();
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 _a = parsedStyle, _b = _a.lineWidth, lineWidth = _b === void 0 ? 1 : _b, _c = _a.textAlign, textAlign = _c === void 0 ? 'start' : _c, _d = _a.textBaseline, textBaseline = _d === void 0 ? 'alphabetic' : _d, _e = _a.lineJoin, lineJoin = _e === void 0 ? 'miter' : _e, _f = _a.miterLimit, miterLimit = _f === void 0 ? 10 : _f, _g = _a.letterSpacing, letterSpacing = _g === void 0 ? 0 : _g, stroke = _a.stroke, fill = _a.fill, _h = _a.fillOpacity, fillOpacity = _h === void 0 ? 1 : _h, _j = _a.strokeOpacity, strokeOpacity = _j === void 0 ? 1 : _j, _k = _a.opacity, opacity = _k === void 0 ? 1 : _k, metrics = _a.metrics, _l = _a.x, x = _l === void 0 ? 0 : _l, _m = _a.y, y = _m === void 0 ? 0 : _m, 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;

@@ -594,0 +589,0 @@ context.font = font;

@@ -105,6 +105,2 @@ 'use strict';

_this.renderDisplayObject(object, context, _this.context, _this.restoreStack, runtime);
// if (object.renderable.) {
// if we did a full screen rendering last frame
// this.saveDirtyAABB(object);
// }
}

@@ -186,3 +182,2 @@ var sorted = object.sortable.sorted || object.childNodes;

var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds);
console.log(dirtyObjects, dirtyRenderBounds);
// do rendering

@@ -400,3 +395,3 @@ dirtyObjects

DefaultRenderer.prototype.render = function (context, parsedStyle, object, canvasContext, plugin, runtime) {
var fill = parsedStyle.fill, fillRule = parsedStyle.fillRule, opacity = parsedStyle.opacity, fillOpacity = parsedStyle.fillOpacity, stroke = parsedStyle.stroke, strokeOpacity = parsedStyle.strokeOpacity, lineWidth = parsedStyle.lineWidth, lineCap = parsedStyle.lineCap, lineJoin = parsedStyle.lineJoin, shadowType = parsedStyle.shadowType, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur, filter = parsedStyle.filter, miterLimit = parsedStyle.miterLimit;
var fill = parsedStyle.fill, fillRule = parsedStyle.fillRule, opacity = parsedStyle.opacity, fillOpacity = parsedStyle.fillOpacity, stroke = parsedStyle.stroke, strokeOpacity = parsedStyle.strokeOpacity, _a = parsedStyle.lineWidth, lineWidth = _a === void 0 ? 1 : _a, lineCap = parsedStyle.lineCap, lineJoin = parsedStyle.lineJoin, shadowType = parsedStyle.shadowType, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur, filter = parsedStyle.filter, miterLimit = parsedStyle.miterLimit;
var hasFill = !util.isNil(fill) && !fill.isNone;

@@ -559,14 +554,14 @@ var hasStroke = !util.isNil(stroke) && !stroke.isNone && lineWidth > 0;

ImageRenderer.prototype.render = function (context, parsedStyle, object) {
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 _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, width = parsedStyle.width, height = parsedStyle.height, src = parsedStyle.src, shadowColor = parsedStyle.shadowColor, shadowBlur = parsedStyle.shadowBlur;
var image;
var iw = width;
var ih = height;
if (util.isString(img)) {
if (util.isString(src)) {
// image has been loaded in `mounted` hook
image = this.imagePool.getImageSync(img);
image = this.imagePool.getImageSync(src);
}
else {
iw || (iw = img.width);
ih || (ih = img.height);
image = img;
iw || (iw = src.width);
ih || (ih = src.height);
image = src;
}

@@ -593,3 +588,3 @@ if (image) {

object.getBounds();
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 _a = parsedStyle, _b = _a.lineWidth, lineWidth = _b === void 0 ? 1 : _b, _c = _a.textAlign, textAlign = _c === void 0 ? 'start' : _c, _d = _a.textBaseline, textBaseline = _d === void 0 ? 'alphabetic' : _d, _e = _a.lineJoin, lineJoin = _e === void 0 ? 'miter' : _e, _f = _a.miterLimit, miterLimit = _f === void 0 ? 10 : _f, _g = _a.letterSpacing, letterSpacing = _g === void 0 ? 0 : _g, stroke = _a.stroke, fill = _a.fill, _h = _a.fillOpacity, fillOpacity = _h === void 0 ? 1 : _h, _j = _a.strokeOpacity, strokeOpacity = _j === void 0 ? 1 : _j, _k = _a.opacity, opacity = _k === void 0 ? 1 : _k, metrics = _a.metrics, _l = _a.x, x = _l === void 0 ? 0 : _l, _m = _a.y, y = _m === void 0 ? 0 : _m, 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;

@@ -596,0 +591,0 @@ context.font = font;

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}var a="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var e=new a(16);return a!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function s(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function h(e,t,r){var n=t[0],o=t[1],i=t[2],a=t[3],l=t[4],s=t[5],h=t[6],c=t[7],d=t[8],u=t[9],p=t[10],f=t[11],y=t[12],v=t[13],g=t[14],m=t[15],A=r[0],x=r[1],b=r[2],S=r[3];return e[0]=A*n+x*l+b*d+S*y,e[1]=A*o+x*s+b*u+S*v,e[2]=A*i+x*h+b*p+S*g,e[3]=A*a+x*c+b*f+S*m,e[4]=(A=r[4])*n+(x=r[5])*l+(b=r[6])*d+(S=r[7])*y,e[5]=A*o+x*s+b*u+S*v,e[6]=A*i+x*h+b*p+S*g,e[7]=A*a+x*c+b*f+S*m,e[8]=(A=r[8])*n+(x=r[9])*l+(b=r[10])*d+(S=r[11])*y,e[9]=A*o+x*s+b*u+S*v,e[10]=A*i+x*h+b*p+S*g,e[11]=A*a+x*c+b*f+S*m,e[12]=(A=r[12])*n+(x=r[13])*l+(b=r[14])*d+(S=r[15])*y,e[13]=A*o+x*s+b*u+S*v,e[14]=A*i+x*h+b*p+S*g,e[15]=A*a+x*c+b*f+S*m,e}function c(){var e=new a(3);return a!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function d(e,t,r){var n=t[0],o=t[1],i=t[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return e[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,e[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),c();var u=function(e){return null==e},p={}.toString,f=function(e,t){return p.call(e)==="[object "+t+"]"},y=function(){function e(e){this.canvasRendererPluginOptions=e,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreenLastFrame=!1,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 e.prototype.apply=function(r,n){var o=this;this.context=r;var a=r.config,l=r.camera,s=r.renderingService,c=r.renderingContext,u=r.pathGeneratorFactory;this.rBush=r.rBushRoot,this.pathGeneratorFactory=u;var p=r.contextService,f=c.root.ownerDocument.defaultView,y=function(e){var t=e.target.rBushNode;t.aabb&&o.removedRBushNodeAABBs.push(t.aabb)},v=function(e){var t=e.target.rBushNode;t.aabb&&o.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,(function(){f.addEventListener(t.ElementEvent.UNMOUNTED,y),f.addEventListener(t.ElementEvent.CULLED,v);var e=p.getDPR(),r=a.width,n=a.height,i=p.getContext();o.clearRect(i,0,0,r*e,n*e,a.background)})),s.hooks.destroy.tap(e.tag,(function(){f.removeEventListener(t.ElementEvent.UNMOUNTED,y),f.removeEventListener(t.ElementEvent.CULLED,v),o.renderQueue=[],o.removedRBushNodeAABBs=[],o.restoreStack=[]})),s.hooks.beginFrame.tap(e.tag,(function(){var e=p.getContext(),t=p.getDPR(),r=a.width,n=a.height,i=o.canvasRendererPluginOptions,l=i.dirtyObjectNumThreshold,h=i.dirtyObjectRatioThreshold,c=s.getStats(),d=c.rendered,u=d/c.total;o.clearFullScreen=o.clearFullScreenLastFrame||s.disableDirtyRectangleRendering()||d>l&&u>h,e&&(e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),o.clearFullScreen&&o.clearRect(e,0,0,r*t,n*t,a.background))}));var g=function(e,t){e.isVisible()&&!e.isCulled()&&o.renderDisplayObject(e,t,o.context,o.restoreStack,n),(e.sortable.sorted||e.childNodes).forEach((function(e){g(e,t)}))};s.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){o.clearFullScreenLastFrame=!1;var e,r,s=p.getContext(),u=p.getDPR();if((e=o.dprMatrix)[0]=(r=[u,u,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,h(o.vpMatrix,o.dprMatrix,l.getOrthoMatrix()),o.clearFullScreen)g(c.root,s);else{var y=o.safeMergeAABB.apply(o,function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;i>o;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([o.mergeDirtyAABBs(o.renderQueue)],i(o.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,o=e.maxX,i=e.maxY,a=new t.AABB;return a.setMinMax([r,n,0],[o,i,0]),a}))),!1));if(o.removedRBushNodeAABBs=[],t.AABB.isEmpty(y))return void(o.renderQueue=[]);var v=o.convertAABB2Rect(y),m=v.x,A=v.y,x=v.width,b=v.height,S=d(o.vec3a,[m,A,0],o.vpMatrix),B=d(o.vec3b,[m+x,A,0],o.vpMatrix),M=d(o.vec3c,[m,A+b,0],o.vpMatrix),w=d(o.vec3d,[m+x,A+b,0],o.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(),o.clearRect(s,T,P,N,L,a.background),s.beginPath(),s.rect(T,P,N,L),s.clip(),s.setTransform(o.vpMatrix[0],o.vpMatrix[1],o.vpMatrix[4],o.vpMatrix[5],o.vpMatrix[12],o.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:P,width:N,height:L}}));var k=o.searchDirtyObjects(y);console.log(k,y),k.sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&o.renderDisplayObject(e,s,o.context,o.restoreStack,n)})),s.restore(),o.renderQueue.forEach((function(e){o.saveDirtyAABB(e)})),o.renderQueue=[]}o.restoreStack.forEach((function(){s.restore()})),o.restoreStack=[]}else o.clearFullScreenLastFrame=!0})),s.hooks.render.tap(e.tag,(function(e){o.clearFullScreen||o.renderQueue.push(e)}))},e.prototype.clearRect=function(e,t,r,n,o,i){e.clearRect(t,r,n,o),i&&(e.fillStyle=i,e.fillRect(t,r,n,o))},e.prototype.renderDisplayObject=function(e,r,n,o,i){var a=e.nodeName,l=o[o.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),o.pop());var s=this.context.styleRendererFactory[a],h=this.pathGeneratorFactory[a],c=e.parsedStyle.clipPath;if(c){this.applyWorldTransform(r,c);var d=this.pathGeneratorFactory[c.nodeName];d&&(r.save(),o.push(e),r.beginPath(),d(r,c.parsedStyle),r.closePath(),r.clip())}s&&(this.applyWorldTransform(r,e),r.save(),this.applyAttributesToContext(r,e)),h&&(r.beginPath(),h(r,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,e.parsedStyle,e,n,this,i),r.restore()),e.renderable.dirty=!1},e.prototype.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),o=Math.floor(t[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},e.prototype.mergeDirtyAABBs=function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r},e.prototype.searchDirtyObjects=function(e){var t=i(e.getMin(),2),r=t[0],n=t[1],o=i(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:o[0],maxY:o[1]}).map((function(e){return e.displayObject}))},e.prototype.saveDirtyAABB=function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},e.prototype.applyAttributesToContext=function(e,t){var r=t.parsedStyle,n=r.stroke,o=r.fill,i=r.opacity,a=r.lineDash,l=r.lineDashOffset;a&&e.setLineDash(a),u(l)||(e.lineDashOffset=l),u(i)||(e.globalAlpha*=i),u(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),u(o)||Array.isArray(o)||o.isNone||(e.fillStyle=t.attributes.fill)},e.prototype.applyWorldTransform=function(e,t,r){r?(s(this.tmpMat4,t.getLocalTransform()),h(this.tmpMat4,r,this.tmpMat4),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(s(this.tmpMat4,t.getWorldTransform()),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},e.prototype.safeMergeAABB=function(){for(var e=[],r=0;arguments.length>r;r++)e[r]=arguments[r];var n=new t.AABB;return e.forEach((function(e){n.add(e)})),n},e.tag="CanvasRenderer",e}(),v=function(){function e(e){this.imagePool=e}return e.prototype.render=function(e,r,n,o,i,a){var l=r.fill,s=r.fillRule,h=r.opacity,c=r.fillOpacity,d=r.stroke,p=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=!u(l)&&!l.isNone,M=!u(d)&&!d.isNone&&f>0,w=0===(null==l?void 0:l.alpha),R=!(!b||!b.length),O=!u(A)&&x>0,E=n.nodeName,C="inner"===m,T=M&&O&&(E===t.Shape.PATH||E===t.Shape.LINE||E===t.Shape.POLYLINE||w||C);B&&(e.globalAlpha=h*c,T||g(n,e,O),this.fill(e,n,l,s,o,i,a),T||this.clearShadowAndFilter(e,R,O)),M&&(e.globalAlpha=h*p,e.lineWidth=f,u(S)||(e.miterLimit=S),u(y)||(e.lineCap=y),u(v)||(e.lineJoin=v),T&&(C&&(e.globalCompositeOperation="source-atop"),g(n,e,!0),C&&(this.stroke(e,n,d,o,i,a),e.globalCompositeOperation="source-over",this.clearShadowAndFilter(e,R,!0))),this.stroke(e,n,d,o,i,a))},e.prototype.clearShadowAndFilter=function(e,t,r){if(r&&(e.shadowColor="transparent",e.shadowBlur=0),t){var n=e.filter;!u(n)&&n.indexOf("drop-shadow")>-1&&(e.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},e.prototype.fill=function(e,r,n,o,i,a,l){var s=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=s.getColor(t,r,e),o?e.fill(o):e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,i,a,l)),o?e.fill(o):e.fill())},e.prototype.stroke=function(e,r,n,o,i,a){var l=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=l.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,o,i,a)),e.stroke())},e.prototype.getPattern=function(e,t,r,n,o,i){var a,l;if("rect"===e.image.nodeName){var s=e.image.parsedStyle,h=s.width,c=s.height;l=n.contextService.getDPR();var d=n.config.offscreenCanvas;(a=i.offscreenCanvasCreator.getOrCreateCanvas(d)).width=h*l,a.height=c*l;var u=i.offscreenCanvasCreator.getOrCreateContext(d),p=[];e.image.forEach((function(e){o.renderDisplayObject(e,u,n,p,i)})),p.forEach((function(){u.restore()}))}return this.imagePool.getOrCreatePatternSync(e,r,a,l,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))},e.prototype.getColor=function(e,r,n){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.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];i=this.imagePool.getOrCreateGradient(o(o({type:e.type},e.value),{min:h,width:l,height:s}),n)}return i},e}();function g(e,t,r){var n=e.parsedStyle,o=n.filter,i=n.shadowColor,a=n.shadowBlur,l=n.shadowOffsetX,s=n.shadowOffsetY;o&&o.length&&(t.filter=e.style.filter),r&&(t.shadowColor=""+i,t.shadowBlur=a||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}var m=function(){function e(e){this.imagePool=e}return e.prototype.render=function(e,t,r){var n,o=t.x,i=void 0===o?0:o,a=t.y,l=void 0===a?0:a,s=t.img,h=t.shadowColor,c=t.shadowBlur,d=t.width,p=t.height;if(f(s,"String")?n=this.imagePool.getImageSync(s):(d||(d=s.width),p||(p=s.height),n=s),n){g(r,e,!u(h)&&c>0);try{e.drawImage(n,i,l,d,p)}catch(e){}}},e}(),A=function(){function e(){}return e.prototype.render=function(e,t,r,n,o,i){r.getBounds();var a=t.lineWidth,l=t.textAlign,s=t.textBaseline,h=t.lineJoin,c=t.miterLimit,d=t.letterSpacing,p=t.stroke,f=t.fill,y=t.fillOpacity,v=t.strokeOpacity,m=t.opacity,A=t.metrics,x=t.x,b=void 0===x?0:x,S=t.y,B=void 0===S?0:S,M=t.dx,w=t.dy,R=t.shadowColor,O=t.shadowBlur,E=A.lines,C=A.height,T=A.lineHeight,P=A.lineMetrics;e.font=A.font,e.lineWidth=a,e.textAlign="middle"===l?"center":l;var N=s;i.enableCSSParsing||"alphabetic"!==N||(N="bottom"),e.lineJoin=h,u(c)||(e.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)),e.textBaseline=N,g(r,e,!u(R)&&O>0);for(var F=0;E.length>F;F++){var D=a/2+k;L+=T,u(p)||p.isNone||!a||this.drawLetterSpacing(e,E[F],P[F],l,D,L,d,y,v,m,!0),u(f)||this.drawLetterSpacing(e,E[F],P[F],l,D,L,d,y,v,m)}},e.prototype.drawLetterSpacing=function(e,t,r,n,o,i,a,l,s,h,c){if(void 0===c&&(c=!1),0!==a){var d=e.textAlign;e.textAlign="left";var u=o;"center"===n||"middle"===n?u=o-r.width/2:"right"!==n&&"end"!==n||(u=o-r.width);for(var p=Array.from(t),f=e.measureText(t).width,y=0,v=0;p.length>v;++v){var g=p[v];c?this.strokeText(e,g,u,i,s):this.fillText(e,g,u,i,l,h),u+=f-(y=e.measureText(t.substring(v+1)).width)+a,f=y}e.textAlign=d}else c?this.strokeText(e,t,o,i,s):this.fillText(e,t,o,i,l,h)},e.prototype.fillText=function(e,t,r,n,o,i){var a,l=!u(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o*i),e.fillText(t,r,n),l&&(e.globalAlpha=a)},e.prototype.strokeText=function(e,t,r,n,o){var i,a=!u(o)&&1!==o;a&&(i=e.globalAlpha,e.globalAlpha=o),e.strokeText(t,r,n),a&&(e.globalAlpha=i)},e}(),x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),S=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),O=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="canvas-renderer",r}return n(r,e),r.prototype.init=function(){var e,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new v(n),a=((e={})[t.Shape.CIRCLE]=i,e[t.Shape.ELLIPSE]=i,e[t.Shape.RECT]=i,e[t.Shape.IMAGE]=new m(n),e[t.Shape.TEXT]=new A,e[t.Shape.LINE]=i,e[t.Shape.POLYLINE]=i,e[t.Shape.POLYGON]=i,e[t.Shape.PATH]=i,e[t.Shape.GROUP]=void 0,e[t.Shape.HTML]=void 0,e[t.Shape.MESH]=void 0,e);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}(t.AbstractRendererPlugin);e.CircleRenderer=b,e.EllipseRenderer=S,e.ImageRenderer=m,e.LineRenderer=B,e.PathRenderer=R,e.Plugin=O,e.PolygonRenderer=w,e.PolylineRenderer=M,e.RectRenderer=x,e.TextRenderer=A}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}var a="undefined"!=typeof Float32Array?Float32Array:Array;function l(){var e=new a(16);return a!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function s(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function h(e,t,r){var n=t[0],o=t[1],i=t[2],a=t[3],l=t[4],s=t[5],h=t[6],c=t[7],d=t[8],p=t[9],u=t[10],f=t[11],y=t[12],v=t[13],g=t[14],m=t[15],A=r[0],x=r[1],b=r[2],S=r[3];return e[0]=A*n+x*l+b*d+S*y,e[1]=A*o+x*s+b*p+S*v,e[2]=A*i+x*h+b*u+S*g,e[3]=A*a+x*c+b*f+S*m,e[4]=(A=r[4])*n+(x=r[5])*l+(b=r[6])*d+(S=r[7])*y,e[5]=A*o+x*s+b*p+S*v,e[6]=A*i+x*h+b*u+S*g,e[7]=A*a+x*c+b*f+S*m,e[8]=(A=r[8])*n+(x=r[9])*l+(b=r[10])*d+(S=r[11])*y,e[9]=A*o+x*s+b*p+S*v,e[10]=A*i+x*h+b*u+S*g,e[11]=A*a+x*c+b*f+S*m,e[12]=(A=r[12])*n+(x=r[13])*l+(b=r[14])*d+(S=r[15])*y,e[13]=A*o+x*s+b*p+S*v,e[14]=A*i+x*h+b*u+S*g,e[15]=A*a+x*c+b*f+S*m,e}function c(){var e=new a(3);return a!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function d(e,t,r){var n=t[0],o=t[1],i=t[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return e[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,e[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),c();var p=function(e){return null==e},u={}.toString,f=function(e,t){return u.call(e)==="[object "+t+"]"},y=function(){function e(e){this.canvasRendererPluginOptions=e,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreenLastFrame=!1,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 e.prototype.apply=function(r,n){var o=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(e){var t=e.target.rBushNode;t.aabb&&o.removedRBushNodeAABBs.push(t.aabb)},v=function(e){var t=e.target.rBushNode;t.aabb&&o.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,(function(){f.addEventListener(t.ElementEvent.UNMOUNTED,y),f.addEventListener(t.ElementEvent.CULLED,v);var e=u.getDPR(),r=a.width,n=a.height,i=u.getContext();o.clearRect(i,0,0,r*e,n*e,a.background)})),s.hooks.destroy.tap(e.tag,(function(){f.removeEventListener(t.ElementEvent.UNMOUNTED,y),f.removeEventListener(t.ElementEvent.CULLED,v),o.renderQueue=[],o.removedRBushNodeAABBs=[],o.restoreStack=[]})),s.hooks.beginFrame.tap(e.tag,(function(){var e=u.getContext(),t=u.getDPR(),r=a.width,n=a.height,i=o.canvasRendererPluginOptions,l=i.dirtyObjectNumThreshold,h=i.dirtyObjectRatioThreshold,c=s.getStats(),d=c.rendered,p=d/c.total;o.clearFullScreen=o.clearFullScreenLastFrame||s.disableDirtyRectangleRendering()||d>l&&p>h,e&&(e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),o.clearFullScreen&&o.clearRect(e,0,0,r*t,n*t,a.background))}));var g=function(e,t){e.isVisible()&&!e.isCulled()&&o.renderDisplayObject(e,t,o.context,o.restoreStack,n),(e.sortable.sorted||e.childNodes).forEach((function(e){g(e,t)}))};s.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){o.clearFullScreenLastFrame=!1;var e,r,s=u.getContext(),p=u.getDPR();if((e=o.dprMatrix)[0]=(r=[p,p,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,h(o.vpMatrix,o.dprMatrix,l.getOrthoMatrix()),o.clearFullScreen)g(c.root,s);else{var y=o.safeMergeAABB.apply(o,function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;i>o;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([o.mergeDirtyAABBs(o.renderQueue)],i(o.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,o=e.maxX,i=e.maxY,a=new t.AABB;return a.setMinMax([r,n,0],[o,i,0]),a}))),!1));if(o.removedRBushNodeAABBs=[],t.AABB.isEmpty(y))return void(o.renderQueue=[]);var v=o.convertAABB2Rect(y),m=v.x,A=v.y,x=v.width,b=v.height,S=d(o.vec3a,[m,A,0],o.vpMatrix),B=d(o.vec3b,[m+x,A,0],o.vpMatrix),M=d(o.vec3c,[m,A+b,0],o.vpMatrix),w=d(o.vec3d,[m+x,A+b,0],o.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(),o.clearRect(s,T,P,N,L,a.background),s.beginPath(),s.rect(T,P,N,L),s.clip(),s.setTransform(o.vpMatrix[0],o.vpMatrix[1],o.vpMatrix[4],o.vpMatrix[5],o.vpMatrix[12],o.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:P,width:N,height:L}})),o.searchDirtyObjects(y).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&o.renderDisplayObject(e,s,o.context,o.restoreStack,n)})),s.restore(),o.renderQueue.forEach((function(e){o.saveDirtyAABB(e)})),o.renderQueue=[]}o.restoreStack.forEach((function(){s.restore()})),o.restoreStack=[]}else o.clearFullScreenLastFrame=!0})),s.hooks.render.tap(e.tag,(function(e){o.clearFullScreen||o.renderQueue.push(e)}))},e.prototype.clearRect=function(e,t,r,n,o,i){e.clearRect(t,r,n,o),i&&(e.fillStyle=i,e.fillRect(t,r,n,o))},e.prototype.renderDisplayObject=function(e,r,n,o,i){var a=e.nodeName,l=o[o.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),o.pop());var s=this.context.styleRendererFactory[a],h=this.pathGeneratorFactory[a],c=e.parsedStyle.clipPath;if(c){this.applyWorldTransform(r,c);var d=this.pathGeneratorFactory[c.nodeName];d&&(r.save(),o.push(e),r.beginPath(),d(r,c.parsedStyle),r.closePath(),r.clip())}s&&(this.applyWorldTransform(r,e),r.save(),this.applyAttributesToContext(r,e)),h&&(r.beginPath(),h(r,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,e.parsedStyle,e,n,this,i),r.restore()),e.renderable.dirty=!1},e.prototype.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),o=Math.floor(t[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},e.prototype.mergeDirtyAABBs=function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r},e.prototype.searchDirtyObjects=function(e){var t=i(e.getMin(),2),r=t[0],n=t[1],o=i(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:o[0],maxY:o[1]}).map((function(e){return e.displayObject}))},e.prototype.saveDirtyAABB=function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},e.prototype.applyAttributesToContext=function(e,t){var r=t.parsedStyle,n=r.stroke,o=r.fill,i=r.opacity,a=r.lineDash,l=r.lineDashOffset;a&&e.setLineDash(a),p(l)||(e.lineDashOffset=l),p(i)||(e.globalAlpha*=i),p(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),p(o)||Array.isArray(o)||o.isNone||(e.fillStyle=t.attributes.fill)},e.prototype.applyWorldTransform=function(e,t,r){r?(s(this.tmpMat4,t.getLocalTransform()),h(this.tmpMat4,r,this.tmpMat4),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(s(this.tmpMat4,t.getWorldTransform()),h(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},e.prototype.safeMergeAABB=function(){for(var e=[],r=0;arguments.length>r;r++)e[r]=arguments[r];var n=new t.AABB;return e.forEach((function(e){n.add(e)})),n},e.tag="CanvasRenderer",e}(),v=function(){function e(e){this.imagePool=e}return e.prototype.render=function(e,r,n,o,i,a){var l=r.fill,s=r.fillRule,h=r.opacity,c=r.fillOpacity,d=r.stroke,u=r.strokeOpacity,f=r.lineWidth,y=void 0===f?1:f,v=r.lineCap,m=r.lineJoin,A=r.shadowType,x=r.shadowColor,b=r.shadowBlur,S=r.filter,B=r.miterLimit,M=!p(l)&&!l.isNone,w=!p(d)&&!d.isNone&&y>0,R=0===(null==l?void 0:l.alpha),O=!(!S||!S.length),E=!p(x)&&b>0,C=n.nodeName,T="inner"===A,P=w&&E&&(C===t.Shape.PATH||C===t.Shape.LINE||C===t.Shape.POLYLINE||R||T);M&&(e.globalAlpha=h*c,P||g(n,e,E),this.fill(e,n,l,s,o,i,a),P||this.clearShadowAndFilter(e,O,E)),w&&(e.globalAlpha=h*u,e.lineWidth=y,p(B)||(e.miterLimit=B),p(v)||(e.lineCap=v),p(m)||(e.lineJoin=m),P&&(T&&(e.globalCompositeOperation="source-atop"),g(n,e,!0),T&&(this.stroke(e,n,d,o,i,a),e.globalCompositeOperation="source-over",this.clearShadowAndFilter(e,O,!0))),this.stroke(e,n,d,o,i,a))},e.prototype.clearShadowAndFilter=function(e,t,r){if(r&&(e.shadowColor="transparent",e.shadowBlur=0),t){var n=e.filter;!p(n)&&n.indexOf("drop-shadow")>-1&&(e.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},e.prototype.fill=function(e,r,n,o,i,a,l){var s=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=s.getColor(t,r,e),o?e.fill(o):e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,i,a,l)),o?e.fill(o):e.fill())},e.prototype.stroke=function(e,r,n,o,i,a){var l=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=l.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,o,i,a)),e.stroke())},e.prototype.getPattern=function(e,t,r,n,o,i){var a,l;if("rect"===e.image.nodeName){var s=e.image.parsedStyle,h=s.width,c=s.height;l=n.contextService.getDPR();var d=n.config.offscreenCanvas;(a=i.offscreenCanvasCreator.getOrCreateCanvas(d)).width=h*l,a.height=c*l;var p=i.offscreenCanvasCreator.getOrCreateContext(d),u=[];e.image.forEach((function(e){o.renderDisplayObject(e,p,n,u,i)})),u.forEach((function(){p.restore()}))}return this.imagePool.getOrCreatePatternSync(e,r,a,l,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))},e.prototype.getColor=function(e,r,n){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.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];i=this.imagePool.getOrCreateGradient(o(o({type:e.type},e.value),{min:h,width:l,height:s}),n)}return i},e}();function g(e,t,r){var n=e.parsedStyle,o=n.filter,i=n.shadowColor,a=n.shadowBlur,l=n.shadowOffsetX,s=n.shadowOffsetY;o&&o.length&&(t.filter=e.style.filter),r&&(t.shadowColor=""+i,t.shadowBlur=a||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}var m=function(){function e(e){this.imagePool=e}return e.prototype.render=function(e,t,r){var n,o=t.x,i=void 0===o?0:o,a=t.y,l=void 0===a?0:a,s=t.src,h=t.shadowColor,c=t.shadowBlur,d=t.width,u=t.height;if(f(s,"String")?n=this.imagePool.getImageSync(s):(d||(d=s.width),u||(u=s.height),n=s),n){g(r,e,!p(h)&&c>0);try{e.drawImage(n,i,l,d,u)}catch(e){}}},e}(),A=function(){function e(){}return e.prototype.render=function(e,t,r,n,o,i){r.getBounds();var a=t.lineWidth,l=void 0===a?1:a,s=t.textAlign,h=void 0===s?"start":s,c=t.textBaseline,d=void 0===c?"alphabetic":c,u=t.lineJoin,f=void 0===u?"miter":u,y=t.miterLimit,v=void 0===y?10:y,m=t.letterSpacing,A=void 0===m?0:m,x=t.stroke,b=t.fill,S=t.fillOpacity,B=void 0===S?1:S,M=t.strokeOpacity,w=void 0===M?1:M,R=t.opacity,O=void 0===R?1:R,E=t.metrics,C=t.x,T=void 0===C?0:C,P=t.y,N=void 0===P?0:P,L=t.dx,k=t.dy,F=t.shadowColor,D=t.shadowBlur,G=E.lines,j=E.height,I=E.lineHeight,Y=E.lineMetrics;e.font=E.font,e.lineWidth=l,e.textAlign="middle"===h?"center":h;var _=d;i.enableCSSParsing||"alphabetic"!==_||(_="bottom"),e.lineJoin=f,p(v)||(e.miterLimit=v);var U=N;"middle"===d?U+=-j/2-I/2:"bottom"===d||"alphabetic"===d||"ideographic"===d?U+=-j:"top"!==d&&"hanging"!==d||(U+=-I);var W=T+(L||0);U+=k||0,1===G.length&&("bottom"===_?(_="middle",U-=.5*j):"top"===_&&(_="middle",U+=.5*j)),e.textBaseline=_,g(r,e,!p(F)&&D>0);for(var Q=0;G.length>Q;Q++){var X=l/2+W;U+=I,p(x)||x.isNone||!l||this.drawLetterSpacing(e,G[Q],Y[Q],h,X,U,A,B,w,O,!0),p(b)||this.drawLetterSpacing(e,G[Q],Y[Q],h,X,U,A,B,w,O)}},e.prototype.drawLetterSpacing=function(e,t,r,n,o,i,a,l,s,h,c){if(void 0===c&&(c=!1),0!==a){var d=e.textAlign;e.textAlign="left";var p=o;"center"===n||"middle"===n?p=o-r.width/2:"right"!==n&&"end"!==n||(p=o-r.width);for(var u=Array.from(t),f=e.measureText(t).width,y=0,v=0;u.length>v;++v){var g=u[v];c?this.strokeText(e,g,p,i,s):this.fillText(e,g,p,i,l,h),p+=f-(y=e.measureText(t.substring(v+1)).width)+a,f=y}e.textAlign=d}else c?this.strokeText(e,t,o,i,s):this.fillText(e,t,o,i,l,h)},e.prototype.fillText=function(e,t,r,n,o,i){var a,l=!p(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o*i),e.fillText(t,r,n),l&&(e.globalAlpha=a)},e.prototype.strokeText=function(e,t,r,n,o){var i,a=!p(o)&&1!==o;a&&(i=e.globalAlpha,e.globalAlpha=o),e.strokeText(t,r,n),a&&(e.globalAlpha=i)},e}(),x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),S=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(v),O=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="canvas-renderer",r}return n(r,e),r.prototype.init=function(){var e,r=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new v(n),a=((e={})[t.Shape.CIRCLE]=i,e[t.Shape.ELLIPSE]=i,e[t.Shape.RECT]=i,e[t.Shape.IMAGE]=new m(n),e[t.Shape.TEXT]=new A,e[t.Shape.LINE]=i,e[t.Shape.POLYLINE]=i,e[t.Shape.POLYGON]=i,e[t.Shape.PATH]=i,e[t.Shape.GROUP]=void 0,e[t.Shape.HTML]=void 0,e[t.Shape.MESH]=void 0,e);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}(t.AbstractRendererPlugin);e.CircleRenderer=b,e.EllipseRenderer=S,e.ImageRenderer=m,e.LineRenderer=B,e.PathRenderer=R,e.Plugin=O,e.PolygonRenderer=w,e.PolylineRenderer=M,e.RectRenderer=x,e.TextRenderer=A}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@antv/g-plugin-canvas-renderer",
"version": "1.10.0-next.12",
"version": "1.10.0-next.13",
"description": "A G plugin of renderer implementation with Canvas2D API",

@@ -38,5 +38,5 @@ "keywords": [

"tslib": "^2.5.3",
"@antv/g-plugin-canvas-path-generator": "1.3.22-next.12",
"@antv/g-lite": "1.3.0-next.12",
"@antv/g-plugin-image-loader": "1.4.0-next.12",
"@antv/g-plugin-image-loader": "1.4.0-next.13",
"@antv/g-lite": "1.3.0-next.13",
"@antv/g-plugin-canvas-path-generator": "1.3.22-next.13",
"@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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc