@antv/g-canvas 1.6.0-alpha.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -400,6 +400,21 @@
400
400
  return _setPrototypeOf(o, p);
401
401
  }
402
402
 
403
+ function _inheritsLoose$1(subClass, superClass) {
404
+ subClass.prototype = Object.create(superClass.prototype);
405
+ subClass.prototype.constructor = subClass;
406
+
407
+ _setPrototypeOf$1(subClass, superClass);
408
+ }
409
+
410
+ function _setPrototypeOf$1(o, p) {
411
+ _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
412
+ o.__proto__ = p;
413
+ return o;
414
+ };
415
+ return _setPrototypeOf$1(o, p);
416
+ }
417
+
403
418
  var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
404
419
  var PathGenerator = g.Syringe.defineToken('PathGenerator');
405
420
 
@@ -637,23 +652,33 @@
637
652
  });
638
653
  });
639
654
 
640
- var Plugin = /*#__PURE__*/function () {
655
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
656
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
657
+
641
658
  function Plugin() {
642
- this.name = 'canvas-path-generator';
659
+ var _this;
660
+
661
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
662
+ args[_key] = arguments[_key];
663
+ }
664
+
665
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
666
+ _this.name = 'canvas-path-generator';
667
+ return _this;
643
668
  }
644
669
 
645
670
  var _proto = Plugin.prototype;
646
671
 
647
- _proto.init = function init(container) {
648
- container.load(containerModule, true);
672
+ _proto.init = function init() {
673
+ this.container.load(containerModule, true);
649
674
  };
650
675
 
651
- _proto.destroy = function destroy(container) {
652
- container.unload(containerModule);
676
+ _proto.destroy = function destroy() {
677
+ this.container.unload(containerModule);
653
678
  };
654
679
 
655
680
  return Plugin;
656
- }();
681
+ }(g.AbstractRendererPlugin);
657
682
 
658
683
  var index_esm = /*#__PURE__*/Object.freeze({
659
684
  __proto__: null,
@@ -1073,6 +1098,21 @@
1073
1098
  });
1074
1099
  };
1075
1100
  }
1101
+
1102
+ function _inheritsLoose$2(subClass, superClass) {
1103
+ subClass.prototype = Object.create(superClass.prototype);
1104
+ subClass.prototype.constructor = subClass;
1105
+
1106
+ _setPrototypeOf$2(subClass, superClass);
1107
+ }
1108
+
1109
+ function _setPrototypeOf$2(o, p) {
1110
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1111
+ o.__proto__ = p;
1112
+ return o;
1113
+ };
1114
+ return _setPrototypeOf$2(o, p);
1115
+ }
1076
1116
  /**
1077
1117
  * Common utilities
1078
1118
  * @module glMatrix
@@ -2524,192 +2564,39 @@
2524
2564
  register(CanvasPickerPlugin);
2525
2565
  });
2526
2566
 
2527
- var Plugin$1 = /*#__PURE__*/function () {
2567
+ var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
2568
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
2569
+
2528
2570
  function Plugin() {
2529
- this.name = 'canvas-picker';
2571
+ var _this;
2572
+
2573
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2574
+ args[_key] = arguments[_key];
2575
+ }
2576
+
2577
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
2578
+ _this.name = 'canvas-picker';
2579
+ return _this;
2530
2580
  }
2531
2581
 
2532
2582
  var _proto = Plugin.prototype;
2533
2583
 
2534
- _proto.init = function init(container) {
2535
- container.load(containerModule$1, true);
2584
+ _proto.init = function init() {
2585
+ this.container.load(containerModule$1, true);
2536
2586
  };
2537
2587
 
2538
- _proto.destroy = function destroy(container) {
2539
- container.unload(containerModule$1);
2588
+ _proto.destroy = function destroy() {
2589
+ this.container.unload(containerModule$1);
2540
2590
  };
2541
2591
 
2542
2592
  return Plugin;
2543
- }();
2593
+ }(g.AbstractRendererPlugin);
2544
2594
 
2545
2595
  var index_esm$1 = /*#__PURE__*/Object.freeze({
2546
2596
  __proto__: null,
2547
2597
  Plugin: Plugin$1
2548
2598
  });
2549
2599
 
2550
- var ImagePool = /*#__PURE__*/function () {
2551
- function ImagePool() {
2552
- this.imageCache = {};
2553
- this.gradientCache = {};
2554
- this.patternCache = {};
2555
- this.canvasConfig = void 0;
2556
- }
2557
-
2558
- var _proto = ImagePool.prototype;
2559
-
2560
- _proto.getImageSync = function getImageSync(src, callback) {
2561
- if (!this.imageCache[src]) {
2562
- this.getOrCreateImage(src).then(function () {
2563
- if (callback) {
2564
- callback();
2565
- }
2566
- });
2567
- }
2568
-
2569
- return this.imageCache[src];
2570
- };
2571
-
2572
- _proto.getOrCreateImage = function getOrCreateImage(src) {
2573
- var _this = this;
2574
-
2575
- if (this.imageCache[src]) {
2576
- return Promise.resolve(this.imageCache[src]);
2577
- } // @see https://github.com/antvis/g/issues/938
2578
-
2579
-
2580
- var createImage = this.canvasConfig.createImage;
2581
- return new Promise(function (resolve, reject) {
2582
- var image;
2583
-
2584
- if (createImage) {
2585
- image = createImage(src);
2586
- } else if (g.isBrowser) {
2587
- image = new window.Image();
2588
- }
2589
-
2590
- if (image) {
2591
- image.onload = function () {
2592
- resolve(image);
2593
- };
2594
-
2595
- image.onerror = function (ev) {
2596
- reject(ev);
2597
- };
2598
-
2599
- image.crossOrigin = 'Anonymous';
2600
- image.src = src;
2601
- _this.imageCache[src] = image;
2602
- }
2603
- });
2604
- };
2605
-
2606
- _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
2607
- var patternKey = this.generatePatternKey(pattern);
2608
-
2609
- if (patternKey && this.patternCache[patternKey]) {
2610
- return this.patternCache[patternKey];
2611
- }
2612
-
2613
- var image = pattern.image,
2614
- repetition = pattern.repetition;
2615
- var src; // Image URL
2616
-
2617
- if (g.isString(image)) {
2618
- src = this.getImageSync(image, callback);
2619
- } else {
2620
- src = image;
2621
- } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
2622
-
2623
-
2624
- var canvasPattern = src && context.createPattern(src, repetition);
2625
-
2626
- if (patternKey && canvasPattern) {
2627
- this.patternCache[patternKey] = canvasPattern;
2628
- }
2629
-
2630
- return canvasPattern;
2631
- };
2632
-
2633
- _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2634
- var key = this.generateGradientKey(params); // @ts-ignore
2635
-
2636
- var type = params.type,
2637
- steps = params.steps,
2638
- width = params.width,
2639
- height = params.height,
2640
- angle = params.angle,
2641
- cx = params.cx,
2642
- cy = params.cy;
2643
-
2644
- if (this.gradientCache[key]) {
2645
- return this.gradientCache[key];
2646
- }
2647
-
2648
- var gradient = null;
2649
-
2650
- if (type === g.GradientType.LinearGradient) {
2651
- var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
2652
- x1 = _computeLinearGradien.x1,
2653
- y1 = _computeLinearGradien.y1,
2654
- x2 = _computeLinearGradien.x2,
2655
- y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2656
-
2657
-
2658
- gradient = context.createLinearGradient(x1, y1, x2, y2);
2659
- } else if (type === g.GradientType.RadialGradient) {
2660
- var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
2661
- x = _computeRadialGradien.x,
2662
- y = _computeRadialGradien.y,
2663
- r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2664
-
2665
-
2666
- gradient = context.createRadialGradient(x, y, 0, x, y, r);
2667
- }
2668
-
2669
- if (gradient) {
2670
- steps.forEach(function (_ref) {
2671
- var _gradient;
2672
-
2673
- var offset = _ref[0],
2674
- color = _ref[1];
2675
- (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
2676
- });
2677
- this.gradientCache[key] = gradient;
2678
- }
2679
-
2680
- return this.gradientCache[key];
2681
- };
2682
-
2683
- _proto.generateGradientKey = function generateGradientKey(params) {
2684
- // @ts-ignore
2685
- var type = params.type,
2686
- width = params.width,
2687
- height = params.height,
2688
- steps = params.steps,
2689
- angle = params.angle,
2690
- cx = params.cx,
2691
- cy = params.cy;
2692
- return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2693
- return step.join('');
2694
- }).join('-');
2695
- };
2696
-
2697
- _proto.generatePatternKey = function generatePatternKey(pattern) {
2698
- var image = pattern.image,
2699
- repetition = pattern.repetition; // only generate cache for Image
2700
-
2701
- if (g.isString(image)) {
2702
- return "pattern-" + image + "-" + repetition;
2703
- }
2704
- };
2705
-
2706
- return ImagePool;
2707
- }();
2708
-
2709
- __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
2710
-
2711
- ImagePool = __decorate([g.singleton()], ImagePool);
2712
-
2713
2600
  function _regeneratorRuntime$2() {
2714
2601
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2715
2602
  _regeneratorRuntime$2 = function _regeneratorRuntime() {
@@ -3096,6 +2983,184 @@
3096
2983
  };
3097
2984
  }
3098
2985
 
2986
+ function _inheritsLoose$3(subClass, superClass) {
2987
+ subClass.prototype = Object.create(superClass.prototype);
2988
+ subClass.prototype.constructor = subClass;
2989
+
2990
+ _setPrototypeOf$3(subClass, superClass);
2991
+ }
2992
+
2993
+ function _setPrototypeOf$3(o, p) {
2994
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2995
+ o.__proto__ = p;
2996
+ return o;
2997
+ };
2998
+ return _setPrototypeOf$3(o, p);
2999
+ }
3000
+
3001
+ var ImagePool = /*#__PURE__*/function () {
3002
+ function ImagePool() {
3003
+ this.imageCache = {};
3004
+ this.gradientCache = {};
3005
+ this.patternCache = {};
3006
+ this.canvasConfig = void 0;
3007
+ }
3008
+
3009
+ var _proto = ImagePool.prototype;
3010
+
3011
+ _proto.getImageSync = function getImageSync(src, callback) {
3012
+ if (!this.imageCache[src]) {
3013
+ this.getOrCreateImage(src).then(function () {
3014
+ if (callback) {
3015
+ callback();
3016
+ }
3017
+ });
3018
+ }
3019
+
3020
+ return this.imageCache[src];
3021
+ };
3022
+
3023
+ _proto.getOrCreateImage = function getOrCreateImage(src) {
3024
+ var _this = this;
3025
+
3026
+ if (this.imageCache[src]) {
3027
+ return Promise.resolve(this.imageCache[src]);
3028
+ } // @see https://github.com/antvis/g/issues/938
3029
+
3030
+
3031
+ var createImage = this.canvasConfig.createImage;
3032
+ return new Promise(function (resolve, reject) {
3033
+ var image;
3034
+
3035
+ if (createImage) {
3036
+ image = createImage(src);
3037
+ } else if (g.isBrowser) {
3038
+ image = new window.Image();
3039
+ }
3040
+
3041
+ if (image) {
3042
+ image.onload = function () {
3043
+ resolve(image);
3044
+ };
3045
+
3046
+ image.onerror = function (ev) {
3047
+ reject(ev);
3048
+ };
3049
+
3050
+ image.crossOrigin = 'Anonymous';
3051
+ image.src = src;
3052
+ _this.imageCache[src] = image;
3053
+ }
3054
+ });
3055
+ };
3056
+
3057
+ _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
3058
+ var patternKey = this.generatePatternKey(pattern);
3059
+
3060
+ if (patternKey && this.patternCache[patternKey]) {
3061
+ return this.patternCache[patternKey];
3062
+ }
3063
+
3064
+ var image = pattern.image,
3065
+ repetition = pattern.repetition;
3066
+ var src; // Image URL
3067
+
3068
+ if (g.isString(image)) {
3069
+ src = this.getImageSync(image, callback);
3070
+ } else {
3071
+ src = image;
3072
+ } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
3073
+
3074
+
3075
+ var canvasPattern = src && context.createPattern(src, repetition);
3076
+
3077
+ if (patternKey && canvasPattern) {
3078
+ this.patternCache[patternKey] = canvasPattern;
3079
+ }
3080
+
3081
+ return canvasPattern;
3082
+ };
3083
+
3084
+ _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
3085
+ var key = this.generateGradientKey(params); // @ts-ignore
3086
+
3087
+ var type = params.type,
3088
+ steps = params.steps,
3089
+ width = params.width,
3090
+ height = params.height,
3091
+ angle = params.angle,
3092
+ cx = params.cx,
3093
+ cy = params.cy;
3094
+
3095
+ if (this.gradientCache[key]) {
3096
+ return this.gradientCache[key];
3097
+ }
3098
+
3099
+ var gradient = null;
3100
+
3101
+ if (type === g.GradientType.LinearGradient) {
3102
+ var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
3103
+ x1 = _computeLinearGradien.x1,
3104
+ y1 = _computeLinearGradien.y1,
3105
+ x2 = _computeLinearGradien.x2,
3106
+ y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
3107
+
3108
+
3109
+ gradient = context.createLinearGradient(x1, y1, x2, y2);
3110
+ } else if (type === g.GradientType.RadialGradient) {
3111
+ var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
3112
+ x = _computeRadialGradien.x,
3113
+ y = _computeRadialGradien.y,
3114
+ r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
3115
+
3116
+
3117
+ gradient = context.createRadialGradient(x, y, 0, x, y, r);
3118
+ }
3119
+
3120
+ if (gradient) {
3121
+ steps.forEach(function (_ref) {
3122
+ var _gradient;
3123
+
3124
+ var offset = _ref[0],
3125
+ color = _ref[1];
3126
+ (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
3127
+ });
3128
+ this.gradientCache[key] = gradient;
3129
+ }
3130
+
3131
+ return this.gradientCache[key];
3132
+ };
3133
+
3134
+ _proto.generateGradientKey = function generateGradientKey(params) {
3135
+ // @ts-ignore
3136
+ var type = params.type,
3137
+ width = params.width,
3138
+ height = params.height,
3139
+ steps = params.steps,
3140
+ angle = params.angle,
3141
+ cx = params.cx,
3142
+ cy = params.cy;
3143
+ return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
3144
+ return step.join('');
3145
+ }).join('-');
3146
+ };
3147
+
3148
+ _proto.generatePatternKey = function generatePatternKey(pattern) {
3149
+ var image = pattern.image,
3150
+ repetition = pattern.repetition; // only generate cache for Image
3151
+
3152
+ if (g.isString(image)) {
3153
+ return "pattern-" + image + "-" + repetition;
3154
+ }
3155
+ };
3156
+
3157
+ return ImagePool;
3158
+ }();
3159
+
3160
+ __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
3161
+
3162
+ ImagePool = __decorate([g.singleton()], ImagePool);
3163
+
3099
3164
  var _class$1;
3100
3165
 
3101
3166
  var LoadImagePlugin_1;
@@ -3184,23 +3249,33 @@
3184
3249
  register(LoadImagePlugin);
3185
3250
  });
3186
3251
 
3187
- var Plugin$2 = /*#__PURE__*/function () {
3252
+ var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
3253
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
3254
+
3188
3255
  function Plugin() {
3189
- this.name = 'image-loader';
3256
+ var _this;
3257
+
3258
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3259
+ args[_key] = arguments[_key];
3260
+ }
3261
+
3262
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
3263
+ _this.name = 'image-loader';
3264
+ return _this;
3190
3265
  }
3191
3266
 
3192
3267
  var _proto = Plugin.prototype;
3193
3268
 
3194
- _proto.init = function init(container) {
3195
- container.load(containerModule$2, true);
3269
+ _proto.init = function init() {
3270
+ this.container.load(containerModule$2, true);
3196
3271
  };
3197
3272
 
3198
- _proto.destroy = function destroy(container) {
3199
- container.unload(containerModule$2);
3273
+ _proto.destroy = function destroy() {
3274
+ this.container.unload(containerModule$2);
3200
3275
  };
3201
3276
 
3202
3277
  return Plugin;
3203
- }();
3278
+ }(g.AbstractRendererPlugin);
3204
3279
 
3205
3280
  var index_esm$2 = /*#__PURE__*/Object.freeze({
3206
3281
  __proto__: null,
@@ -3611,19 +3686,19 @@
3611
3686
  return _extends.apply(this, arguments);
3612
3687
  }
3613
3688
 
3614
- function _inheritsLoose$1(subClass, superClass) {
3689
+ function _inheritsLoose$4(subClass, superClass) {
3615
3690
  subClass.prototype = Object.create(superClass.prototype);
3616
3691
  subClass.prototype.constructor = subClass;
3617
3692
 
3618
- _setPrototypeOf$1(subClass, superClass);
3693
+ _setPrototypeOf$4(subClass, superClass);
3619
3694
  }
3620
3695
 
3621
- function _setPrototypeOf$1(o, p) {
3622
- _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3696
+ function _setPrototypeOf$4(o, p) {
3697
+ _setPrototypeOf$4 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3623
3698
  o.__proto__ = p;
3624
3699
  return o;
3625
3700
  };
3626
- return _setPrototypeOf$1(o, p);
3701
+ return _setPrototypeOf$4(o, p);
3627
3702
  }
3628
3703
  /**
3629
3704
  * Common utilities
@@ -3895,6 +3970,28 @@
3895
3970
  out[2] = z;
3896
3971
  return out;
3897
3972
  }
3973
+ /**
3974
+ * Transforms the vec3 with a mat4.
3975
+ * 4th vector component is implicitly '1'
3976
+ *
3977
+ * @param {vec3} out the receiving vector
3978
+ * @param {ReadonlyVec3} a the vector to transform
3979
+ * @param {ReadonlyMat4} m matrix to transform with
3980
+ * @returns {vec3} out
3981
+ */
3982
+
3983
+
3984
+ function transformMat4$1(out, a, m) {
3985
+ var x = a[0],
3986
+ y = a[1],
3987
+ z = a[2];
3988
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
3989
+ w = w || 1.0;
3990
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
3991
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
3992
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
3993
+ return out;
3994
+ }
3898
3995
  /**
3899
3996
  * Perform some operation over an array of vec3s.
3900
3997
  *
@@ -4345,7 +4442,7 @@
4345
4442
  DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
4346
4443
 
4347
4444
  var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4348
- _inheritsLoose$1(RectRenderer, _DefaultRenderer);
4445
+ _inheritsLoose$4(RectRenderer, _DefaultRenderer);
4349
4446
 
4350
4447
  function RectRenderer() {
4351
4448
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4359,7 +4456,7 @@
4359
4456
  })], RectRenderer);
4360
4457
 
4361
4458
  var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4362
- _inheritsLoose$1(CircleRenderer, _DefaultRenderer);
4459
+ _inheritsLoose$4(CircleRenderer, _DefaultRenderer);
4363
4460
 
4364
4461
  function CircleRenderer() {
4365
4462
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4373,7 +4470,7 @@
4373
4470
  })], CircleRenderer);
4374
4471
 
4375
4472
  var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4376
- _inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
4473
+ _inheritsLoose$4(EllipseRenderer, _DefaultRenderer);
4377
4474
 
4378
4475
  function EllipseRenderer() {
4379
4476
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4387,7 +4484,7 @@
4387
4484
  })], EllipseRenderer);
4388
4485
 
4389
4486
  var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4390
- _inheritsLoose$1(LineRenderer, _DefaultRenderer);
4487
+ _inheritsLoose$4(LineRenderer, _DefaultRenderer);
4391
4488
 
4392
4489
  function LineRenderer() {
4393
4490
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4401,7 +4498,7 @@
4401
4498
  })], LineRenderer);
4402
4499
 
4403
4500
  var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4404
- _inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
4501
+ _inheritsLoose$4(PolylineRenderer, _DefaultRenderer);
4405
4502
 
4406
4503
  function PolylineRenderer() {
4407
4504
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4415,7 +4512,7 @@
4415
4512
  })], PolylineRenderer);
4416
4513
 
4417
4514
  var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4418
- _inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
4515
+ _inheritsLoose$4(PolygonRenderer, _DefaultRenderer);
4419
4516
 
4420
4517
  function PolygonRenderer() {
4421
4518
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4429,7 +4526,7 @@
4429
4526
  })], PolygonRenderer);
4430
4527
 
4431
4528
  var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4432
- _inheritsLoose$1(PathRenderer, _DefaultRenderer);
4529
+ _inheritsLoose$4(PathRenderer, _DefaultRenderer);
4433
4530
 
4434
4531
  function PathRenderer() {
4435
4532
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4557,9 +4654,9 @@
4557
4654
  _this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > dirtyObjectNumThreshold && ratio > dirtyObjectRatioThreshold;
4558
4655
 
4559
4656
  if (context) {
4560
- if (_this.clearFullScreen) {
4561
- context.resetTransform();
4657
+ context.resetTransform();
4562
4658
 
4659
+ if (_this.clearFullScreen) {
4563
4660
  _this.clearRect(context, 0, 0, width * dpr, height * dpr);
4564
4661
  }
4565
4662
  }
@@ -4604,16 +4701,22 @@
4604
4701
  var x = dirtyRect.x,
4605
4702
  y = dirtyRect.y,
4606
4703
  width = dirtyRect.width,
4607
- height = dirtyRect.height; // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4608
-
4609
- context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
4704
+ height = dirtyRect.height;
4705
+ var tl = transformMat4$1(_this.tmpVec3, fromValues$1(x, y, 0), _this.vpMatrix);
4706
+ var br = transformMat4$1(create$1$1(), fromValues$1(x + width, y + height, 0), _this.vpMatrix);
4707
+ var ix = Math.floor(tl[0]);
4708
+ var iy = Math.floor(tl[1]);
4709
+ var iwidth = Math.ceil(br[0] - tl[0]);
4710
+ var iheight = Math.ceil(br[1] - tl[1]);
4610
4711
  context.save();
4611
4712
 
4612
- _this.clearRect(context, x, y, width, height);
4713
+ _this.clearRect(context, ix, iy, iwidth, iheight);
4613
4714
 
4614
4715
  context.beginPath();
4615
- context.rect(x, y, width, height);
4616
- context.clip(); // draw dirty rectangle
4716
+ context.rect(ix, iy, iwidth, iheight);
4717
+ context.clip(); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4718
+
4719
+ context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]); // draw dirty rectangle
4617
4720
 
4618
4721
  var _this$canvasConfig$re = _this.canvasConfig.renderer.getConfig(),
4619
4722
  enableDirtyRectangleRenderingDebug = _this$canvasConfig$re.enableDirtyRectangleRenderingDebug;
@@ -4664,6 +4767,7 @@
4664
4767
  };
4665
4768
 
4666
4769
  _proto.clearRect = function clearRect(context, x, y, width, height) {
4770
+ // clearRect is faster than fillRect @see https://stackoverflow.com/a/30830253
4667
4771
  context.clearRect(x, y, width, height);
4668
4772
  var background = this.canvasConfig.background;
4669
4773
 
@@ -4777,7 +4881,7 @@
4777
4881
 
4778
4882
  _proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
4779
4883
  // merge into a big AABB
4780
- // TODO: skip descendant if ancestor is caculated
4884
+ // TODO: skip descendant if ancestor is caculated, but compareNodePosition is really slow
4781
4885
  var aabb = new g.AABB();
4782
4886
  dirtyObjects.forEach(function (object) {
4783
4887
  var renderBounds = object.getRenderBounds();
@@ -4993,36 +5097,42 @@
4993
5097
  register(CanvasRendererPlugin);
4994
5098
  });
4995
5099
 
4996
- var Plugin$3 = /*#__PURE__*/function () {
5100
+ var Plugin$3 = /*#__PURE__*/function (_AbstractRendererPlug) {
5101
+ _inheritsLoose$4(Plugin, _AbstractRendererPlug);
5102
+
4997
5103
  function Plugin(options) {
5104
+ var _this;
5105
+
4998
5106
  if (options === void 0) {
4999
5107
  options = {};
5000
5108
  }
5001
5109
 
5002
- this.options = void 0;
5003
- this.name = 'canvas-renderer';
5004
- this.options = options;
5110
+ _this = _AbstractRendererPlug.call(this) || this;
5111
+ _this.options = void 0;
5112
+ _this.name = 'canvas-renderer';
5113
+ _this.options = options;
5114
+ return _this;
5005
5115
  }
5006
5116
 
5007
5117
  var _proto = Plugin.prototype;
5008
5118
 
5009
- _proto.init = function init(container) {
5010
- container.register(CanvasRendererPluginOptions, {
5119
+ _proto.init = function init() {
5120
+ this.container.register(CanvasRendererPluginOptions, {
5011
5121
  useValue: _extends({
5012
5122
  dirtyObjectNumThreshold: 500,
5013
5123
  dirtyObjectRatioThreshold: 0.8
5014
5124
  }, this.options)
5015
5125
  });
5016
- container.load(containerModule$3, true);
5126
+ this.container.load(containerModule$3, true);
5017
5127
  };
5018
5128
 
5019
- _proto.destroy = function destroy(container) {
5020
- container.unload(containerModule$3);
5021
- container.remove(CanvasRendererPluginOptions);
5129
+ _proto.destroy = function destroy() {
5130
+ this.container.unload(containerModule$3);
5131
+ this.container.remove(CanvasRendererPluginOptions);
5022
5132
  };
5023
5133
 
5024
5134
  return Plugin;
5025
- }();
5135
+ }(g.AbstractRendererPlugin);
5026
5136
 
5027
5137
  var index_esm$3 = /*#__PURE__*/Object.freeze({
5028
5138
  __proto__: null,
@@ -5434,6 +5544,21 @@
5434
5544
  };
5435
5545
  }
5436
5546
 
5547
+ function _inheritsLoose$5(subClass, superClass) {
5548
+ subClass.prototype = Object.create(superClass.prototype);
5549
+ subClass.prototype.constructor = subClass;
5550
+
5551
+ _setPrototypeOf$5(subClass, superClass);
5552
+ }
5553
+
5554
+ function _setPrototypeOf$5(o, p) {
5555
+ _setPrototypeOf$5 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
5556
+ o.__proto__ = p;
5557
+ return o;
5558
+ };
5559
+ return _setPrototypeOf$5(o, p);
5560
+ }
5561
+
5437
5562
  var _class$3;
5438
5563
 
5439
5564
  var DOMInteractionPlugin_1;
@@ -5600,23 +5725,33 @@
5600
5725
  register(DOMInteractionPlugin);
5601
5726
  });
5602
5727
 
5603
- var Plugin$4 = /*#__PURE__*/function () {
5728
+ var Plugin$4 = /*#__PURE__*/function (_AbstractRendererPlug) {
5729
+ _inheritsLoose$5(Plugin, _AbstractRendererPlug);
5730
+
5604
5731
  function Plugin() {
5605
- this.name = 'dom-interaction';
5732
+ var _this;
5733
+
5734
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5735
+ args[_key] = arguments[_key];
5736
+ }
5737
+
5738
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
5739
+ _this.name = 'dom-interaction';
5740
+ return _this;
5606
5741
  }
5607
5742
 
5608
5743
  var _proto = Plugin.prototype;
5609
5744
 
5610
- _proto.init = function init(container) {
5611
- container.load(containerModule$4, true);
5745
+ _proto.init = function init() {
5746
+ this.container.load(containerModule$4, true);
5612
5747
  };
5613
5748
 
5614
- _proto.destroy = function destroy(container) {
5615
- container.unload(containerModule$4);
5749
+ _proto.destroy = function destroy() {
5750
+ this.container.unload(containerModule$4);
5616
5751
  };
5617
5752
 
5618
5753
  return Plugin;
5619
- }();
5754
+ }(g.AbstractRendererPlugin);
5620
5755
 
5621
5756
  var index_esm$4 = /*#__PURE__*/Object.freeze({
5622
5757
  __proto__: null,
@@ -6009,6 +6144,21 @@
6009
6144
  };
6010
6145
  }
6011
6146
 
6147
+ function _inheritsLoose$6(subClass, superClass) {
6148
+ subClass.prototype = Object.create(superClass.prototype);
6149
+ subClass.prototype.constructor = subClass;
6150
+
6151
+ _setPrototypeOf$6(subClass, superClass);
6152
+ }
6153
+
6154
+ function _setPrototypeOf$6(o, p) {
6155
+ _setPrototypeOf$6 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
6156
+ o.__proto__ = p;
6157
+ return o;
6158
+ };
6159
+ return _setPrototypeOf$6(o, p);
6160
+ }
6161
+
6012
6162
  var _class$4;
6013
6163
 
6014
6164
  var HTMLRenderingPlugin_1;
@@ -6277,23 +6427,33 @@
6277
6427
  register(HTMLRenderingPlugin);
6278
6428
  });
6279
6429
 
6280
- var Plugin$5 = /*#__PURE__*/function () {
6430
+ var Plugin$5 = /*#__PURE__*/function (_AbstractRendererPlug) {
6431
+ _inheritsLoose$6(Plugin, _AbstractRendererPlug);
6432
+
6281
6433
  function Plugin() {
6282
- this.name = 'html-renderer';
6434
+ var _this;
6435
+
6436
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6437
+ args[_key] = arguments[_key];
6438
+ }
6439
+
6440
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6441
+ _this.name = 'html-renderer';
6442
+ return _this;
6283
6443
  }
6284
6444
 
6285
6445
  var _proto = Plugin.prototype;
6286
6446
 
6287
- _proto.init = function init(container) {
6288
- container.load(containerModule$5, true);
6447
+ _proto.init = function init() {
6448
+ this.container.load(containerModule$5, true);
6289
6449
  };
6290
6450
 
6291
- _proto.destroy = function destroy(container) {
6292
- container.unload(containerModule$5);
6451
+ _proto.destroy = function destroy() {
6452
+ this.container.unload(containerModule$5);
6293
6453
  };
6294
6454
 
6295
6455
  return Plugin;
6296
- }();
6456
+ }(g.AbstractRendererPlugin);
6297
6457
 
6298
6458
  var index_esm$5 = /*#__PURE__*/Object.freeze({
6299
6459
  __proto__: null,
@@ -6460,23 +6620,33 @@
6460
6620
  */
6461
6621
  register(Canvas2DContextService);
6462
6622
  });
6463
- var ContextRegisterPlugin = /*#__PURE__*/function () {
6623
+ var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
6624
+ _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
6625
+
6464
6626
  function ContextRegisterPlugin() {
6465
- this.name = 'canvas-context-register';
6627
+ var _this;
6628
+
6629
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6630
+ args[_key] = arguments[_key];
6631
+ }
6632
+
6633
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6634
+ _this.name = 'canvas-context-register';
6635
+ return _this;
6466
6636
  }
6467
6637
 
6468
6638
  var _proto = ContextRegisterPlugin.prototype;
6469
6639
 
6470
- _proto.init = function init(container) {
6471
- container.load(containerModule$6, true);
6640
+ _proto.init = function init() {
6641
+ this.container.load(containerModule$6, true);
6472
6642
  };
6473
6643
 
6474
- _proto.destroy = function destroy(container) {
6475
- container.unload(containerModule$6);
6644
+ _proto.destroy = function destroy() {
6645
+ this.container.unload(containerModule$6);
6476
6646
  };
6477
6647
 
6478
6648
  return ContextRegisterPlugin;
6479
- }();
6649
+ }(g.AbstractRendererPlugin);
6480
6650
 
6481
6651
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
6482
6652
  _inheritsLoose(Renderer, _AbstractRenderer);