@antv/g-canvas 1.2.1 → 1.2.2
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.esm.js +102 -213
- package/dist/index.js +102 -213
- package/dist/index.umd.js +1538 -2330
- package/dist/index.umd.min.js +6 -6
- package/package.json +8 -8
package/dist/index.umd.js
CHANGED
|
@@ -349,16 +349,6 @@
|
|
|
349
349
|
}, exports;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
function _typeof(obj) {
|
|
353
|
-
"@babel/helpers - typeof";
|
|
354
|
-
|
|
355
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
356
|
-
return typeof obj;
|
|
357
|
-
} : function (obj) {
|
|
358
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
359
|
-
}, _typeof(obj);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
352
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
363
353
|
try {
|
|
364
354
|
var info = gen[key](arg);
|
|
@@ -395,54 +385,11 @@
|
|
|
395
385
|
};
|
|
396
386
|
}
|
|
397
387
|
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function _defineProperties(target, props) {
|
|
405
|
-
for (var i = 0; i < props.length; i++) {
|
|
406
|
-
var descriptor = props[i];
|
|
407
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
408
|
-
descriptor.configurable = true;
|
|
409
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
410
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
415
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
416
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
417
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
418
|
-
writable: false
|
|
419
|
-
});
|
|
420
|
-
return Constructor;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function _inherits(subClass, superClass) {
|
|
424
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
425
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
429
|
-
constructor: {
|
|
430
|
-
value: subClass,
|
|
431
|
-
writable: true,
|
|
432
|
-
configurable: true
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
Object.defineProperty(subClass, "prototype", {
|
|
436
|
-
writable: false
|
|
437
|
-
});
|
|
438
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
439
|
-
}
|
|
388
|
+
function _inheritsLoose(subClass, superClass) {
|
|
389
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
390
|
+
subClass.prototype.constructor = subClass;
|
|
440
391
|
|
|
441
|
-
|
|
442
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
443
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
444
|
-
};
|
|
445
|
-
return _getPrototypeOf(o);
|
|
392
|
+
_setPrototypeOf(subClass, superClass);
|
|
446
393
|
}
|
|
447
394
|
|
|
448
395
|
function _setPrototypeOf(o, p) {
|
|
@@ -453,158 +400,6 @@
|
|
|
453
400
|
return _setPrototypeOf(o, p);
|
|
454
401
|
}
|
|
455
402
|
|
|
456
|
-
function _isNativeReflectConstruct() {
|
|
457
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
458
|
-
if (Reflect.construct.sham) return false;
|
|
459
|
-
if (typeof Proxy === "function") return true;
|
|
460
|
-
|
|
461
|
-
try {
|
|
462
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
463
|
-
return true;
|
|
464
|
-
} catch (e) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function _assertThisInitialized(self) {
|
|
470
|
-
if (self === void 0) {
|
|
471
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
return self;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function _possibleConstructorReturn(self, call) {
|
|
478
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
479
|
-
return call;
|
|
480
|
-
} else if (call !== void 0) {
|
|
481
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return _assertThisInitialized(self);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function _createSuper(Derived) {
|
|
488
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
489
|
-
|
|
490
|
-
return function _createSuperInternal() {
|
|
491
|
-
var Super = _getPrototypeOf(Derived),
|
|
492
|
-
result;
|
|
493
|
-
|
|
494
|
-
if (hasNativeReflectConstruct) {
|
|
495
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
496
|
-
|
|
497
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
498
|
-
} else {
|
|
499
|
-
result = Super.apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return _possibleConstructorReturn(this, result);
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function _classCallCheck$1(instance, Constructor) {
|
|
507
|
-
if (!(instance instanceof Constructor)) {
|
|
508
|
-
throw new TypeError("Cannot call a class as a function");
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function _defineProperties$1(target, props) {
|
|
513
|
-
for (var i = 0; i < props.length; i++) {
|
|
514
|
-
var descriptor = props[i];
|
|
515
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
516
|
-
descriptor.configurable = true;
|
|
517
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
518
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
523
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
524
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
525
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
526
|
-
writable: false
|
|
527
|
-
});
|
|
528
|
-
return Constructor;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function _slicedToArray(arr, i) {
|
|
532
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
function _toConsumableArray(arr) {
|
|
536
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
function _arrayWithoutHoles(arr) {
|
|
540
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
function _arrayWithHoles(arr) {
|
|
544
|
-
if (Array.isArray(arr)) return arr;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
function _iterableToArray(iter) {
|
|
548
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
function _iterableToArrayLimit(arr, i) {
|
|
552
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
553
|
-
|
|
554
|
-
if (_i == null) return;
|
|
555
|
-
var _arr = [];
|
|
556
|
-
var _n = true;
|
|
557
|
-
var _d = false;
|
|
558
|
-
|
|
559
|
-
var _s, _e;
|
|
560
|
-
|
|
561
|
-
try {
|
|
562
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
563
|
-
_arr.push(_s.value);
|
|
564
|
-
|
|
565
|
-
if (i && _arr.length === i) break;
|
|
566
|
-
}
|
|
567
|
-
} catch (err) {
|
|
568
|
-
_d = true;
|
|
569
|
-
_e = err;
|
|
570
|
-
} finally {
|
|
571
|
-
try {
|
|
572
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
573
|
-
} finally {
|
|
574
|
-
if (_d) throw _e;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
return _arr;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
582
|
-
if (!o) return;
|
|
583
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
584
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
585
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
586
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
587
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function _arrayLikeToArray(arr, len) {
|
|
591
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
592
|
-
|
|
593
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
594
|
-
arr2[i] = arr[i];
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return arr2;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
function _nonIterableSpread() {
|
|
601
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function _nonIterableRest() {
|
|
605
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
606
|
-
}
|
|
607
|
-
|
|
608
403
|
var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
|
|
609
404
|
var PathGenerator = g.Syringe.defineToken('PathGenerator');
|
|
610
405
|
|
|
@@ -646,17 +441,12 @@
|
|
|
646
441
|
}
|
|
647
442
|
|
|
648
443
|
function generatePath$3(context, parsedStyle) {
|
|
649
|
-
var _parsedStyle$defX = parsedStyle.defX,
|
|
650
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
651
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
652
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
653
444
|
var _parsedStyle$path = parsedStyle.path,
|
|
654
445
|
curve = _parsedStyle$path.curve,
|
|
655
446
|
zCommandIndexes = _parsedStyle$path.zCommandIndexes;
|
|
656
|
-
|
|
657
|
-
var path = _toConsumableArray(curve);
|
|
658
|
-
|
|
447
|
+
var path = [].concat(curve);
|
|
659
448
|
zCommandIndexes.forEach(function (zIndex, index) {
|
|
449
|
+
// @ts-ignore
|
|
660
450
|
path.splice(zIndex + index, 1, ['Z']);
|
|
661
451
|
});
|
|
662
452
|
|
|
@@ -667,12 +457,13 @@
|
|
|
667
457
|
|
|
668
458
|
switch (command) {
|
|
669
459
|
case 'M':
|
|
670
|
-
context.moveTo(params[1]
|
|
460
|
+
context.moveTo(params[1], params[2]);
|
|
671
461
|
break;
|
|
672
462
|
|
|
673
463
|
case 'C':
|
|
674
|
-
context.bezierCurveTo(params[1]
|
|
464
|
+
context.bezierCurveTo(params[1], params[2], params[3], params[4], params[5], params[6]);
|
|
675
465
|
break;
|
|
466
|
+
// @ts-ignore
|
|
676
467
|
|
|
677
468
|
case 'Z':
|
|
678
469
|
context.closePath();
|
|
@@ -682,42 +473,34 @@
|
|
|
682
473
|
}
|
|
683
474
|
|
|
684
475
|
function generatePath$4(context, parsedStyle) {
|
|
685
|
-
var _parsedStyle$defX = parsedStyle.defX,
|
|
686
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
687
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
688
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
689
476
|
var points = parsedStyle.points.points;
|
|
690
477
|
var length = points.length;
|
|
691
|
-
var x1 = points[0][0]
|
|
692
|
-
var y1 = points[0][1]
|
|
693
|
-
var x2 = points[length - 1][0]
|
|
694
|
-
var y2 = points[length - 1][1]
|
|
478
|
+
var x1 = points[0][0];
|
|
479
|
+
var y1 = points[0][1];
|
|
480
|
+
var x2 = points[length - 1][0];
|
|
481
|
+
var y2 = points[length - 1][1];
|
|
695
482
|
context.moveTo(x1, y1);
|
|
696
483
|
|
|
697
484
|
for (var i = 0; i < length - 1; i++) {
|
|
698
485
|
var point = points[i];
|
|
699
|
-
context.lineTo(point[0]
|
|
486
|
+
context.lineTo(point[0], point[1]);
|
|
700
487
|
}
|
|
701
488
|
|
|
702
489
|
context.lineTo(x2, y2);
|
|
703
490
|
}
|
|
704
491
|
|
|
705
492
|
function generatePath$5(context, parsedStyle) {
|
|
706
|
-
var _parsedStyle$defX = parsedStyle.defX,
|
|
707
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
708
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
709
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
710
493
|
var points = parsedStyle.points.points;
|
|
711
494
|
var length = points.length;
|
|
712
|
-
var x1 = points[0][0]
|
|
713
|
-
var y1 = points[0][1]
|
|
714
|
-
var x2 = points[length - 1][0]
|
|
715
|
-
var y2 = points[length - 1][1]
|
|
495
|
+
var x1 = points[0][0];
|
|
496
|
+
var y1 = points[0][1];
|
|
497
|
+
var x2 = points[length - 1][0];
|
|
498
|
+
var y2 = points[length - 1][1];
|
|
716
499
|
context.moveTo(x1, y1);
|
|
717
500
|
|
|
718
501
|
for (var i = 0; i < length - 1; i++) {
|
|
719
502
|
var point = points[i];
|
|
720
|
-
context.lineTo(point[0]
|
|
503
|
+
context.lineTo(point[0], point[1]);
|
|
721
504
|
}
|
|
722
505
|
|
|
723
506
|
context.lineTo(x2, y2);
|
|
@@ -744,11 +527,10 @@
|
|
|
744
527
|
var _radius$map = radius.map(function (r) {
|
|
745
528
|
return g.clamp(r.value, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
|
|
746
529
|
}),
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
blr = _radius$map2[3];
|
|
530
|
+
tlr = _radius$map[0],
|
|
531
|
+
trr = _radius$map[1],
|
|
532
|
+
brr = _radius$map[2],
|
|
533
|
+
blr = _radius$map[3];
|
|
752
534
|
|
|
753
535
|
context.moveTo(signX * tlr, 0);
|
|
754
536
|
context.lineTo(w - signX * trr, 0);
|
|
@@ -846,22 +628,18 @@
|
|
|
846
628
|
|
|
847
629
|
var Plugin = /*#__PURE__*/function () {
|
|
848
630
|
function Plugin() {
|
|
849
|
-
_classCallCheck$1(this, Plugin);
|
|
850
|
-
|
|
851
631
|
this.name = 'canvas-path-generator';
|
|
852
632
|
}
|
|
853
633
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}
|
|
864
|
-
}]);
|
|
634
|
+
var _proto = Plugin.prototype;
|
|
635
|
+
|
|
636
|
+
_proto.init = function init(container) {
|
|
637
|
+
container.load(containerModule, true);
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
_proto.destroy = function destroy(container) {
|
|
641
|
+
container.unload(containerModule);
|
|
642
|
+
};
|
|
865
643
|
|
|
866
644
|
return Plugin;
|
|
867
645
|
}();
|
|
@@ -1024,7 +802,7 @@
|
|
|
1024
802
|
if ("throw" !== record.type) {
|
|
1025
803
|
var result = record.arg,
|
|
1026
804
|
value = result.value;
|
|
1027
|
-
return value && "object" ==
|
|
805
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1028
806
|
invoke("next", value, resolve, reject);
|
|
1029
807
|
}, function (err) {
|
|
1030
808
|
invoke("throw", err, resolve, reject);
|
|
@@ -1284,92 +1062,6 @@
|
|
|
1284
1062
|
});
|
|
1285
1063
|
};
|
|
1286
1064
|
}
|
|
1287
|
-
|
|
1288
|
-
function _classCallCheck$2(instance, Constructor) {
|
|
1289
|
-
if (!(instance instanceof Constructor)) {
|
|
1290
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
function _defineProperties$2(target, props) {
|
|
1295
|
-
for (var i = 0; i < props.length; i++) {
|
|
1296
|
-
var descriptor = props[i];
|
|
1297
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1298
|
-
descriptor.configurable = true;
|
|
1299
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1300
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1305
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1306
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1307
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1308
|
-
writable: false
|
|
1309
|
-
});
|
|
1310
|
-
return Constructor;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
function _slicedToArray$1(arr, i) {
|
|
1314
|
-
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
function _arrayWithHoles$1(arr) {
|
|
1318
|
-
if (Array.isArray(arr)) return arr;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
function _iterableToArrayLimit$1(arr, i) {
|
|
1322
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1323
|
-
|
|
1324
|
-
if (_i == null) return;
|
|
1325
|
-
var _arr = [];
|
|
1326
|
-
var _n = true;
|
|
1327
|
-
var _d = false;
|
|
1328
|
-
|
|
1329
|
-
var _s, _e;
|
|
1330
|
-
|
|
1331
|
-
try {
|
|
1332
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1333
|
-
_arr.push(_s.value);
|
|
1334
|
-
|
|
1335
|
-
if (i && _arr.length === i) break;
|
|
1336
|
-
}
|
|
1337
|
-
} catch (err) {
|
|
1338
|
-
_d = true;
|
|
1339
|
-
_e = err;
|
|
1340
|
-
} finally {
|
|
1341
|
-
try {
|
|
1342
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1343
|
-
} finally {
|
|
1344
|
-
if (_d) throw _e;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
return _arr;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
1352
|
-
if (!o) return;
|
|
1353
|
-
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
1354
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1355
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1356
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1357
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
function _arrayLikeToArray$1(arr, len) {
|
|
1361
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1362
|
-
|
|
1363
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1364
|
-
arr2[i] = arr[i];
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
return arr2;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
function _nonIterableRest$1() {
|
|
1371
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1372
|
-
}
|
|
1373
1065
|
/**
|
|
1374
1066
|
* Common utilities
|
|
1375
1067
|
* @module glMatrix
|
|
@@ -1964,8 +1656,6 @@
|
|
|
1964
1656
|
function CanvasPickerPlugin() {
|
|
1965
1657
|
var _this = this;
|
|
1966
1658
|
|
|
1967
|
-
_classCallCheck$2(this, CanvasPickerPlugin);
|
|
1968
|
-
|
|
1969
1659
|
this.displayObjectPool = void 0;
|
|
1970
1660
|
this.canvasConfig = void 0;
|
|
1971
1661
|
this.offscreenCanvas = void 0;
|
|
@@ -2016,109 +1706,108 @@
|
|
|
2016
1706
|
};
|
|
2017
1707
|
}
|
|
2018
1708
|
|
|
2019
|
-
|
|
2020
|
-
key: "apply",
|
|
2021
|
-
value: function apply(renderingService) {
|
|
2022
|
-
var _this2 = this;
|
|
2023
|
-
|
|
2024
|
-
renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
2025
|
-
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
|
|
2026
|
-
var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject, clipPath, objectToTest, worldTransform;
|
|
2027
|
-
|
|
2028
|
-
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
2029
|
-
while (1) {
|
|
2030
|
-
switch (_context.prev = _context.next) {
|
|
2031
|
-
case 0:
|
|
2032
|
-
topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
|
|
2033
|
-
|
|
2034
|
-
position = fromValues(x, y, 0); // query by AABB first with spatial index(r-tree)
|
|
2035
|
-
|
|
2036
|
-
rBushNodes = _this2.rBush.search({
|
|
2037
|
-
minX: position[0],
|
|
2038
|
-
minY: position[1],
|
|
2039
|
-
maxX: position[0],
|
|
2040
|
-
maxY: position[1]
|
|
2041
|
-
});
|
|
2042
|
-
queriedIds = rBushNodes.map(function (node) {
|
|
2043
|
-
return node.id;
|
|
2044
|
-
});
|
|
2045
|
-
hitTestList = [];
|
|
2046
|
-
rBushNodes.forEach(function (_ref2) {
|
|
2047
|
-
var id = _ref2.id;
|
|
2048
|
-
|
|
2049
|
-
var displayObject = _this2.displayObjectPool.getByEntity(id);
|
|
2050
|
-
|
|
2051
|
-
if (displayObject.isVisible() && !displayObject.isCulled() && displayObject.isInteractive()) {
|
|
2052
|
-
// parent is not included, eg. parent is clipped
|
|
2053
|
-
if (displayObject.parentNode && queriedIds.indexOf(displayObject.parentNode.entity) === -1) {
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
hitTestList.push(displayObject);
|
|
2058
|
-
}
|
|
2059
|
-
}); // find group with max z-index
|
|
2060
|
-
|
|
2061
|
-
hitTestList.sort(function (a, b) {
|
|
2062
|
-
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
2063
|
-
});
|
|
2064
|
-
pickedDisplayObjects = [];
|
|
2065
|
-
_i = 0, _hitTestList = hitTestList;
|
|
2066
|
-
|
|
2067
|
-
case 9:
|
|
2068
|
-
if (!(_i < _hitTestList.length)) {
|
|
2069
|
-
_context.next = 25;
|
|
2070
|
-
break;
|
|
2071
|
-
}
|
|
1709
|
+
var _proto = CanvasPickerPlugin.prototype;
|
|
2072
1710
|
|
|
2073
|
-
|
|
1711
|
+
_proto.apply = function apply(renderingService) {
|
|
1712
|
+
var _this2 = this;
|
|
2074
1713
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
1714
|
+
renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
1715
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
|
|
1716
|
+
var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject, clipPath, objectToTest, worldTransform;
|
|
2078
1717
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
1718
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
1719
|
+
while (1) {
|
|
1720
|
+
switch (_context.prev = _context.next) {
|
|
1721
|
+
case 0:
|
|
1722
|
+
topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
|
|
2082
1723
|
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1724
|
+
position = fromValues(x, y, 0); // query by AABB first with spatial index(r-tree)
|
|
1725
|
+
|
|
1726
|
+
rBushNodes = _this2.rBush.search({
|
|
1727
|
+
minX: position[0],
|
|
1728
|
+
minY: position[1],
|
|
1729
|
+
maxX: position[0],
|
|
1730
|
+
maxY: position[1]
|
|
1731
|
+
});
|
|
1732
|
+
queriedIds = rBushNodes.map(function (node) {
|
|
1733
|
+
return node.id;
|
|
1734
|
+
});
|
|
1735
|
+
hitTestList = [];
|
|
1736
|
+
rBushNodes.forEach(function (_ref2) {
|
|
1737
|
+
var id = _ref2.id;
|
|
1738
|
+
|
|
1739
|
+
var displayObject = _this2.displayObjectPool.getByEntity(id);
|
|
1740
|
+
|
|
1741
|
+
if (displayObject.isVisible() && !displayObject.isCulled() && displayObject.isInteractive()) {
|
|
1742
|
+
// parent is not included, eg. parent is clipped
|
|
1743
|
+
if (displayObject.parentNode && queriedIds.indexOf(displayObject.parentNode.entity) === -1) {
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
2087
1746
|
|
|
2088
|
-
|
|
2089
|
-
_context.next = 21;
|
|
2090
|
-
break;
|
|
1747
|
+
hitTestList.push(displayObject);
|
|
2091
1748
|
}
|
|
1749
|
+
}); // find group with max z-index
|
|
1750
|
+
|
|
1751
|
+
hitTestList.sort(function (a, b) {
|
|
1752
|
+
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
1753
|
+
});
|
|
1754
|
+
pickedDisplayObjects = [];
|
|
1755
|
+
_i = 0, _hitTestList = hitTestList;
|
|
1756
|
+
|
|
1757
|
+
case 9:
|
|
1758
|
+
if (!(_i < _hitTestList.length)) {
|
|
1759
|
+
_context.next = 25;
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
displayObject = _hitTestList[_i]; // test with clip path
|
|
2092
1764
|
|
|
2093
|
-
|
|
2094
|
-
|
|
1765
|
+
clipPath = displayObject.parsedStyle.clipPath;
|
|
1766
|
+
objectToTest = clipPath || displayObject;
|
|
1767
|
+
worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
|
|
1768
|
+
|
|
1769
|
+
if (clipPath) {
|
|
1770
|
+
worldTransform = multiply$1(create$1(), worldTransform, clipPath.getLocalTransform());
|
|
1771
|
+
}
|
|
2095
1772
|
|
|
2096
|
-
|
|
2097
|
-
|
|
1773
|
+
if (!_this2.isHit(objectToTest, position, worldTransform)) {
|
|
1774
|
+
_context.next = 22;
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
2098
1777
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
_context.next = 9;
|
|
1778
|
+
if (!topmost) {
|
|
1779
|
+
_context.next = 21;
|
|
2102
1780
|
break;
|
|
1781
|
+
}
|
|
2103
1782
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
return _context.abrupt("return", result);
|
|
1783
|
+
result.picked = [displayObject];
|
|
1784
|
+
return _context.abrupt("return", result);
|
|
2107
1785
|
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
1786
|
+
case 21:
|
|
1787
|
+
pickedDisplayObjects.push(displayObject);
|
|
1788
|
+
|
|
1789
|
+
case 22:
|
|
1790
|
+
_i++;
|
|
1791
|
+
_context.next = 9;
|
|
1792
|
+
break;
|
|
1793
|
+
|
|
1794
|
+
case 25:
|
|
1795
|
+
result.picked = pickedDisplayObjects;
|
|
1796
|
+
return _context.abrupt("return", result);
|
|
1797
|
+
|
|
1798
|
+
case 27:
|
|
1799
|
+
case "end":
|
|
1800
|
+
return _context.stop();
|
|
2112
1801
|
}
|
|
2113
|
-
}
|
|
2114
|
-
})
|
|
1802
|
+
}
|
|
1803
|
+
}, _callee);
|
|
1804
|
+
}));
|
|
2115
1805
|
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
}]);
|
|
1806
|
+
return function (_x) {
|
|
1807
|
+
return _ref.apply(this, arguments);
|
|
1808
|
+
};
|
|
1809
|
+
}());
|
|
1810
|
+
};
|
|
2122
1811
|
|
|
2123
1812
|
return CanvasPickerPlugin;
|
|
2124
1813
|
}(), _class.tag = 'CanvasPicker', _class);
|
|
@@ -2138,41 +1827,6 @@
|
|
|
2138
1827
|
CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([g.singleton({
|
|
2139
1828
|
contrib: g.RenderingPluginContribution
|
|
2140
1829
|
})], CanvasPickerPlugin);
|
|
2141
|
-
|
|
2142
|
-
function _toConsumableArray$1(arr) {
|
|
2143
|
-
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1$1(arr) || _nonIterableSpread$1();
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
function _arrayWithoutHoles$1(arr) {
|
|
2147
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$1$1(arr);
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
function _iterableToArray$1(iter) {
|
|
2151
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
function _unsupportedIterableToArray$1$1(o, minLen) {
|
|
2155
|
-
if (!o) return;
|
|
2156
|
-
if (typeof o === "string") return _arrayLikeToArray$1$1(o, minLen);
|
|
2157
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2158
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2159
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
2160
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1$1(o, minLen);
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
function _arrayLikeToArray$1$1(arr, len) {
|
|
2164
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
2165
|
-
|
|
2166
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
2167
|
-
arr2[i] = arr[i];
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
return arr2;
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
function _nonIterableSpread$1() {
|
|
2174
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2175
|
-
}
|
|
2176
1830
|
/**
|
|
2177
1831
|
* 两点之间的距离
|
|
2178
1832
|
* @param {number} x1 起始点 x
|
|
@@ -2182,7 +1836,6 @@
|
|
|
2182
1836
|
* @return {number} 距离
|
|
2183
1837
|
*/
|
|
2184
1838
|
|
|
2185
|
-
|
|
2186
1839
|
function distance(x1, y1, x2, y2) {
|
|
2187
1840
|
var dx = x1 - x2;
|
|
2188
1841
|
var dy = y1 - y2;
|
|
@@ -2194,10 +1847,10 @@
|
|
|
2194
1847
|
}
|
|
2195
1848
|
|
|
2196
1849
|
function getBBoxByArray(xArr, yArr) {
|
|
2197
|
-
var minX = Math.min.apply(Math,
|
|
2198
|
-
var minY = Math.min.apply(Math,
|
|
2199
|
-
var maxX = Math.max.apply(Math,
|
|
2200
|
-
var maxY = Math.max.apply(Math,
|
|
1850
|
+
var minX = Math.min.apply(Math, xArr);
|
|
1851
|
+
var minY = Math.min.apply(Math, yArr);
|
|
1852
|
+
var maxX = Math.max.apply(Math, xArr);
|
|
1853
|
+
var maxY = Math.max.apply(Math, yArr);
|
|
2201
1854
|
return {
|
|
2202
1855
|
x: minX,
|
|
2203
1856
|
y: minY,
|
|
@@ -2340,7 +1993,7 @@
|
|
|
2340
1993
|
for (var i = 0; i <= segNum; i++) {
|
|
2341
1994
|
var _t = i * increaseRate;
|
|
2342
1995
|
|
|
2343
|
-
var v1 = [tCallback.apply(void 0,
|
|
1996
|
+
var v1 = [tCallback.apply(void 0, xArr.concat([_t])), tCallback.apply(void 0, yArr.concat([_t]))];
|
|
2344
1997
|
var d1 = distance(v0[0], v0[1], v1[0], v1[1]);
|
|
2345
1998
|
|
|
2346
1999
|
if (d1 < d) {
|
|
@@ -2374,7 +2027,7 @@
|
|
|
2374
2027
|
|
|
2375
2028
|
var prev = t - interval;
|
|
2376
2029
|
var next = t + interval;
|
|
2377
|
-
var _v = [tCallback.apply(void 0,
|
|
2030
|
+
var _v = [tCallback.apply(void 0, xArr.concat([prev])), tCallback.apply(void 0, yArr.concat([prev]))];
|
|
2378
2031
|
|
|
2379
2032
|
var _d = distance(v0[0], v0[1], _v[0], _v[1]);
|
|
2380
2033
|
|
|
@@ -2382,7 +2035,7 @@
|
|
|
2382
2035
|
t = prev;
|
|
2383
2036
|
d = _d;
|
|
2384
2037
|
} else {
|
|
2385
|
-
var v2 = [tCallback.apply(void 0,
|
|
2038
|
+
var v2 = [tCallback.apply(void 0, xArr.concat([next])), tCallback.apply(void 0, yArr.concat([next]))];
|
|
2386
2039
|
var d2 = distance(v0[0], v0[1], v2[0], v2[1]);
|
|
2387
2040
|
|
|
2388
2041
|
if (next <= 1 && d2 < d) {
|
|
@@ -2395,8 +2048,8 @@
|
|
|
2395
2048
|
}
|
|
2396
2049
|
|
|
2397
2050
|
return {
|
|
2398
|
-
x: tCallback.apply(void 0,
|
|
2399
|
-
y: tCallback.apply(void 0,
|
|
2051
|
+
x: tCallback.apply(void 0, xArr.concat([t])),
|
|
2052
|
+
y: tCallback.apply(void 0, yArr.concat([t]))
|
|
2400
2053
|
};
|
|
2401
2054
|
} // 近似求解 https://community.khronos.org/t/3d-cubic-bezier-segment-length/62363/2
|
|
2402
2055
|
|
|
@@ -2465,7 +2118,7 @@
|
|
|
2465
2118
|
var right = quadratics[1];
|
|
2466
2119
|
left.push(iterationCount - 1);
|
|
2467
2120
|
right.push(iterationCount - 1);
|
|
2468
|
-
return quadraticLength.apply(void 0,
|
|
2121
|
+
return quadraticLength.apply(void 0, left) + quadraticLength.apply(void 0, right);
|
|
2469
2122
|
}
|
|
2470
2123
|
|
|
2471
2124
|
var quadratic = {
|
|
@@ -2586,9 +2239,9 @@
|
|
|
2586
2239
|
}
|
|
2587
2240
|
|
|
2588
2241
|
var cubics = divideCubic(x1, y1, x2, y2, x3, y3, x4, y4, 0.5);
|
|
2589
|
-
var left = [].concat(
|
|
2590
|
-
var right = [].concat(
|
|
2591
|
-
return cubicLength.apply(void 0,
|
|
2242
|
+
var left = [].concat(cubics[0], [iterationCount - 1]);
|
|
2243
|
+
var right = [].concat(cubics[1], [iterationCount - 1]);
|
|
2244
|
+
return cubicLength.apply(void 0, left) + cubicLength.apply(void 0, right);
|
|
2592
2245
|
}
|
|
2593
2246
|
|
|
2594
2247
|
var cubic = {
|
|
@@ -3096,12 +2749,10 @@
|
|
|
3096
2749
|
}
|
|
3097
2750
|
|
|
3098
2751
|
function inRectWithRadius(minX, minY, width, height, radiusArray, lineWidth, x, y) {
|
|
3099
|
-
var
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
blr = _radiusArray[3];
|
|
3104
|
-
|
|
2752
|
+
var tlr = radiusArray[0],
|
|
2753
|
+
trr = radiusArray[1],
|
|
2754
|
+
brr = radiusArray[2],
|
|
2755
|
+
blr = radiusArray[3];
|
|
3105
2756
|
return inLine(minX + tlr, minY, minX + width - trr, minY, lineWidth, x, y) || inLine(minX + width, minY + trr, minX + width, minY + height - brr, lineWidth, x, y) || inLine(minX + width - brr, minY + height, minX + blr, minY + height, lineWidth, x, y) || inLine(minX, minY + height - blr, minX, minY + tlr, lineWidth, x, y) || inArc(minX + width - trr, minY + trr, trr, 1.5 * Math.PI, 2 * Math.PI, lineWidth, x, y) || inArc(minX + width - brr, minY + height - brr, brr, 0, 0.5 * Math.PI, lineWidth, x, y) || inArc(minX + blr, minY + height - blr, blr, 0.5 * Math.PI, Math.PI, lineWidth, x, y) || inArc(minX + tlr, minY + tlr, tlr, Math.PI, 1.5 * Math.PI, lineWidth, x, y);
|
|
3106
2757
|
}
|
|
3107
2758
|
|
|
@@ -3140,22 +2791,18 @@
|
|
|
3140
2791
|
|
|
3141
2792
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
3142
2793
|
function Plugin() {
|
|
3143
|
-
_classCallCheck$2(this, Plugin);
|
|
3144
|
-
|
|
3145
2794
|
this.name = 'canvas-picker';
|
|
3146
2795
|
}
|
|
3147
2796
|
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
}
|
|
3158
|
-
}]);
|
|
2797
|
+
var _proto = Plugin.prototype;
|
|
2798
|
+
|
|
2799
|
+
_proto.init = function init(container) {
|
|
2800
|
+
container.load(containerModule$1, true);
|
|
2801
|
+
};
|
|
2802
|
+
|
|
2803
|
+
_proto.destroy = function destroy(container) {
|
|
2804
|
+
container.unload(containerModule$1);
|
|
2805
|
+
};
|
|
3159
2806
|
|
|
3160
2807
|
return Plugin;
|
|
3161
2808
|
}();
|
|
@@ -3165,64 +2812,227 @@
|
|
|
3165
2812
|
Plugin: Plugin$1
|
|
3166
2813
|
});
|
|
3167
2814
|
|
|
3168
|
-
function
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
var exports = {},
|
|
3175
|
-
Op = Object.prototype,
|
|
3176
|
-
hasOwn = Op.hasOwnProperty,
|
|
3177
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
3178
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
3179
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
3180
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
3181
|
-
|
|
3182
|
-
function define(obj, key, value) {
|
|
3183
|
-
return Object.defineProperty(obj, key, {
|
|
3184
|
-
value: value,
|
|
3185
|
-
enumerable: !0,
|
|
3186
|
-
configurable: !0,
|
|
3187
|
-
writable: !0
|
|
3188
|
-
}), obj[key];
|
|
3189
|
-
}
|
|
3190
|
-
|
|
3191
|
-
try {
|
|
3192
|
-
define({}, "");
|
|
3193
|
-
} catch (err) {
|
|
3194
|
-
define = function define(obj, key, value) {
|
|
3195
|
-
return obj[key] = value;
|
|
3196
|
-
};
|
|
2815
|
+
var ImagePool = /*#__PURE__*/function () {
|
|
2816
|
+
function ImagePool() {
|
|
2817
|
+
this.imageCache = {};
|
|
2818
|
+
this.gradientCache = {};
|
|
2819
|
+
this.patternCache = {};
|
|
2820
|
+
this.canvasConfig = void 0;
|
|
3197
2821
|
}
|
|
3198
2822
|
|
|
3199
|
-
|
|
3200
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
3201
|
-
generator = Object.create(protoGenerator.prototype),
|
|
3202
|
-
context = new Context(tryLocsList || []);
|
|
3203
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
3204
|
-
var state = "suspendedStart";
|
|
3205
|
-
return function (method, arg) {
|
|
3206
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
2823
|
+
var _proto = ImagePool.prototype;
|
|
3207
2824
|
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
2825
|
+
_proto.getImageSync = function getImageSync(src, callback) {
|
|
2826
|
+
if (!this.imageCache[src]) {
|
|
2827
|
+
this.getOrCreateImage(src).then(function () {
|
|
2828
|
+
if (callback) {
|
|
2829
|
+
callback();
|
|
3211
2830
|
}
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
3212
2833
|
|
|
3213
|
-
|
|
3214
|
-
|
|
2834
|
+
return this.imageCache[src];
|
|
2835
|
+
};
|
|
3215
2836
|
|
|
3216
|
-
|
|
3217
|
-
|
|
2837
|
+
_proto.getOrCreateImage = function getOrCreateImage(src) {
|
|
2838
|
+
var _this = this;
|
|
3218
2839
|
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
2840
|
+
if (this.imageCache[src]) {
|
|
2841
|
+
return Promise.resolve(this.imageCache[src]);
|
|
2842
|
+
} // @see https://github.com/antvis/g/issues/938
|
|
3224
2843
|
|
|
3225
|
-
|
|
2844
|
+
|
|
2845
|
+
var createImage = this.canvasConfig.createImage;
|
|
2846
|
+
return new Promise(function (resolve, reject) {
|
|
2847
|
+
var image;
|
|
2848
|
+
|
|
2849
|
+
if (createImage) {
|
|
2850
|
+
image = createImage(src);
|
|
2851
|
+
} else if (g.isBrowser) {
|
|
2852
|
+
image = new window.Image();
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
if (image) {
|
|
2856
|
+
image.onload = function () {
|
|
2857
|
+
resolve(image);
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
image.onerror = function (ev) {
|
|
2861
|
+
reject(ev);
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2864
|
+
image.crossOrigin = 'Anonymous';
|
|
2865
|
+
image.src = src;
|
|
2866
|
+
_this.imageCache[src] = image;
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
};
|
|
2870
|
+
|
|
2871
|
+
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
|
|
2872
|
+
var patternKey = this.generatePatternKey(pattern);
|
|
2873
|
+
|
|
2874
|
+
if (patternKey && this.patternCache[patternKey]) {
|
|
2875
|
+
return this.patternCache[patternKey];
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
var image = pattern.image,
|
|
2879
|
+
repetition = pattern.repetition;
|
|
2880
|
+
var src; // Image URL
|
|
2881
|
+
|
|
2882
|
+
if (g.isString(image)) {
|
|
2883
|
+
src = this.getImageSync(image, callback);
|
|
2884
|
+
} else {
|
|
2885
|
+
src = image;
|
|
2886
|
+
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
2890
|
+
|
|
2891
|
+
if (patternKey && canvasPattern) {
|
|
2892
|
+
this.patternCache[patternKey] = canvasPattern;
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
return canvasPattern;
|
|
2896
|
+
};
|
|
2897
|
+
|
|
2898
|
+
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
2899
|
+
var key = this.generateGradientKey(params); // @ts-ignore
|
|
2900
|
+
|
|
2901
|
+
var type = params.type,
|
|
2902
|
+
steps = params.steps,
|
|
2903
|
+
width = params.width,
|
|
2904
|
+
height = params.height,
|
|
2905
|
+
angle = params.angle,
|
|
2906
|
+
cx = params.cx,
|
|
2907
|
+
cy = params.cy;
|
|
2908
|
+
|
|
2909
|
+
if (this.gradientCache[key]) {
|
|
2910
|
+
return this.gradientCache[key];
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
var gradient = null;
|
|
2914
|
+
|
|
2915
|
+
if (type === g.GradientType.LinearGradient) {
|
|
2916
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
2917
|
+
x1 = _computeLinearGradien.x1,
|
|
2918
|
+
y1 = _computeLinearGradien.y1,
|
|
2919
|
+
x2 = _computeLinearGradien.x2,
|
|
2920
|
+
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
2921
|
+
|
|
2922
|
+
|
|
2923
|
+
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
2924
|
+
} else if (type === g.GradientType.RadialGradient) {
|
|
2925
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
2926
|
+
x = _computeRadialGradien.x,
|
|
2927
|
+
y = _computeRadialGradien.y,
|
|
2928
|
+
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
if (gradient) {
|
|
2935
|
+
steps.forEach(function (_ref) {
|
|
2936
|
+
var _gradient;
|
|
2937
|
+
|
|
2938
|
+
var offset = _ref[0],
|
|
2939
|
+
color = _ref[1];
|
|
2940
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
2941
|
+
});
|
|
2942
|
+
this.gradientCache[key] = gradient;
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
return this.gradientCache[key];
|
|
2946
|
+
};
|
|
2947
|
+
|
|
2948
|
+
_proto.generateGradientKey = function generateGradientKey(params) {
|
|
2949
|
+
// @ts-ignore
|
|
2950
|
+
var type = params.type,
|
|
2951
|
+
width = params.width,
|
|
2952
|
+
height = params.height,
|
|
2953
|
+
steps = params.steps,
|
|
2954
|
+
angle = params.angle,
|
|
2955
|
+
cx = params.cx,
|
|
2956
|
+
cy = params.cy;
|
|
2957
|
+
return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
2958
|
+
return step.join('');
|
|
2959
|
+
}).join('-');
|
|
2960
|
+
};
|
|
2961
|
+
|
|
2962
|
+
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2963
|
+
var image = pattern.image,
|
|
2964
|
+
repetition = pattern.repetition; // only generate cache for Image
|
|
2965
|
+
|
|
2966
|
+
if (g.isString(image)) {
|
|
2967
|
+
return "pattern-" + image + "-" + repetition;
|
|
2968
|
+
}
|
|
2969
|
+
};
|
|
2970
|
+
|
|
2971
|
+
return ImagePool;
|
|
2972
|
+
}();
|
|
2973
|
+
|
|
2974
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
2975
|
+
|
|
2976
|
+
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
2977
|
+
|
|
2978
|
+
function _regeneratorRuntime$2() {
|
|
2979
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2980
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2981
|
+
return exports;
|
|
2982
|
+
};
|
|
2983
|
+
|
|
2984
|
+
var exports = {},
|
|
2985
|
+
Op = Object.prototype,
|
|
2986
|
+
hasOwn = Op.hasOwnProperty,
|
|
2987
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
2988
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
2989
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
2990
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
2991
|
+
|
|
2992
|
+
function define(obj, key, value) {
|
|
2993
|
+
return Object.defineProperty(obj, key, {
|
|
2994
|
+
value: value,
|
|
2995
|
+
enumerable: !0,
|
|
2996
|
+
configurable: !0,
|
|
2997
|
+
writable: !0
|
|
2998
|
+
}), obj[key];
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
try {
|
|
3002
|
+
define({}, "");
|
|
3003
|
+
} catch (err) {
|
|
3004
|
+
define = function define(obj, key, value) {
|
|
3005
|
+
return obj[key] = value;
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
3010
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
3011
|
+
generator = Object.create(protoGenerator.prototype),
|
|
3012
|
+
context = new Context(tryLocsList || []);
|
|
3013
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
3014
|
+
var state = "suspendedStart";
|
|
3015
|
+
return function (method, arg) {
|
|
3016
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
3017
|
+
|
|
3018
|
+
if ("completed" === state) {
|
|
3019
|
+
if ("throw" === method) throw arg;
|
|
3020
|
+
return doneResult();
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
for (context.method = method, context.arg = arg;;) {
|
|
3024
|
+
var delegate = context.delegate;
|
|
3025
|
+
|
|
3026
|
+
if (delegate) {
|
|
3027
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
3028
|
+
|
|
3029
|
+
if (delegateResult) {
|
|
3030
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
3031
|
+
return delegateResult;
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
3226
3036
|
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
3227
3037
|
context.dispatchException(context.arg);
|
|
3228
3038
|
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
@@ -3290,7 +3100,7 @@
|
|
|
3290
3100
|
if ("throw" !== record.type) {
|
|
3291
3101
|
var result = record.arg,
|
|
3292
3102
|
value = result.value;
|
|
3293
|
-
return value && "object" ==
|
|
3103
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3294
3104
|
invoke("next", value, resolve, reject);
|
|
3295
3105
|
}, function (err) {
|
|
3296
3106
|
invoke("throw", err, resolve, reject);
|
|
@@ -3551,340 +3361,78 @@
|
|
|
3551
3361
|
};
|
|
3552
3362
|
}
|
|
3553
3363
|
|
|
3554
|
-
function _classCallCheck$3(instance, Constructor) {
|
|
3555
|
-
if (!(instance instanceof Constructor)) {
|
|
3556
|
-
throw new TypeError("Cannot call a class as a function");
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
|
|
3560
|
-
function _defineProperties$3(target, props) {
|
|
3561
|
-
for (var i = 0; i < props.length; i++) {
|
|
3562
|
-
var descriptor = props[i];
|
|
3563
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
3564
|
-
descriptor.configurable = true;
|
|
3565
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
3566
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
|
|
3570
|
-
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
3571
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
3572
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
3573
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
3574
|
-
writable: false
|
|
3575
|
-
});
|
|
3576
|
-
return Constructor;
|
|
3577
|
-
}
|
|
3578
|
-
|
|
3579
|
-
function _slicedToArray$2(arr, i) {
|
|
3580
|
-
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2();
|
|
3581
|
-
}
|
|
3582
|
-
|
|
3583
|
-
function _arrayWithHoles$2(arr) {
|
|
3584
|
-
if (Array.isArray(arr)) return arr;
|
|
3585
|
-
}
|
|
3586
|
-
|
|
3587
|
-
function _iterableToArrayLimit$2(arr, i) {
|
|
3588
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
3589
|
-
|
|
3590
|
-
if (_i == null) return;
|
|
3591
|
-
var _arr = [];
|
|
3592
|
-
var _n = true;
|
|
3593
|
-
var _d = false;
|
|
3594
|
-
|
|
3595
|
-
var _s, _e;
|
|
3596
|
-
|
|
3597
|
-
try {
|
|
3598
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
3599
|
-
_arr.push(_s.value);
|
|
3600
|
-
|
|
3601
|
-
if (i && _arr.length === i) break;
|
|
3602
|
-
}
|
|
3603
|
-
} catch (err) {
|
|
3604
|
-
_d = true;
|
|
3605
|
-
_e = err;
|
|
3606
|
-
} finally {
|
|
3607
|
-
try {
|
|
3608
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
3609
|
-
} finally {
|
|
3610
|
-
if (_d) throw _e;
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
|
|
3614
|
-
return _arr;
|
|
3615
|
-
}
|
|
3616
|
-
|
|
3617
|
-
function _unsupportedIterableToArray$2(o, minLen) {
|
|
3618
|
-
if (!o) return;
|
|
3619
|
-
if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
|
|
3620
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3621
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3622
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3623
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
|
|
3624
|
-
}
|
|
3625
|
-
|
|
3626
|
-
function _arrayLikeToArray$2(arr, len) {
|
|
3627
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3628
|
-
|
|
3629
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3630
|
-
arr2[i] = arr[i];
|
|
3631
|
-
}
|
|
3632
|
-
|
|
3633
|
-
return arr2;
|
|
3634
|
-
}
|
|
3635
|
-
|
|
3636
|
-
function _nonIterableRest$2() {
|
|
3637
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
var ImagePool = /*#__PURE__*/function () {
|
|
3641
|
-
function ImagePool() {
|
|
3642
|
-
_classCallCheck$3(this, ImagePool);
|
|
3643
|
-
|
|
3644
|
-
this.imageCache = {};
|
|
3645
|
-
this.gradientCache = {};
|
|
3646
|
-
this.patternCache = {};
|
|
3647
|
-
this.canvasConfig = void 0;
|
|
3648
|
-
}
|
|
3649
|
-
|
|
3650
|
-
_createClass$3(ImagePool, [{
|
|
3651
|
-
key: "getImageSync",
|
|
3652
|
-
value: function getImageSync(src, callback) {
|
|
3653
|
-
if (!this.imageCache[src]) {
|
|
3654
|
-
this.getOrCreateImage(src).then(function () {
|
|
3655
|
-
if (callback) {
|
|
3656
|
-
callback();
|
|
3657
|
-
}
|
|
3658
|
-
});
|
|
3659
|
-
}
|
|
3660
|
-
|
|
3661
|
-
return this.imageCache[src];
|
|
3662
|
-
}
|
|
3663
|
-
}, {
|
|
3664
|
-
key: "getOrCreateImage",
|
|
3665
|
-
value: function getOrCreateImage(src) {
|
|
3666
|
-
var _this = this;
|
|
3667
|
-
|
|
3668
|
-
if (this.imageCache[src]) {
|
|
3669
|
-
return Promise.resolve(this.imageCache[src]);
|
|
3670
|
-
} // @see https://github.com/antvis/g/issues/938
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
var createImage = this.canvasConfig.createImage;
|
|
3674
|
-
return new Promise(function (resolve, reject) {
|
|
3675
|
-
var image;
|
|
3676
|
-
|
|
3677
|
-
if (createImage) {
|
|
3678
|
-
image = createImage(src);
|
|
3679
|
-
} else if (g.isBrowser) {
|
|
3680
|
-
image = new window.Image();
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3683
|
-
if (image) {
|
|
3684
|
-
image.onload = function () {
|
|
3685
|
-
resolve(image);
|
|
3686
|
-
};
|
|
3687
|
-
|
|
3688
|
-
image.onerror = function (ev) {
|
|
3689
|
-
reject(ev);
|
|
3690
|
-
};
|
|
3691
|
-
|
|
3692
|
-
image.crossOrigin = 'Anonymous';
|
|
3693
|
-
image.src = src;
|
|
3694
|
-
_this.imageCache[src] = image;
|
|
3695
|
-
}
|
|
3696
|
-
});
|
|
3697
|
-
}
|
|
3698
|
-
}, {
|
|
3699
|
-
key: "getOrCreatePatternSync",
|
|
3700
|
-
value: function getOrCreatePatternSync(pattern, context, callback) {
|
|
3701
|
-
var patternKey = this.generatePatternKey(pattern);
|
|
3702
|
-
|
|
3703
|
-
if (patternKey && this.patternCache[patternKey]) {
|
|
3704
|
-
return this.patternCache[patternKey];
|
|
3705
|
-
}
|
|
3706
|
-
|
|
3707
|
-
var image = pattern.image,
|
|
3708
|
-
repetition = pattern.repetition;
|
|
3709
|
-
var src; // Image URL
|
|
3710
|
-
|
|
3711
|
-
if (g.isString(image)) {
|
|
3712
|
-
src = this.getImageSync(image, callback);
|
|
3713
|
-
} else {
|
|
3714
|
-
src = image;
|
|
3715
|
-
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
var canvasPattern = src && context.createPattern(src, repetition);
|
|
3719
|
-
|
|
3720
|
-
if (patternKey && canvasPattern) {
|
|
3721
|
-
this.patternCache[patternKey] = canvasPattern;
|
|
3722
|
-
}
|
|
3723
|
-
|
|
3724
|
-
return canvasPattern;
|
|
3725
|
-
}
|
|
3726
|
-
}, {
|
|
3727
|
-
key: "getOrCreateGradient",
|
|
3728
|
-
value: function getOrCreateGradient(params, context) {
|
|
3729
|
-
var key = this.generateGradientKey(params); // @ts-ignore
|
|
3730
|
-
|
|
3731
|
-
var type = params.type,
|
|
3732
|
-
steps = params.steps,
|
|
3733
|
-
width = params.width,
|
|
3734
|
-
height = params.height,
|
|
3735
|
-
angle = params.angle,
|
|
3736
|
-
cx = params.cx,
|
|
3737
|
-
cy = params.cy;
|
|
3738
|
-
|
|
3739
|
-
if (this.gradientCache[key]) {
|
|
3740
|
-
return this.gradientCache[key];
|
|
3741
|
-
}
|
|
3742
|
-
|
|
3743
|
-
var gradient = null;
|
|
3744
|
-
|
|
3745
|
-
if (type === g.GradientType.LinearGradient) {
|
|
3746
|
-
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
3747
|
-
x1 = _computeLinearGradien.x1,
|
|
3748
|
-
y1 = _computeLinearGradien.y1,
|
|
3749
|
-
x2 = _computeLinearGradien.x2,
|
|
3750
|
-
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
3754
|
-
} else if (type === g.GradientType.RadialGradient) {
|
|
3755
|
-
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
3756
|
-
x = _computeRadialGradien.x,
|
|
3757
|
-
y = _computeRadialGradien.y,
|
|
3758
|
-
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
3762
|
-
}
|
|
3763
|
-
|
|
3764
|
-
if (gradient) {
|
|
3765
|
-
steps.forEach(function (_ref) {
|
|
3766
|
-
var _gradient;
|
|
3767
|
-
|
|
3768
|
-
var _ref2 = _slicedToArray$2(_ref, 2),
|
|
3769
|
-
offset = _ref2[0],
|
|
3770
|
-
color = _ref2[1];
|
|
3771
|
-
|
|
3772
|
-
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
3773
|
-
});
|
|
3774
|
-
this.gradientCache[key] = gradient;
|
|
3775
|
-
}
|
|
3776
|
-
|
|
3777
|
-
return this.gradientCache[key];
|
|
3778
|
-
}
|
|
3779
|
-
}, {
|
|
3780
|
-
key: "generateGradientKey",
|
|
3781
|
-
value: function generateGradientKey(params) {
|
|
3782
|
-
// @ts-ignore
|
|
3783
|
-
var type = params.type,
|
|
3784
|
-
width = params.width,
|
|
3785
|
-
height = params.height,
|
|
3786
|
-
steps = params.steps,
|
|
3787
|
-
angle = params.angle,
|
|
3788
|
-
cx = params.cx,
|
|
3789
|
-
cy = params.cy;
|
|
3790
|
-
return "gradient-".concat(type, "-").concat(angle || 0, "-").concat(cx || 0, "-").concat(cy || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (step) {
|
|
3791
|
-
return step.join('');
|
|
3792
|
-
}).join('-'));
|
|
3793
|
-
}
|
|
3794
|
-
}, {
|
|
3795
|
-
key: "generatePatternKey",
|
|
3796
|
-
value: function generatePatternKey(pattern) {
|
|
3797
|
-
var image = pattern.image,
|
|
3798
|
-
repetition = pattern.repetition; // only generate cache for Image
|
|
3799
|
-
|
|
3800
|
-
if (g.isString(image)) {
|
|
3801
|
-
return "pattern-".concat(image, "-").concat(repetition);
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
}]);
|
|
3805
|
-
|
|
3806
|
-
return ImagePool;
|
|
3807
|
-
}();
|
|
3808
|
-
|
|
3809
|
-
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
3810
|
-
|
|
3811
|
-
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
3812
|
-
|
|
3813
3364
|
var _class$1;
|
|
3814
3365
|
|
|
3815
3366
|
var LoadImagePlugin_1;
|
|
3816
3367
|
var LoadImagePlugin = LoadImagePlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
3817
3368
|
function LoadImagePlugin() {
|
|
3818
|
-
_classCallCheck$3(this, LoadImagePlugin);
|
|
3819
|
-
|
|
3820
3369
|
this.imagePool = void 0;
|
|
3821
3370
|
this.renderingContext = void 0;
|
|
3822
3371
|
}
|
|
3823
3372
|
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3373
|
+
var _proto = LoadImagePlugin.prototype;
|
|
3374
|
+
|
|
3375
|
+
_proto.apply = function apply(renderingService) {
|
|
3376
|
+
var _this = this;
|
|
3828
3377
|
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3378
|
+
var handleMounted = function handleMounted(e) {
|
|
3379
|
+
var object = e.target;
|
|
3380
|
+
var nodeName = object.nodeName,
|
|
3381
|
+
attributes = object.attributes;
|
|
3382
|
+
|
|
3383
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
3384
|
+
var img = attributes.img;
|
|
3385
|
+
|
|
3386
|
+
if (g.isString(img)) {
|
|
3387
|
+
_this.imagePool.getImageSync(img, function () {
|
|
3388
|
+
// set dirty rectangle flag
|
|
3389
|
+
object.renderable.dirty = true;
|
|
3390
|
+
renderingService.dirtify();
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
};
|
|
3833
3395
|
|
|
3834
|
-
|
|
3835
|
-
|
|
3396
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
3397
|
+
var object = e.target;
|
|
3398
|
+
var attrName = e.attrName,
|
|
3399
|
+
newValue = e.newValue;
|
|
3836
3400
|
|
|
3837
|
-
|
|
3838
|
-
|
|
3401
|
+
if (object.nodeName === g.Shape.IMAGE) {
|
|
3402
|
+
if (attrName === 'img') {
|
|
3403
|
+
if (g.isString(newValue)) {
|
|
3404
|
+
_this.imagePool.getOrCreateImage(newValue).then(function () {
|
|
3839
3405
|
// set dirty rectangle flag
|
|
3840
3406
|
object.renderable.dirty = true;
|
|
3841
3407
|
renderingService.dirtify();
|
|
3842
3408
|
});
|
|
3843
3409
|
}
|
|
3844
3410
|
}
|
|
3845
|
-
}
|
|
3411
|
+
}
|
|
3412
|
+
};
|
|
3846
3413
|
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
if (attrName === 'img') {
|
|
3854
|
-
if (g.isString(newValue)) {
|
|
3855
|
-
_this.imagePool.getOrCreateImage(newValue).then(function () {
|
|
3856
|
-
// set dirty rectangle flag
|
|
3857
|
-
object.renderable.dirty = true;
|
|
3858
|
-
renderingService.dirtify();
|
|
3859
|
-
});
|
|
3860
|
-
}
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
};
|
|
3414
|
+
renderingService.hooks.init.tapPromise(LoadImagePlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
3415
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3416
|
+
while (1) {
|
|
3417
|
+
switch (_context.prev = _context.next) {
|
|
3418
|
+
case 0:
|
|
3419
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3864
3420
|
|
|
3865
|
-
|
|
3866
|
-
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3867
|
-
while (1) {
|
|
3868
|
-
switch (_context.prev = _context.next) {
|
|
3869
|
-
case 0:
|
|
3870
|
-
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3871
|
-
|
|
3872
|
-
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3421
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3873
3422
|
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
}
|
|
3423
|
+
case 2:
|
|
3424
|
+
case "end":
|
|
3425
|
+
return _context.stop();
|
|
3878
3426
|
}
|
|
3879
|
-
}
|
|
3880
|
-
})
|
|
3881
|
-
|
|
3882
|
-
|
|
3427
|
+
}
|
|
3428
|
+
}, _callee);
|
|
3429
|
+
})));
|
|
3430
|
+
renderingService.hooks.destroy.tap(LoadImagePlugin_1.tag, function () {
|
|
3431
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3883
3432
|
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
}]);
|
|
3433
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3434
|
+
});
|
|
3435
|
+
};
|
|
3888
3436
|
|
|
3889
3437
|
return LoadImagePlugin;
|
|
3890
3438
|
}(), _class$1.tag = 'LoadImage', _class$1);
|
|
@@ -3903,22 +3451,18 @@
|
|
|
3903
3451
|
|
|
3904
3452
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
3905
3453
|
function Plugin() {
|
|
3906
|
-
_classCallCheck$3(this, Plugin);
|
|
3907
|
-
|
|
3908
3454
|
this.name = 'image-loader';
|
|
3909
3455
|
}
|
|
3910
3456
|
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
}
|
|
3921
|
-
}]);
|
|
3457
|
+
var _proto = Plugin.prototype;
|
|
3458
|
+
|
|
3459
|
+
_proto.init = function init(container) {
|
|
3460
|
+
container.load(containerModule$2, true);
|
|
3461
|
+
};
|
|
3462
|
+
|
|
3463
|
+
_proto.destroy = function destroy(container) {
|
|
3464
|
+
container.unload(containerModule$2);
|
|
3465
|
+
};
|
|
3922
3466
|
|
|
3923
3467
|
return Plugin;
|
|
3924
3468
|
}();
|
|
@@ -3929,32 +3473,6 @@
|
|
|
3929
3473
|
Plugin: Plugin$2
|
|
3930
3474
|
});
|
|
3931
3475
|
|
|
3932
|
-
function ownKeys(object, enumerableOnly) {
|
|
3933
|
-
var keys = Object.keys(object);
|
|
3934
|
-
|
|
3935
|
-
if (Object.getOwnPropertySymbols) {
|
|
3936
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
3937
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
3938
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3939
|
-
})), keys.push.apply(keys, symbols);
|
|
3940
|
-
}
|
|
3941
|
-
|
|
3942
|
-
return keys;
|
|
3943
|
-
}
|
|
3944
|
-
|
|
3945
|
-
function _objectSpread2(target) {
|
|
3946
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
3947
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
3948
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
3949
|
-
_defineProperty(target, key, source[key]);
|
|
3950
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
3951
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3952
|
-
});
|
|
3953
|
-
}
|
|
3954
|
-
|
|
3955
|
-
return target;
|
|
3956
|
-
}
|
|
3957
|
-
|
|
3958
3476
|
function _regeneratorRuntime$3() {
|
|
3959
3477
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3960
3478
|
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
@@ -4080,7 +3598,7 @@
|
|
|
4080
3598
|
if ("throw" !== record.type) {
|
|
4081
3599
|
var result = record.arg,
|
|
4082
3600
|
value = result.value;
|
|
4083
|
-
return value && "object" ==
|
|
3601
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
4084
3602
|
invoke("next", value, resolve, reject);
|
|
4085
3603
|
}, function (err) {
|
|
4086
3604
|
invoke("throw", err, resolve, reject);
|
|
@@ -4302,243 +3820,75 @@
|
|
|
4302
3820
|
nextLoc: nextLoc
|
|
4303
3821
|
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
4304
3822
|
}
|
|
4305
|
-
}, exports;
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
4309
|
-
try {
|
|
4310
|
-
var info = gen[key](arg);
|
|
4311
|
-
var value = info.value;
|
|
4312
|
-
} catch (error) {
|
|
4313
|
-
reject(error);
|
|
4314
|
-
return;
|
|
4315
|
-
}
|
|
4316
|
-
|
|
4317
|
-
if (info.done) {
|
|
4318
|
-
resolve(value);
|
|
4319
|
-
} else {
|
|
4320
|
-
Promise.resolve(value).then(_next, _throw);
|
|
4321
|
-
}
|
|
4322
|
-
}
|
|
4323
|
-
|
|
4324
|
-
function _asyncToGenerator$3(fn) {
|
|
4325
|
-
return function () {
|
|
4326
|
-
var self = this,
|
|
4327
|
-
args = arguments;
|
|
4328
|
-
return new Promise(function (resolve, reject) {
|
|
4329
|
-
var gen = fn.apply(self, args);
|
|
4330
|
-
|
|
4331
|
-
function _next(value) {
|
|
4332
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
4333
|
-
}
|
|
4334
|
-
|
|
4335
|
-
function _throw(err) {
|
|
4336
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
4337
|
-
}
|
|
4338
|
-
|
|
4339
|
-
_next(undefined);
|
|
4340
|
-
});
|
|
4341
|
-
};
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
|
-
function _classCallCheck$4(instance, Constructor) {
|
|
4345
|
-
if (!(instance instanceof Constructor)) {
|
|
4346
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
|
-
|
|
4350
|
-
function _defineProperties$4(target, props) {
|
|
4351
|
-
for (var i = 0; i < props.length; i++) {
|
|
4352
|
-
var descriptor = props[i];
|
|
4353
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
4354
|
-
descriptor.configurable = true;
|
|
4355
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
4356
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4357
|
-
}
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
function _createClass$4(Constructor, protoProps, staticProps) {
|
|
4361
|
-
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
4362
|
-
if (staticProps) _defineProperties$4(Constructor, staticProps);
|
|
4363
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
4364
|
-
writable: false
|
|
4365
|
-
});
|
|
4366
|
-
return Constructor;
|
|
4367
|
-
}
|
|
4368
|
-
|
|
4369
|
-
function _defineProperty(obj, key, value) {
|
|
4370
|
-
if (key in obj) {
|
|
4371
|
-
Object.defineProperty(obj, key, {
|
|
4372
|
-
value: value,
|
|
4373
|
-
enumerable: true,
|
|
4374
|
-
configurable: true,
|
|
4375
|
-
writable: true
|
|
4376
|
-
});
|
|
4377
|
-
} else {
|
|
4378
|
-
obj[key] = value;
|
|
4379
|
-
}
|
|
4380
|
-
|
|
4381
|
-
return obj;
|
|
4382
|
-
}
|
|
4383
|
-
|
|
4384
|
-
function _inherits$1(subClass, superClass) {
|
|
4385
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
4386
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
4387
|
-
}
|
|
4388
|
-
|
|
4389
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
4390
|
-
constructor: {
|
|
4391
|
-
value: subClass,
|
|
4392
|
-
writable: true,
|
|
4393
|
-
configurable: true
|
|
4394
|
-
}
|
|
4395
|
-
});
|
|
4396
|
-
Object.defineProperty(subClass, "prototype", {
|
|
4397
|
-
writable: false
|
|
4398
|
-
});
|
|
4399
|
-
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
4400
|
-
}
|
|
4401
|
-
|
|
4402
|
-
function _getPrototypeOf$1(o) {
|
|
4403
|
-
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
4404
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
4405
|
-
};
|
|
4406
|
-
return _getPrototypeOf$1(o);
|
|
4407
|
-
}
|
|
4408
|
-
|
|
4409
|
-
function _setPrototypeOf$1(o, p) {
|
|
4410
|
-
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
4411
|
-
o.__proto__ = p;
|
|
4412
|
-
return o;
|
|
4413
|
-
};
|
|
4414
|
-
return _setPrototypeOf$1(o, p);
|
|
4415
|
-
}
|
|
4416
|
-
|
|
4417
|
-
function _isNativeReflectConstruct$1() {
|
|
4418
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
4419
|
-
if (Reflect.construct.sham) return false;
|
|
4420
|
-
if (typeof Proxy === "function") return true;
|
|
4421
|
-
|
|
4422
|
-
try {
|
|
4423
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4424
|
-
return true;
|
|
4425
|
-
} catch (e) {
|
|
4426
|
-
return false;
|
|
4427
|
-
}
|
|
3823
|
+
}, exports;
|
|
4428
3824
|
}
|
|
4429
3825
|
|
|
4430
|
-
function
|
|
4431
|
-
|
|
4432
|
-
|
|
3826
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3827
|
+
try {
|
|
3828
|
+
var info = gen[key](arg);
|
|
3829
|
+
var value = info.value;
|
|
3830
|
+
} catch (error) {
|
|
3831
|
+
reject(error);
|
|
3832
|
+
return;
|
|
4433
3833
|
}
|
|
4434
3834
|
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
4440
|
-
return call;
|
|
4441
|
-
} else if (call !== void 0) {
|
|
4442
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
3835
|
+
if (info.done) {
|
|
3836
|
+
resolve(value);
|
|
3837
|
+
} else {
|
|
3838
|
+
Promise.resolve(value).then(_next, _throw);
|
|
4443
3839
|
}
|
|
4444
|
-
|
|
4445
|
-
return _assertThisInitialized$1(self);
|
|
4446
3840
|
}
|
|
4447
3841
|
|
|
4448
|
-
function
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
3842
|
+
function _asyncToGenerator$3(fn) {
|
|
3843
|
+
return function () {
|
|
3844
|
+
var self = this,
|
|
3845
|
+
args = arguments;
|
|
3846
|
+
return new Promise(function (resolve, reject) {
|
|
3847
|
+
var gen = fn.apply(self, args);
|
|
4454
3848
|
|
|
4455
|
-
|
|
4456
|
-
|
|
3849
|
+
function _next(value) {
|
|
3850
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
3851
|
+
}
|
|
4457
3852
|
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
}
|
|
3853
|
+
function _throw(err) {
|
|
3854
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3855
|
+
}
|
|
4462
3856
|
|
|
4463
|
-
|
|
3857
|
+
_next(undefined);
|
|
3858
|
+
});
|
|
4464
3859
|
};
|
|
4465
3860
|
}
|
|
4466
3861
|
|
|
4467
|
-
function
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
function _toConsumableArray$2(arr) {
|
|
4472
|
-
return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread$2();
|
|
4473
|
-
}
|
|
4474
|
-
|
|
4475
|
-
function _arrayWithoutHoles$2(arr) {
|
|
4476
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
|
|
4477
|
-
}
|
|
4478
|
-
|
|
4479
|
-
function _arrayWithHoles$3(arr) {
|
|
4480
|
-
if (Array.isArray(arr)) return arr;
|
|
4481
|
-
}
|
|
4482
|
-
|
|
4483
|
-
function _iterableToArray$2(iter) {
|
|
4484
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
4485
|
-
}
|
|
4486
|
-
|
|
4487
|
-
function _iterableToArrayLimit$3(arr, i) {
|
|
4488
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
4489
|
-
|
|
4490
|
-
if (_i == null) return;
|
|
4491
|
-
var _arr = [];
|
|
4492
|
-
var _n = true;
|
|
4493
|
-
var _d = false;
|
|
4494
|
-
|
|
4495
|
-
var _s, _e;
|
|
3862
|
+
function _extends() {
|
|
3863
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3864
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3865
|
+
var source = arguments[i];
|
|
4496
3866
|
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
}
|
|
4503
|
-
} catch (err) {
|
|
4504
|
-
_d = true;
|
|
4505
|
-
_e = err;
|
|
4506
|
-
} finally {
|
|
4507
|
-
try {
|
|
4508
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
4509
|
-
} finally {
|
|
4510
|
-
if (_d) throw _e;
|
|
3867
|
+
for (var key in source) {
|
|
3868
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3869
|
+
target[key] = source[key];
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
4511
3872
|
}
|
|
4512
|
-
}
|
|
4513
3873
|
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
function _unsupportedIterableToArray$3(o, minLen) {
|
|
4518
|
-
if (!o) return;
|
|
4519
|
-
if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
|
|
4520
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4521
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4522
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
4523
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
|
|
3874
|
+
return target;
|
|
3875
|
+
};
|
|
3876
|
+
return _extends.apply(this, arguments);
|
|
4524
3877
|
}
|
|
4525
3878
|
|
|
4526
|
-
function
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
4530
|
-
arr2[i] = arr[i];
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
|
-
return arr2;
|
|
4534
|
-
}
|
|
3879
|
+
function _inheritsLoose$1(subClass, superClass) {
|
|
3880
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
3881
|
+
subClass.prototype.constructor = subClass;
|
|
4535
3882
|
|
|
4536
|
-
|
|
4537
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3883
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
4538
3884
|
}
|
|
4539
3885
|
|
|
4540
|
-
function
|
|
4541
|
-
|
|
3886
|
+
function _setPrototypeOf$1(o, p) {
|
|
3887
|
+
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
3888
|
+
o.__proto__ = p;
|
|
3889
|
+
return o;
|
|
3890
|
+
};
|
|
3891
|
+
return _setPrototypeOf$1(o, p);
|
|
4542
3892
|
}
|
|
4543
3893
|
/**
|
|
4544
3894
|
* Common utilities
|
|
@@ -5266,39 +4616,36 @@
|
|
|
5266
4616
|
|
|
5267
4617
|
var ImageRenderer = /*#__PURE__*/function () {
|
|
5268
4618
|
function ImageRenderer() {
|
|
5269
|
-
_classCallCheck$4(this, ImageRenderer);
|
|
5270
|
-
|
|
5271
4619
|
this.imagePool = void 0;
|
|
5272
4620
|
}
|
|
5273
4621
|
|
|
5274
|
-
|
|
5275
|
-
key: "render",
|
|
5276
|
-
value: function render(context, parsedStyle) {
|
|
5277
|
-
var width = parsedStyle.width,
|
|
5278
|
-
height = parsedStyle.height,
|
|
5279
|
-
img = parsedStyle.img;
|
|
5280
|
-
var image;
|
|
5281
|
-
var iw = width.value;
|
|
5282
|
-
var ih = height.value;
|
|
4622
|
+
var _proto = ImageRenderer.prototype;
|
|
5283
4623
|
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
}
|
|
4624
|
+
_proto.render = function render(context, parsedStyle) {
|
|
4625
|
+
var width = parsedStyle.width,
|
|
4626
|
+
height = parsedStyle.height,
|
|
4627
|
+
img = parsedStyle.img;
|
|
4628
|
+
var image;
|
|
4629
|
+
var iw = width.value;
|
|
4630
|
+
var ih = height.value;
|
|
5292
4631
|
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
4632
|
+
if (g.isString(img)) {
|
|
4633
|
+
// image has been loaded in `mounted` hook
|
|
4634
|
+
image = this.imagePool.getImageSync(img);
|
|
4635
|
+
} else {
|
|
4636
|
+
iw || (iw = img.width);
|
|
4637
|
+
ih || (ih = img.height);
|
|
4638
|
+
image = img;
|
|
5300
4639
|
}
|
|
5301
|
-
|
|
4640
|
+
|
|
4641
|
+
if (image) {
|
|
4642
|
+
// node-canvas will throw the following err:
|
|
4643
|
+
// Error: Image given has not completed loading
|
|
4644
|
+
try {
|
|
4645
|
+
context.drawImage(image, 0, 0, iw, ih);
|
|
4646
|
+
} catch (e) {}
|
|
4647
|
+
}
|
|
4648
|
+
};
|
|
5302
4649
|
|
|
5303
4650
|
return ImageRenderer;
|
|
5304
4651
|
}();
|
|
@@ -5310,157 +4657,154 @@
|
|
|
5310
4657
|
})], ImageRenderer);
|
|
5311
4658
|
|
|
5312
4659
|
var TextRenderer = /*#__PURE__*/function () {
|
|
5313
|
-
function TextRenderer() {
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
4660
|
+
function TextRenderer() {}
|
|
4661
|
+
|
|
4662
|
+
var _proto = TextRenderer.prototype;
|
|
4663
|
+
|
|
4664
|
+
_proto.render = function render(context, parsedStyle, object) {
|
|
4665
|
+
var lineWidth = parsedStyle.lineWidth,
|
|
4666
|
+
textAlign = parsedStyle.textAlign,
|
|
4667
|
+
textBaseline = parsedStyle.textBaseline,
|
|
4668
|
+
lineJoin = parsedStyle.lineJoin,
|
|
4669
|
+
_parsedStyle$miterLim = parsedStyle.miterLimit,
|
|
4670
|
+
miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
|
|
4671
|
+
_parsedStyle$letterSp = parsedStyle.letterSpacing,
|
|
4672
|
+
letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
|
|
4673
|
+
stroke = parsedStyle.stroke,
|
|
4674
|
+
fill = parsedStyle.fill,
|
|
4675
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
4676
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
4677
|
+
opacity = parsedStyle.opacity,
|
|
4678
|
+
metrics = parsedStyle.metrics,
|
|
4679
|
+
dx = parsedStyle.dx,
|
|
4680
|
+
dy = parsedStyle.dy;
|
|
4681
|
+
var font = metrics.font,
|
|
4682
|
+
lines = metrics.lines,
|
|
4683
|
+
height = metrics.height,
|
|
4684
|
+
lineHeight = metrics.lineHeight,
|
|
4685
|
+
lineMetrics = metrics.lineMetrics;
|
|
4686
|
+
context.font = font;
|
|
4687
|
+
context.lineWidth = lineWidth.value;
|
|
4688
|
+
context.textAlign = textAlign.value;
|
|
4689
|
+
context.textBaseline = textBaseline.value;
|
|
4690
|
+
context.lineJoin = lineJoin.value;
|
|
4691
|
+
context.miterLimit = miterLimit;
|
|
4692
|
+
var linePositionY = 0; // handle vertical text baseline
|
|
4693
|
+
|
|
4694
|
+
if (textBaseline.value === 'middle') {
|
|
4695
|
+
linePositionY = -height / 2 - lineHeight / 2;
|
|
4696
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
4697
|
+
linePositionY = -height;
|
|
4698
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
4699
|
+
linePositionY = -lineHeight;
|
|
4700
|
+
} // account for dx & dy
|
|
4701
|
+
|
|
4702
|
+
|
|
4703
|
+
var offsetX = 0;
|
|
4704
|
+
|
|
4705
|
+
if (dx && dx.unit === g.UnitType.kPixels) {
|
|
4706
|
+
offsetX += dx.value;
|
|
4707
|
+
}
|
|
4708
|
+
|
|
4709
|
+
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
4710
|
+
linePositionY += dy.value;
|
|
4711
|
+
} // draw lines line by line
|
|
4712
|
+
|
|
4713
|
+
|
|
4714
|
+
for (var i = 0; i < lines.length; i++) {
|
|
4715
|
+
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
4716
|
+
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
4717
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
4718
|
+
|
|
4719
|
+
if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
|
|
4720
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
4721
|
+
}
|
|
4722
|
+
|
|
4723
|
+
if (!g.isNil(fill)) {
|
|
4724
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
|
|
5362
4725
|
}
|
|
4726
|
+
}
|
|
4727
|
+
};
|
|
5363
4728
|
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
4729
|
+
_proto.drawLetterSpacing = function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity, isStroke) {
|
|
4730
|
+
if (isStroke === void 0) {
|
|
4731
|
+
isStroke = false;
|
|
4732
|
+
} // letterSpacing of 0 means normal, render all texts directly
|
|
5367
4733
|
|
|
5368
4734
|
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
4735
|
+
if (letterSpacing === 0) {
|
|
4736
|
+
if (isStroke) {
|
|
4737
|
+
this.strokeText(context, text, x, y, strokeOpacity);
|
|
4738
|
+
} else {
|
|
4739
|
+
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
4740
|
+
}
|
|
5373
4741
|
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
}
|
|
4742
|
+
return;
|
|
4743
|
+
} // draw text using left align
|
|
5377
4744
|
|
|
5378
|
-
if (!g.isNil(fill)) {
|
|
5379
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
|
|
5380
|
-
}
|
|
5381
|
-
}
|
|
5382
|
-
}
|
|
5383
|
-
}, {
|
|
5384
|
-
key: "drawLetterSpacing",
|
|
5385
|
-
value: function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity) {
|
|
5386
|
-
var isStroke = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false; // letterSpacing of 0 means normal, render all texts directly
|
|
5387
4745
|
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
} else {
|
|
5392
|
-
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
5393
|
-
}
|
|
4746
|
+
var currentTextAlign = context.textAlign;
|
|
4747
|
+
context.textAlign = 'left';
|
|
4748
|
+
var currentPosition = x;
|
|
5394
4749
|
|
|
5395
|
-
|
|
5396
|
-
|
|
4750
|
+
if (textAlign === 'center') {
|
|
4751
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
4752
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
4753
|
+
currentPosition = x - lineMetrics.width;
|
|
4754
|
+
}
|
|
5397
4755
|
|
|
4756
|
+
var stringArray = Array.from(text);
|
|
4757
|
+
var previousWidth = context.measureText(text).width;
|
|
4758
|
+
var currentWidth = 0;
|
|
5398
4759
|
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
var currentPosition = x;
|
|
4760
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
4761
|
+
var currentChar = stringArray[i];
|
|
5402
4762
|
|
|
5403
|
-
if (
|
|
5404
|
-
|
|
5405
|
-
} else
|
|
5406
|
-
currentPosition
|
|
4763
|
+
if (isStroke) {
|
|
4764
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
4765
|
+
} else {
|
|
4766
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
5407
4767
|
}
|
|
5408
4768
|
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
for (var i = 0; i < stringArray.length; ++i) {
|
|
5414
|
-
var currentChar = stringArray[i];
|
|
4769
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
4770
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
4771
|
+
previousWidth = currentWidth;
|
|
4772
|
+
}
|
|
5415
4773
|
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
} else {
|
|
5419
|
-
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
5420
|
-
}
|
|
4774
|
+
context.textAlign = currentTextAlign;
|
|
4775
|
+
};
|
|
5421
4776
|
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
}
|
|
4777
|
+
_proto.fillText = function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
4778
|
+
var currentGlobalAlpha;
|
|
4779
|
+
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
5426
4780
|
|
|
5427
|
-
|
|
4781
|
+
if (applyOpacity) {
|
|
4782
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
4783
|
+
context.globalAlpha = fillOpacity * opacity;
|
|
5428
4784
|
}
|
|
5429
|
-
}, {
|
|
5430
|
-
key: "fillText",
|
|
5431
|
-
value: function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
5432
|
-
var currentGlobalAlpha;
|
|
5433
|
-
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
5434
|
-
|
|
5435
|
-
if (applyOpacity) {
|
|
5436
|
-
currentGlobalAlpha = context.globalAlpha;
|
|
5437
|
-
context.globalAlpha = fillOpacity * opacity;
|
|
5438
|
-
}
|
|
5439
4785
|
|
|
5440
|
-
|
|
4786
|
+
context.fillText(text, x, y);
|
|
5441
4787
|
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
}
|
|
4788
|
+
if (applyOpacity) {
|
|
4789
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5445
4790
|
}
|
|
5446
|
-
}
|
|
5447
|
-
key: "strokeText",
|
|
5448
|
-
value: function strokeText(context, text, x, y, strokeOpacity) {
|
|
5449
|
-
var currentGlobalAlpha;
|
|
5450
|
-
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
4791
|
+
};
|
|
5451
4792
|
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
}
|
|
4793
|
+
_proto.strokeText = function strokeText(context, text, x, y, strokeOpacity) {
|
|
4794
|
+
var currentGlobalAlpha;
|
|
4795
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
5456
4796
|
|
|
5457
|
-
|
|
4797
|
+
if (applyOpacity) {
|
|
4798
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
4799
|
+
context.globalAlpha = strokeOpacity;
|
|
4800
|
+
}
|
|
5458
4801
|
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
4802
|
+
context.strokeText(text, x, y);
|
|
4803
|
+
|
|
4804
|
+
if (applyOpacity) {
|
|
4805
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5462
4806
|
}
|
|
5463
|
-
}
|
|
4807
|
+
};
|
|
5464
4808
|
|
|
5465
4809
|
return TextRenderer;
|
|
5466
4810
|
}();
|
|
@@ -5471,177 +4815,170 @@
|
|
|
5471
4815
|
|
|
5472
4816
|
var DefaultRenderer = /*#__PURE__*/function () {
|
|
5473
4817
|
function DefaultRenderer() {
|
|
5474
|
-
_classCallCheck$4(this, DefaultRenderer);
|
|
5475
|
-
|
|
5476
4818
|
this.imagePool = void 0;
|
|
5477
4819
|
}
|
|
5478
4820
|
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
}
|
|
4821
|
+
var _proto = DefaultRenderer.prototype;
|
|
4822
|
+
|
|
4823
|
+
_proto.render = function render(context, parsedStyle, object, renderingService) {
|
|
4824
|
+
var fill = parsedStyle.fill,
|
|
4825
|
+
opacity = parsedStyle.opacity,
|
|
4826
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
4827
|
+
stroke = parsedStyle.stroke,
|
|
4828
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
4829
|
+
lineWidth = parsedStyle.lineWidth,
|
|
4830
|
+
lineCap = parsedStyle.lineCap,
|
|
4831
|
+
lineJoin = parsedStyle.lineJoin,
|
|
4832
|
+
shadowColor = parsedStyle.shadowColor,
|
|
4833
|
+
filter = parsedStyle.filter,
|
|
4834
|
+
miterLimit = parsedStyle.miterLimit;
|
|
4835
|
+
var hasFill = !g.isNil(fill) && !fill.isNone;
|
|
4836
|
+
var hasStroke = !g.isNil(stroke) && !stroke.isNone;
|
|
4837
|
+
var isFillTransparent = fill.alpha === 0;
|
|
4838
|
+
|
|
4839
|
+
if (hasFill) {
|
|
4840
|
+
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
4841
|
+
context.globalAlpha = fillOpacity.value;
|
|
4842
|
+
this.fill(context, object, fill, renderingService);
|
|
4843
|
+
context.globalAlpha = opacity.value;
|
|
4844
|
+
} else {
|
|
4845
|
+
this.fill(context, object, fill, renderingService);
|
|
5505
4846
|
}
|
|
4847
|
+
}
|
|
5506
4848
|
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
4849
|
+
if (hasStroke) {
|
|
4850
|
+
if (lineWidth && lineWidth.value > 0) {
|
|
4851
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
5510
4852
|
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
4853
|
+
if (applyOpacity) {
|
|
4854
|
+
context.globalAlpha = strokeOpacity.value;
|
|
4855
|
+
}
|
|
5514
4856
|
|
|
5515
|
-
|
|
4857
|
+
context.lineWidth = lineWidth.value;
|
|
5516
4858
|
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
4859
|
+
if (!g.isNil(miterLimit)) {
|
|
4860
|
+
context.miterLimit = miterLimit;
|
|
4861
|
+
}
|
|
5520
4862
|
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
4863
|
+
if (!g.isNil(lineCap)) {
|
|
4864
|
+
context.lineCap = lineCap.value;
|
|
4865
|
+
}
|
|
5524
4866
|
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
4867
|
+
if (!g.isNil(lineJoin)) {
|
|
4868
|
+
context.lineJoin = lineJoin.value;
|
|
4869
|
+
}
|
|
5528
4870
|
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
}
|
|
4871
|
+
var oldShadowBlur;
|
|
4872
|
+
var oldShadowColor;
|
|
4873
|
+
var oldFilter;
|
|
4874
|
+
var hasShadowColor = !g.isNil(shadowColor);
|
|
4875
|
+
var hasFilter = !g.isNil(filter);
|
|
4876
|
+
|
|
4877
|
+
if (hasShadowColor) {
|
|
4878
|
+
// prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
|
|
4879
|
+
// save shadow blur
|
|
4880
|
+
oldShadowBlur = context.shadowBlur;
|
|
4881
|
+
oldShadowColor = context.shadowColor;
|
|
4882
|
+
|
|
4883
|
+
if (!g.isNil(oldShadowBlur)) {
|
|
4884
|
+
context.shadowColor = 'transparent';
|
|
4885
|
+
context.shadowBlur = 0;
|
|
5545
4886
|
}
|
|
4887
|
+
}
|
|
5546
4888
|
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
4889
|
+
if (hasFilter) {
|
|
4890
|
+
// save drop-shadow filter
|
|
4891
|
+
oldFilter = context.filter;
|
|
5550
4892
|
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
}
|
|
4893
|
+
if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
4894
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
5554
4895
|
}
|
|
4896
|
+
}
|
|
5555
4897
|
|
|
5556
|
-
|
|
4898
|
+
var drawStroke = hasFill && !isFillTransparent;
|
|
5557
4899
|
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
4900
|
+
if (drawStroke) {
|
|
4901
|
+
this.stroke(context, object, stroke, renderingService);
|
|
4902
|
+
} // restore shadow blur
|
|
5561
4903
|
|
|
5562
4904
|
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
4905
|
+
if (hasShadowColor) {
|
|
4906
|
+
context.shadowColor = oldShadowColor;
|
|
4907
|
+
context.shadowBlur = oldShadowBlur;
|
|
4908
|
+
} // restore filters
|
|
5567
4909
|
|
|
5568
4910
|
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
4911
|
+
if (hasFilter) {
|
|
4912
|
+
context.filter = oldFilter;
|
|
4913
|
+
}
|
|
5572
4914
|
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
}
|
|
4915
|
+
if (!drawStroke) {
|
|
4916
|
+
this.stroke(context, object, stroke, renderingService);
|
|
5576
4917
|
}
|
|
5577
4918
|
}
|
|
5578
4919
|
}
|
|
5579
|
-
}
|
|
5580
|
-
key: "fill",
|
|
5581
|
-
value: function fill(context, object, _fill, renderingService) {
|
|
5582
|
-
var _this = this;
|
|
4920
|
+
};
|
|
5583
4921
|
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
context.fillStyle = _this.getColor(gradient, object, context);
|
|
5587
|
-
context.fill();
|
|
5588
|
-
});
|
|
5589
|
-
} else {
|
|
5590
|
-
if (g.isPattern(_fill)) {
|
|
5591
|
-
context.fillStyle = this.getPattern(_fill, object, context, renderingService);
|
|
5592
|
-
}
|
|
4922
|
+
_proto.fill = function fill(context, object, _fill, renderingService) {
|
|
4923
|
+
var _this = this;
|
|
5593
4924
|
|
|
4925
|
+
if (Array.isArray(_fill)) {
|
|
4926
|
+
_fill.forEach(function (gradient) {
|
|
4927
|
+
context.fillStyle = _this.getColor(gradient, object, context);
|
|
5594
4928
|
context.fill();
|
|
4929
|
+
});
|
|
4930
|
+
} else {
|
|
4931
|
+
if (g.isPattern(_fill)) {
|
|
4932
|
+
context.fillStyle = this.getPattern(_fill, object, context, renderingService);
|
|
5595
4933
|
}
|
|
4934
|
+
|
|
4935
|
+
context.fill();
|
|
5596
4936
|
}
|
|
5597
|
-
}
|
|
5598
|
-
key: "stroke",
|
|
5599
|
-
value: function stroke(context, object, _stroke, renderingService) {
|
|
5600
|
-
var _this2 = this;
|
|
4937
|
+
};
|
|
5601
4938
|
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
5605
|
-
context.stroke();
|
|
5606
|
-
});
|
|
5607
|
-
} else {
|
|
5608
|
-
if (g.isPattern(_stroke)) {
|
|
5609
|
-
context.strokeStyle = this.getPattern(_stroke, object, context, renderingService);
|
|
5610
|
-
}
|
|
4939
|
+
_proto.stroke = function stroke(context, object, _stroke, renderingService) {
|
|
4940
|
+
var _this2 = this;
|
|
5611
4941
|
|
|
4942
|
+
if (Array.isArray(_stroke)) {
|
|
4943
|
+
_stroke.forEach(function (gradient) {
|
|
4944
|
+
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
5612
4945
|
context.stroke();
|
|
5613
|
-
}
|
|
5614
|
-
}
|
|
5615
|
-
}, {
|
|
5616
|
-
key: "getPattern",
|
|
5617
|
-
value: function getPattern(pattern, object, context, renderingService) {
|
|
5618
|
-
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, function () {
|
|
5619
|
-
// set dirty rectangle flag
|
|
5620
|
-
object.renderable.dirty = true;
|
|
5621
|
-
renderingService.dirtify();
|
|
5622
4946
|
});
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
key: "getColor",
|
|
5627
|
-
value: function getColor(parsedColor, object, context) {
|
|
5628
|
-
var color;
|
|
5629
|
-
|
|
5630
|
-
if (parsedColor.type === g.GradientType.LinearGradient || parsedColor.type === g.GradientType.RadialGradient) {
|
|
5631
|
-
var bounds = object.getGeometryBounds();
|
|
5632
|
-
var width = bounds && bounds.halfExtents[0] * 2 || 1;
|
|
5633
|
-
var height = bounds && bounds.halfExtents[1] * 2 || 1;
|
|
5634
|
-
color = this.imagePool.getOrCreateGradient(_objectSpread2(_objectSpread2({
|
|
5635
|
-
type: parsedColor.type
|
|
5636
|
-
}, parsedColor.value), {}, {
|
|
5637
|
-
width: width,
|
|
5638
|
-
height: height
|
|
5639
|
-
}), context);
|
|
4947
|
+
} else {
|
|
4948
|
+
if (g.isPattern(_stroke)) {
|
|
4949
|
+
context.strokeStyle = this.getPattern(_stroke, object, context, renderingService);
|
|
5640
4950
|
}
|
|
5641
4951
|
|
|
5642
|
-
|
|
4952
|
+
context.stroke();
|
|
4953
|
+
}
|
|
4954
|
+
};
|
|
4955
|
+
|
|
4956
|
+
_proto.getPattern = function getPattern(pattern, object, context, renderingService) {
|
|
4957
|
+
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, function () {
|
|
4958
|
+
// set dirty rectangle flag
|
|
4959
|
+
object.renderable.dirty = true;
|
|
4960
|
+
renderingService.dirtify();
|
|
4961
|
+
});
|
|
4962
|
+
return canvasPattern;
|
|
4963
|
+
};
|
|
4964
|
+
|
|
4965
|
+
_proto.getColor = function getColor(parsedColor, object, context) {
|
|
4966
|
+
var color;
|
|
4967
|
+
|
|
4968
|
+
if (parsedColor.type === g.GradientType.LinearGradient || parsedColor.type === g.GradientType.RadialGradient) {
|
|
4969
|
+
var bounds = object.getGeometryBounds();
|
|
4970
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 1;
|
|
4971
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 1;
|
|
4972
|
+
color = this.imagePool.getOrCreateGradient(_extends({
|
|
4973
|
+
type: parsedColor.type
|
|
4974
|
+
}, parsedColor.value, {
|
|
4975
|
+
width: width,
|
|
4976
|
+
height: height
|
|
4977
|
+
}), context);
|
|
5643
4978
|
}
|
|
5644
|
-
|
|
4979
|
+
|
|
4980
|
+
return color;
|
|
4981
|
+
};
|
|
5645
4982
|
|
|
5646
4983
|
return DefaultRenderer;
|
|
5647
4984
|
}();
|
|
@@ -5651,17 +4988,13 @@
|
|
|
5651
4988
|
DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
|
|
5652
4989
|
|
|
5653
4990
|
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
var _super = _createSuper$1(RectRenderer);
|
|
4991
|
+
_inheritsLoose$1(RectRenderer, _DefaultRenderer);
|
|
5657
4992
|
|
|
5658
4993
|
function RectRenderer() {
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
return _super.apply(this, arguments);
|
|
4994
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5662
4995
|
}
|
|
5663
4996
|
|
|
5664
|
-
return
|
|
4997
|
+
return RectRenderer;
|
|
5665
4998
|
}(DefaultRenderer);
|
|
5666
4999
|
|
|
5667
5000
|
RectRenderer = __decorate([g.singleton({
|
|
@@ -5669,17 +5002,13 @@
|
|
|
5669
5002
|
})], RectRenderer);
|
|
5670
5003
|
|
|
5671
5004
|
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
var _super = _createSuper$1(CircleRenderer);
|
|
5005
|
+
_inheritsLoose$1(CircleRenderer, _DefaultRenderer);
|
|
5675
5006
|
|
|
5676
5007
|
function CircleRenderer() {
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
return _super.apply(this, arguments);
|
|
5008
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5680
5009
|
}
|
|
5681
5010
|
|
|
5682
|
-
return
|
|
5011
|
+
return CircleRenderer;
|
|
5683
5012
|
}(DefaultRenderer);
|
|
5684
5013
|
|
|
5685
5014
|
CircleRenderer = __decorate([g.singleton({
|
|
@@ -5687,17 +5016,13 @@
|
|
|
5687
5016
|
})], CircleRenderer);
|
|
5688
5017
|
|
|
5689
5018
|
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
var _super = _createSuper$1(EllipseRenderer);
|
|
5019
|
+
_inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
|
|
5693
5020
|
|
|
5694
5021
|
function EllipseRenderer() {
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
return _super.apply(this, arguments);
|
|
5022
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5698
5023
|
}
|
|
5699
5024
|
|
|
5700
|
-
return
|
|
5025
|
+
return EllipseRenderer;
|
|
5701
5026
|
}(DefaultRenderer);
|
|
5702
5027
|
|
|
5703
5028
|
EllipseRenderer = __decorate([g.singleton({
|
|
@@ -5705,17 +5030,13 @@
|
|
|
5705
5030
|
})], EllipseRenderer);
|
|
5706
5031
|
|
|
5707
5032
|
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
var _super = _createSuper$1(LineRenderer);
|
|
5033
|
+
_inheritsLoose$1(LineRenderer, _DefaultRenderer);
|
|
5711
5034
|
|
|
5712
5035
|
function LineRenderer() {
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
return _super.apply(this, arguments);
|
|
5036
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5716
5037
|
}
|
|
5717
5038
|
|
|
5718
|
-
return
|
|
5039
|
+
return LineRenderer;
|
|
5719
5040
|
}(DefaultRenderer);
|
|
5720
5041
|
|
|
5721
5042
|
LineRenderer = __decorate([g.singleton({
|
|
@@ -5723,17 +5044,13 @@
|
|
|
5723
5044
|
})], LineRenderer);
|
|
5724
5045
|
|
|
5725
5046
|
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
var _super = _createSuper$1(PolylineRenderer);
|
|
5047
|
+
_inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
|
|
5729
5048
|
|
|
5730
5049
|
function PolylineRenderer() {
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
return _super.apply(this, arguments);
|
|
5050
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5734
5051
|
}
|
|
5735
5052
|
|
|
5736
|
-
return
|
|
5053
|
+
return PolylineRenderer;
|
|
5737
5054
|
}(DefaultRenderer);
|
|
5738
5055
|
|
|
5739
5056
|
PolylineRenderer = __decorate([g.singleton({
|
|
@@ -5741,17 +5058,13 @@
|
|
|
5741
5058
|
})], PolylineRenderer);
|
|
5742
5059
|
|
|
5743
5060
|
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
var _super = _createSuper$1(PolygonRenderer);
|
|
5061
|
+
_inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
|
|
5747
5062
|
|
|
5748
5063
|
function PolygonRenderer() {
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
return _super.apply(this, arguments);
|
|
5064
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5752
5065
|
}
|
|
5753
5066
|
|
|
5754
|
-
return
|
|
5067
|
+
return PolygonRenderer;
|
|
5755
5068
|
}(DefaultRenderer);
|
|
5756
5069
|
|
|
5757
5070
|
PolygonRenderer = __decorate([g.singleton({
|
|
@@ -5759,17 +5072,13 @@
|
|
|
5759
5072
|
})], PolygonRenderer);
|
|
5760
5073
|
|
|
5761
5074
|
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
var _super = _createSuper$1(PathRenderer);
|
|
5075
|
+
_inheritsLoose$1(PathRenderer, _DefaultRenderer);
|
|
5765
5076
|
|
|
5766
5077
|
function PathRenderer() {
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
return _super.apply(this, arguments);
|
|
5078
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
5770
5079
|
}
|
|
5771
5080
|
|
|
5772
|
-
return
|
|
5081
|
+
return PathRenderer;
|
|
5773
5082
|
}(DefaultRenderer);
|
|
5774
5083
|
|
|
5775
5084
|
PathRenderer = __decorate([g.singleton({
|
|
@@ -5787,8 +5096,6 @@
|
|
|
5787
5096
|
|
|
5788
5097
|
var CanvasRendererPlugin = CanvasRendererPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
5789
5098
|
function CanvasRendererPlugin() {
|
|
5790
|
-
_classCallCheck$4(this, CanvasRendererPlugin);
|
|
5791
|
-
|
|
5792
5099
|
this.canvasConfig = void 0;
|
|
5793
5100
|
this.camera = void 0;
|
|
5794
5101
|
this.contextService = void 0;
|
|
@@ -5807,476 +5114,466 @@
|
|
|
5807
5114
|
this.tmpMat4 = create$1$1();
|
|
5808
5115
|
}
|
|
5809
5116
|
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5117
|
+
var _proto = CanvasRendererPlugin.prototype;
|
|
5118
|
+
|
|
5119
|
+
_proto.apply = function apply(renderingService) {
|
|
5120
|
+
var _this = this;
|
|
5814
5121
|
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5122
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
5123
|
+
var object = e.target; // remove r-bush node
|
|
5124
|
+
// @ts-ignore
|
|
5818
5125
|
|
|
5819
|
-
|
|
5126
|
+
var rBushNode = object.rBushNode;
|
|
5820
5127
|
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5128
|
+
if (rBushNode.aabb) {
|
|
5129
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5130
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5131
|
+
}
|
|
5132
|
+
};
|
|
5826
5133
|
|
|
5827
|
-
|
|
5828
|
-
|
|
5134
|
+
var handleCulled = function handleCulled(e) {
|
|
5135
|
+
var object = e.target; // @ts-ignore
|
|
5829
5136
|
|
|
5830
|
-
|
|
5137
|
+
var rBushNode = object.rBushNode;
|
|
5831
5138
|
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5139
|
+
if (rBushNode.aabb) {
|
|
5140
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5141
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5142
|
+
}
|
|
5143
|
+
};
|
|
5837
5144
|
|
|
5838
|
-
|
|
5839
|
-
|
|
5145
|
+
renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
5146
|
+
var _this$canvasConfig, width, height, context;
|
|
5840
5147
|
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5148
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
5149
|
+
while (1) {
|
|
5150
|
+
switch (_context.prev = _context.next) {
|
|
5151
|
+
case 0:
|
|
5152
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5846
5153
|
|
|
5847
|
-
|
|
5154
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.CULLED, handleCulled); // clear fullscreen
|
|
5848
5155
|
|
|
5849
5156
|
|
|
5850
|
-
|
|
5851
|
-
|
|
5157
|
+
_this$canvasConfig = _this.canvasConfig, width = _this$canvasConfig.width, height = _this$canvasConfig.height;
|
|
5158
|
+
context = _this.contextService.getContext();
|
|
5852
5159
|
|
|
5853
|
-
|
|
5160
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5854
5161
|
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
}
|
|
5162
|
+
case 5:
|
|
5163
|
+
case "end":
|
|
5164
|
+
return _context.stop();
|
|
5859
5165
|
}
|
|
5860
|
-
}
|
|
5861
|
-
})
|
|
5862
|
-
|
|
5863
|
-
|
|
5166
|
+
}
|
|
5167
|
+
}, _callee);
|
|
5168
|
+
})));
|
|
5169
|
+
renderingService.hooks.destroy.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5170
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5864
5171
|
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5172
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.CULLED, handleCulled);
|
|
5173
|
+
});
|
|
5174
|
+
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5175
|
+
var context = _this.contextService.getContext();
|
|
5176
|
+
|
|
5177
|
+
var _this$canvasConfig2 = _this.canvasConfig,
|
|
5178
|
+
width = _this$canvasConfig2.width,
|
|
5179
|
+
height = _this$canvasConfig2.height; // clear fullscreen when:
|
|
5180
|
+
// 1. dirty rectangle rendering disabled
|
|
5181
|
+
// 2. camera changed
|
|
5869
5182
|
|
|
5870
|
-
|
|
5871
|
-
width = _this$canvasConfig2.width,
|
|
5872
|
-
height = _this$canvasConfig2.height; // clear fullscreen when:
|
|
5873
|
-
// 1. dirty rectangle rendering disabled
|
|
5874
|
-
// 2. camera changed
|
|
5183
|
+
_this.clearFullScreen = _this.shouldClearFullScreen();
|
|
5875
5184
|
|
|
5876
|
-
|
|
5185
|
+
if (context) {
|
|
5186
|
+
context.save();
|
|
5877
5187
|
|
|
5878
|
-
if (
|
|
5879
|
-
|
|
5188
|
+
if (_this.clearFullScreen) {
|
|
5189
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5190
|
+
} // account for camera's world matrix
|
|
5880
5191
|
|
|
5881
|
-
if (_this.clearFullScreen) {
|
|
5882
|
-
_this.clearRect(context, 0, 0, width, height);
|
|
5883
|
-
} // account for camera's world matrix
|
|
5884
5192
|
|
|
5193
|
+
_this.applyTransform(context, _this.camera.getOrthoMatrix());
|
|
5194
|
+
}
|
|
5195
|
+
}); // render at the end of frame
|
|
5885
5196
|
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
}); // render at the end of frame
|
|
5889
|
-
|
|
5890
|
-
renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5891
|
-
var context = _this.contextService.getContext();
|
|
5892
|
-
|
|
5893
|
-
if (_this.clearFullScreen) ;else {
|
|
5894
|
-
// merge removed AABB
|
|
5895
|
-
var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs( // should not ignore group since clipPath may affect its children
|
|
5896
|
-
// this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
|
|
5897
|
-
_this.renderQueue)].concat(_toConsumableArray$2(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
5898
|
-
var minX = _ref2.minX,
|
|
5899
|
-
minY = _ref2.minY,
|
|
5900
|
-
maxX = _ref2.maxX,
|
|
5901
|
-
maxY = _ref2.maxY;
|
|
5902
|
-
var aabb = new g.AABB();
|
|
5903
|
-
aabb.setMinMax(fromValues$2(minX, minY, 0), fromValues$2(maxX, maxY, 0));
|
|
5904
|
-
return aabb;
|
|
5905
|
-
}))));
|
|
5906
|
-
|
|
5907
|
-
_this.removedRBushNodeAABBs = [];
|
|
5908
|
-
|
|
5909
|
-
if (g.AABB.isEmpty(dirtyRenderBounds)) {
|
|
5910
|
-
_this.renderQueue = [];
|
|
5911
|
-
return;
|
|
5912
|
-
} // clear & clip dirty rectangle
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
|
|
5916
|
-
x = _this$convertAABB2Rec.x,
|
|
5917
|
-
y = _this$convertAABB2Rec.y,
|
|
5918
|
-
width = _this$convertAABB2Rec.width,
|
|
5919
|
-
height = _this$convertAABB2Rec.height;
|
|
5920
|
-
|
|
5921
|
-
_this.clearRect(context, x, y, width, height);
|
|
5922
|
-
|
|
5923
|
-
context.beginPath();
|
|
5924
|
-
context.rect(x, y, width, height);
|
|
5925
|
-
context.clip(); // draw dirty rectangle
|
|
5926
|
-
// if (enableDirtyRectangleRenderingDebug) {
|
|
5927
|
-
// context.lineWidth = 4;
|
|
5928
|
-
// context.strokeStyle = `rgba(${Math.random() * 255}, ${Math.random() * 255}, ${
|
|
5929
|
-
// Math.random() * 255
|
|
5930
|
-
// }, 1)`;
|
|
5931
|
-
// context.strokeRect(x, y, width, height);
|
|
5932
|
-
// }
|
|
5933
|
-
// search objects intersect with dirty rectangle
|
|
5934
|
-
|
|
5935
|
-
var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds); // do rendering
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
dirtyObjects // sort by z-index
|
|
5939
|
-
.sort(function (a, b) {
|
|
5940
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
5941
|
-
}).forEach(function (object) {
|
|
5942
|
-
// culled object should not be rendered
|
|
5943
|
-
if (object && object.isVisible() && !object.isCulled()) {
|
|
5944
|
-
_this.renderDisplayObject(object, renderingService);
|
|
5945
|
-
}
|
|
5946
|
-
}); // save dirty AABBs in last frame
|
|
5197
|
+
renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5198
|
+
var context = _this.contextService.getContext();
|
|
5947
5199
|
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5200
|
+
if (_this.clearFullScreen) ;else {
|
|
5201
|
+
// merge removed AABB
|
|
5202
|
+
var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs( // should not ignore group since clipPath may affect its children
|
|
5203
|
+
// this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
|
|
5204
|
+
_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
5205
|
+
var minX = _ref2.minX,
|
|
5206
|
+
minY = _ref2.minY,
|
|
5207
|
+
maxX = _ref2.maxX,
|
|
5208
|
+
maxY = _ref2.maxY;
|
|
5209
|
+
var aabb = new g.AABB();
|
|
5210
|
+
aabb.setMinMax(fromValues$2(minX, minY, 0), fromValues$2(maxX, maxY, 0));
|
|
5211
|
+
return aabb;
|
|
5212
|
+
})));
|
|
5951
5213
|
|
|
5214
|
+
_this.removedRBushNodeAABBs = [];
|
|
5952
5215
|
|
|
5216
|
+
if (g.AABB.isEmpty(dirtyRenderBounds)) {
|
|
5953
5217
|
_this.renderQueue = [];
|
|
5954
|
-
|
|
5218
|
+
return;
|
|
5219
|
+
} // clear & clip dirty rectangle
|
|
5955
5220
|
|
|
5956
|
-
_this.restoreStack.forEach(function (s) {
|
|
5957
|
-
context.restore();
|
|
5958
|
-
}); // clear restore stack
|
|
5959
5221
|
|
|
5222
|
+
var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
|
|
5223
|
+
x = _this$convertAABB2Rec.x,
|
|
5224
|
+
y = _this$convertAABB2Rec.y,
|
|
5225
|
+
width = _this$convertAABB2Rec.width,
|
|
5226
|
+
height = _this$convertAABB2Rec.height;
|
|
5960
5227
|
|
|
5961
|
-
_this.
|
|
5962
|
-
|
|
5963
|
-
context.
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
if (
|
|
5967
|
-
|
|
5968
|
-
|
|
5228
|
+
_this.clearRect(context, x, y, width, height);
|
|
5229
|
+
|
|
5230
|
+
context.beginPath();
|
|
5231
|
+
context.rect(x, y, width, height);
|
|
5232
|
+
context.clip(); // draw dirty rectangle
|
|
5233
|
+
// if (enableDirtyRectangleRenderingDebug) {
|
|
5234
|
+
// context.lineWidth = 4;
|
|
5235
|
+
// context.strokeStyle = `rgba(${Math.random() * 255}, ${Math.random() * 255}, ${
|
|
5236
|
+
// Math.random() * 255
|
|
5237
|
+
// }, 1)`;
|
|
5238
|
+
// context.strokeRect(x, y, width, height);
|
|
5239
|
+
// }
|
|
5240
|
+
// search objects intersect with dirty rectangle
|
|
5241
|
+
|
|
5242
|
+
var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds); // do rendering
|
|
5243
|
+
|
|
5244
|
+
|
|
5245
|
+
dirtyObjects // sort by z-index
|
|
5246
|
+
.sort(function (a, b) {
|
|
5247
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
5248
|
+
}).forEach(function (object) {
|
|
5249
|
+
// culled object should not be rendered
|
|
5250
|
+
if (object && object.isVisible() && !object.isCulled()) {
|
|
5969
5251
|
_this.renderDisplayObject(object, renderingService);
|
|
5970
5252
|
}
|
|
5971
|
-
}
|
|
5972
|
-
|
|
5973
|
-
|
|
5253
|
+
}); // save dirty AABBs in last frame
|
|
5254
|
+
|
|
5255
|
+
_this.renderQueue.forEach(function (object) {
|
|
5256
|
+
_this.saveDirtyAABB(object);
|
|
5257
|
+
}); // clear queue
|
|
5258
|
+
|
|
5259
|
+
|
|
5260
|
+
_this.renderQueue = [];
|
|
5261
|
+
} // pop restore stack, eg. root -> parent -> child
|
|
5262
|
+
|
|
5263
|
+
_this.restoreStack.forEach(function (s) {
|
|
5264
|
+
context.restore();
|
|
5265
|
+
}); // clear restore stack
|
|
5266
|
+
|
|
5267
|
+
|
|
5268
|
+
_this.restoreStack = [];
|
|
5269
|
+
_this.clearFullScreen = false;
|
|
5270
|
+
context.restore();
|
|
5271
|
+
});
|
|
5272
|
+
renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
|
|
5273
|
+
if (_this.clearFullScreen) {
|
|
5274
|
+
if (object.isVisible() && !object.isCulled()) {
|
|
5275
|
+
// render immediately
|
|
5276
|
+
_this.renderDisplayObject(object, renderingService);
|
|
5974
5277
|
}
|
|
5975
|
-
}
|
|
5278
|
+
} else {
|
|
5279
|
+
// render at the end of frame
|
|
5280
|
+
_this.renderQueue.push(object);
|
|
5281
|
+
}
|
|
5282
|
+
});
|
|
5283
|
+
};
|
|
5284
|
+
|
|
5285
|
+
_proto.clearRect = function clearRect(context, x, y, width, height) {
|
|
5286
|
+
context.clearRect(x, y, width, height);
|
|
5287
|
+
var background = this.canvasConfig.background;
|
|
5288
|
+
|
|
5289
|
+
if (background) {
|
|
5290
|
+
context.fillStyle = background;
|
|
5291
|
+
context.fillRect(x, y, width, height);
|
|
5976
5292
|
}
|
|
5977
|
-
}
|
|
5978
|
-
key: "clearRect",
|
|
5979
|
-
value: function clearRect(context, x, y, width, height) {
|
|
5980
|
-
context.clearRect(x, y, width, height);
|
|
5981
|
-
var background = this.canvasConfig.background;
|
|
5293
|
+
};
|
|
5982
5294
|
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5295
|
+
_proto.renderDisplayObject = function renderDisplayObject(object, renderingService) {
|
|
5296
|
+
var context = this.contextService.getContext(); // restore to its parent
|
|
5297
|
+
|
|
5298
|
+
var parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5299
|
+
|
|
5300
|
+
while (parent && object.parentNode !== parent) {
|
|
5301
|
+
context.restore();
|
|
5302
|
+
this.restoreStack.pop();
|
|
5303
|
+
parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5987
5304
|
}
|
|
5988
|
-
}, {
|
|
5989
|
-
key: "renderDisplayObject",
|
|
5990
|
-
value: function renderDisplayObject(object, renderingService) {
|
|
5991
|
-
var context = this.contextService.getContext(); // restore to its parent
|
|
5992
5305
|
|
|
5993
|
-
|
|
5306
|
+
var nodeName = object.nodeName;
|
|
5994
5307
|
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5308
|
+
if (this.styleRendererFactoryCache[nodeName] === undefined) {
|
|
5309
|
+
this.styleRendererFactoryCache[nodeName] = this.styleRendererFactory(nodeName);
|
|
5310
|
+
}
|
|
5311
|
+
|
|
5312
|
+
var styleRenderer = this.styleRendererFactoryCache[nodeName]; // reset transformation
|
|
5313
|
+
|
|
5314
|
+
context.save(); // apply RTS transformation in world space
|
|
5315
|
+
|
|
5316
|
+
this.applyTransform(context, object.getLocalTransform()); // clip path
|
|
5317
|
+
|
|
5318
|
+
var clipPathShape = object.style.clipPath;
|
|
5319
|
+
|
|
5320
|
+
if (clipPathShape) {
|
|
5321
|
+
context.save(); // const parentTransform =
|
|
5322
|
+
// (object.parentElement as DisplayObject)?.getWorldTransform() || mat4.identity(this.tmpMat4);
|
|
5323
|
+
// mat4.multiply(this.tmpMat4, parentTransform, clipPathShape.getLocalTransform());
|
|
5324
|
+
// apply clip shape's RTS
|
|
5325
|
+
|
|
5326
|
+
this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
|
|
5327
|
+
|
|
5328
|
+
if (this.pathGeneratorFactoryCache[clipPathShape.nodeName] === undefined) {
|
|
5329
|
+
this.pathGeneratorFactoryCache[clipPathShape.nodeName] = this.pathGeneratorFactory(clipPathShape.nodeName);
|
|
5999
5330
|
}
|
|
6000
5331
|
|
|
6001
|
-
var
|
|
5332
|
+
var _generatePath = this.pathGeneratorFactoryCache[clipPathShape.nodeName];
|
|
5333
|
+
|
|
5334
|
+
if (_generatePath) {
|
|
5335
|
+
this.useAnchor(context, clipPathShape);
|
|
5336
|
+
context.beginPath();
|
|
5337
|
+
|
|
5338
|
+
_generatePath(context, clipPathShape.parsedStyle);
|
|
6002
5339
|
|
|
6003
|
-
|
|
6004
|
-
this.styleRendererFactoryCache[nodeName] = this.styleRendererFactory(nodeName);
|
|
5340
|
+
context.closePath();
|
|
6005
5341
|
}
|
|
6006
5342
|
|
|
6007
|
-
|
|
5343
|
+
context.restore();
|
|
5344
|
+
context.clip();
|
|
5345
|
+
} // fill & stroke
|
|
6008
5346
|
|
|
6009
|
-
context.save(); // apply RTS transformation in world space
|
|
6010
5347
|
|
|
6011
|
-
|
|
5348
|
+
context.save(); // apply attributes to context
|
|
6012
5349
|
|
|
6013
|
-
|
|
5350
|
+
this.applyAttributesToContext(context, object); // apply anchor in local space
|
|
6014
5351
|
|
|
6015
|
-
|
|
6016
|
-
context.save(); // const parentTransform =
|
|
6017
|
-
// (object.parentElement as DisplayObject)?.getWorldTransform() || mat4.identity(this.tmpMat4);
|
|
6018
|
-
// mat4.multiply(this.tmpMat4, parentTransform, clipPathShape.getLocalTransform());
|
|
6019
|
-
// apply clip shape's RTS
|
|
5352
|
+
this.useAnchor(context, object); // generate path in local space
|
|
6020
5353
|
|
|
6021
|
-
|
|
5354
|
+
if (this.pathGeneratorFactoryCache[object.nodeName] === undefined) {
|
|
5355
|
+
this.pathGeneratorFactoryCache[object.nodeName] = this.pathGeneratorFactory(object.nodeName);
|
|
5356
|
+
}
|
|
6022
5357
|
|
|
6023
|
-
|
|
6024
|
-
this.pathGeneratorFactoryCache[clipPathShape.nodeName] = this.pathGeneratorFactory(clipPathShape.nodeName);
|
|
6025
|
-
}
|
|
5358
|
+
var generatePath = this.pathGeneratorFactoryCache[object.nodeName];
|
|
6026
5359
|
|
|
6027
|
-
|
|
5360
|
+
if (generatePath) {
|
|
5361
|
+
context.beginPath();
|
|
5362
|
+
generatePath(context, object.parsedStyle);
|
|
6028
5363
|
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
5364
|
+
if (object.nodeName !== g.Shape.LINE && object.nodeName !== g.Shape.PATH && object.nodeName !== g.Shape.POLYLINE) {
|
|
5365
|
+
context.closePath();
|
|
5366
|
+
}
|
|
5367
|
+
} // fill & stroke
|
|
6032
5368
|
|
|
6033
|
-
_generatePath(context, clipPathShape.parsedStyle);
|
|
6034
5369
|
|
|
6035
|
-
|
|
6036
|
-
|
|
5370
|
+
if (styleRenderer) {
|
|
5371
|
+
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
5372
|
+
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
6037
5373
|
|
|
6038
|
-
context.restore();
|
|
6039
|
-
context.clip();
|
|
6040
|
-
} // fill & stroke
|
|
6041
5374
|
|
|
5375
|
+
context.restore(); // finish rendering, clear dirty flag
|
|
5376
|
+
|
|
5377
|
+
object.renderable.dirty = false;
|
|
5378
|
+
this.restoreStack.push(object);
|
|
5379
|
+
};
|
|
5380
|
+
|
|
5381
|
+
_proto.shouldClearFullScreen = function shouldClearFullScreen() {
|
|
5382
|
+
var renderer = this.canvasConfig.renderer;
|
|
5383
|
+
|
|
5384
|
+
var _renderer$getConfig = renderer.getConfig(),
|
|
5385
|
+
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
6042
5386
|
|
|
6043
|
-
|
|
5387
|
+
return !enableDirtyRectangleRendering || this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
|
|
5388
|
+
};
|
|
6044
5389
|
|
|
6045
|
-
|
|
5390
|
+
_proto.convertAABB2Rect = function convertAABB2Rect(aabb) {
|
|
5391
|
+
var min = aabb.getMin();
|
|
5392
|
+
var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
|
|
5393
|
+
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
5394
|
+
|
|
5395
|
+
var minX = Math.floor(min[0]);
|
|
5396
|
+
var minY = Math.floor(min[1]);
|
|
5397
|
+
var maxX = Math.ceil(max[0]);
|
|
5398
|
+
var maxY = Math.ceil(max[1]);
|
|
5399
|
+
var width = maxX - minX;
|
|
5400
|
+
var height = maxY - minY;
|
|
5401
|
+
return {
|
|
5402
|
+
x: minX,
|
|
5403
|
+
y: minY,
|
|
5404
|
+
width: width,
|
|
5405
|
+
height: height
|
|
5406
|
+
};
|
|
5407
|
+
}
|
|
5408
|
+
/**
|
|
5409
|
+
* TODO: merge dirty rectangles with some strategies.
|
|
5410
|
+
* For now, we just simply merge all the rectangles into one.
|
|
5411
|
+
* @see https://idom.me/articles/841.html
|
|
5412
|
+
*/
|
|
5413
|
+
;
|
|
6046
5414
|
|
|
6047
|
-
|
|
5415
|
+
_proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
|
|
5416
|
+
// merge into a big AABB
|
|
5417
|
+
var aabb = new g.AABB();
|
|
5418
|
+
dirtyObjects.forEach(function (object) {
|
|
5419
|
+
var renderBounds = object.getRenderBounds();
|
|
5420
|
+
aabb.add(renderBounds);
|
|
5421
|
+
var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
|
|
6048
5422
|
|
|
6049
|
-
if (
|
|
6050
|
-
|
|
5423
|
+
if (dirtyRenderBounds) {
|
|
5424
|
+
aabb.add(dirtyRenderBounds);
|
|
6051
5425
|
}
|
|
5426
|
+
});
|
|
5427
|
+
return aabb;
|
|
5428
|
+
};
|
|
6052
5429
|
|
|
6053
|
-
|
|
5430
|
+
_proto.searchDirtyObjects = function searchDirtyObjects(dirtyRectangle) {
|
|
5431
|
+
var _this2 = this; // search in r-tree, get all affected nodes
|
|
6054
5432
|
|
|
6055
|
-
if (generatePath) {
|
|
6056
|
-
context.beginPath();
|
|
6057
|
-
generatePath(context, object.parsedStyle);
|
|
6058
5433
|
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
} // fill & stroke
|
|
5434
|
+
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
5435
|
+
minX = _dirtyRectangle$getMi[0],
|
|
5436
|
+
minY = _dirtyRectangle$getMi[1];
|
|
6063
5437
|
|
|
5438
|
+
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
5439
|
+
maxX = _dirtyRectangle$getMa[0],
|
|
5440
|
+
maxY = _dirtyRectangle$getMa[1];
|
|
5441
|
+
|
|
5442
|
+
var rBushNodes = this.rBush.search({
|
|
5443
|
+
minX: minX,
|
|
5444
|
+
minY: minY,
|
|
5445
|
+
maxX: maxX,
|
|
5446
|
+
maxY: maxY
|
|
5447
|
+
});
|
|
5448
|
+
return rBushNodes.map(function (_ref3) {
|
|
5449
|
+
var id = _ref3.id;
|
|
5450
|
+
return _this2.displayObjectPool.getByEntity(id);
|
|
5451
|
+
});
|
|
5452
|
+
};
|
|
6064
5453
|
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
5454
|
+
_proto.saveDirtyAABB = function saveDirtyAABB(object) {
|
|
5455
|
+
var renderable = object.renderable;
|
|
6068
5456
|
|
|
5457
|
+
if (!renderable.dirtyRenderBounds) {
|
|
5458
|
+
renderable.dirtyRenderBounds = new g.AABB();
|
|
5459
|
+
}
|
|
6069
5460
|
|
|
6070
|
-
|
|
5461
|
+
var renderBounds = object.getRenderBounds();
|
|
6071
5462
|
|
|
6072
|
-
|
|
6073
|
-
|
|
5463
|
+
if (renderBounds) {
|
|
5464
|
+
// save last dirty aabb
|
|
5465
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
6074
5466
|
}
|
|
6075
|
-
}
|
|
6076
|
-
key: "shouldClearFullScreen",
|
|
6077
|
-
value: function shouldClearFullScreen() {
|
|
6078
|
-
var renderer = this.canvasConfig.renderer;
|
|
5467
|
+
};
|
|
6079
5468
|
|
|
6080
|
-
|
|
6081
|
-
|
|
5469
|
+
_proto.applyTransform = function applyTransform(context, transform) {
|
|
5470
|
+
var _mat4$getTranslation = getTranslation(create$2$1(), transform),
|
|
5471
|
+
tx = _mat4$getTranslation[0],
|
|
5472
|
+
ty = _mat4$getTranslation[1];
|
|
6082
5473
|
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
key: "convertAABB2Rect",
|
|
6087
|
-
value: function convertAABB2Rect(aabb) {
|
|
6088
|
-
var min = aabb.getMin();
|
|
6089
|
-
var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
|
|
6090
|
-
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
5474
|
+
var _mat4$getScaling = getScaling(create$2$1(), transform),
|
|
5475
|
+
sx = _mat4$getScaling[0],
|
|
5476
|
+
sy = _mat4$getScaling[1];
|
|
6091
5477
|
|
|
6092
|
-
|
|
6093
|
-
var minY = Math.floor(min[1]);
|
|
6094
|
-
var maxX = Math.ceil(max[0]);
|
|
6095
|
-
var maxY = Math.ceil(max[1]);
|
|
6096
|
-
var width = maxX - minX;
|
|
6097
|
-
var height = maxY - minY;
|
|
6098
|
-
return {
|
|
6099
|
-
x: minX,
|
|
6100
|
-
y: minY,
|
|
6101
|
-
width: width,
|
|
6102
|
-
height: height
|
|
6103
|
-
};
|
|
6104
|
-
}
|
|
6105
|
-
/**
|
|
6106
|
-
* TODO: merge dirty rectangles with some strategies.
|
|
6107
|
-
* For now, we just simply merge all the rectangles into one.
|
|
6108
|
-
* @see https://idom.me/articles/841.html
|
|
6109
|
-
*/
|
|
6110
|
-
|
|
6111
|
-
}, {
|
|
6112
|
-
key: "mergeDirtyAABBs",
|
|
6113
|
-
value: function mergeDirtyAABBs(dirtyObjects) {
|
|
6114
|
-
// merge into a big AABB
|
|
6115
|
-
var aabb = new g.AABB();
|
|
6116
|
-
dirtyObjects.forEach(function (object) {
|
|
6117
|
-
var renderBounds = object.getRenderBounds();
|
|
6118
|
-
aabb.add(renderBounds);
|
|
6119
|
-
var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
|
|
6120
|
-
|
|
6121
|
-
if (dirtyRenderBounds) {
|
|
6122
|
-
aabb.add(dirtyRenderBounds);
|
|
6123
|
-
}
|
|
6124
|
-
});
|
|
6125
|
-
return aabb;
|
|
6126
|
-
}
|
|
6127
|
-
}, {
|
|
6128
|
-
key: "searchDirtyObjects",
|
|
6129
|
-
value: function searchDirtyObjects(dirtyRectangle) {
|
|
6130
|
-
var _this2 = this; // search in r-tree, get all affected nodes
|
|
5478
|
+
var rotation = getRotation(create$4$1(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6131
5479
|
|
|
5480
|
+
var _getEuler = g.getEuler(create$2$1(), rotation),
|
|
5481
|
+
eux = _getEuler[0],
|
|
5482
|
+
euy = _getEuler[1],
|
|
5483
|
+
euz = _getEuler[2]; // gimbal lock at 90 degrees
|
|
6132
5484
|
|
|
6133
|
-
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
6134
|
-
_dirtyRectangle$getMi2 = _slicedToArray$3(_dirtyRectangle$getMi, 2),
|
|
6135
|
-
minX = _dirtyRectangle$getMi2[0],
|
|
6136
|
-
minY = _dirtyRectangle$getMi2[1];
|
|
6137
5485
|
|
|
6138
|
-
|
|
6139
|
-
_dirtyRectangle$getMa2 = _slicedToArray$3(_dirtyRectangle$getMa, 2),
|
|
6140
|
-
maxX = _dirtyRectangle$getMa2[0],
|
|
6141
|
-
maxY = _dirtyRectangle$getMa2[1];
|
|
5486
|
+
var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
6142
5487
|
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
minY: minY,
|
|
6146
|
-
maxX: maxX,
|
|
6147
|
-
maxY: maxY
|
|
6148
|
-
});
|
|
6149
|
-
return rBushNodes.map(function (_ref3) {
|
|
6150
|
-
var id = _ref3.id;
|
|
6151
|
-
return _this2.displayObjectPool.getByEntity(id);
|
|
6152
|
-
});
|
|
6153
|
-
}
|
|
6154
|
-
}, {
|
|
6155
|
-
key: "saveDirtyAABB",
|
|
6156
|
-
value: function saveDirtyAABB(object) {
|
|
6157
|
-
var renderable = object.renderable;
|
|
5488
|
+
context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
|
|
5489
|
+
};
|
|
6158
5490
|
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
5491
|
+
_proto.applyAttributesToContext = function applyAttributesToContext(context, object) {
|
|
5492
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
5493
|
+
stroke = _object$parsedStyle.stroke,
|
|
5494
|
+
fill = _object$parsedStyle.fill,
|
|
5495
|
+
opacity = _object$parsedStyle.opacity,
|
|
5496
|
+
lineDash = _object$parsedStyle.lineDash,
|
|
5497
|
+
lineDashOffset = _object$parsedStyle.lineDashOffset,
|
|
5498
|
+
filter = _object$parsedStyle.filter,
|
|
5499
|
+
shadowColor = _object$parsedStyle.shadowColor,
|
|
5500
|
+
shadowBlur = _object$parsedStyle.shadowBlur,
|
|
5501
|
+
shadowOffsetX = _object$parsedStyle.shadowOffsetX,
|
|
5502
|
+
shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
5503
|
+
|
|
5504
|
+
if (lineDash && Array.isArray(lineDash)) {
|
|
5505
|
+
context.setLineDash(lineDash.map(function (segment) {
|
|
5506
|
+
return segment.value;
|
|
5507
|
+
}));
|
|
5508
|
+
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
6162
5509
|
|
|
6163
|
-
var renderBounds = object.getRenderBounds();
|
|
6164
5510
|
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
6168
|
-
}
|
|
5511
|
+
if (!g.isNil(lineDashOffset)) {
|
|
5512
|
+
context.lineDashOffset = lineDashOffset.value;
|
|
6169
5513
|
}
|
|
6170
|
-
}, {
|
|
6171
|
-
key: "applyTransform",
|
|
6172
|
-
value: function applyTransform(context, transform) {
|
|
6173
|
-
var _mat4$getTranslation = getTranslation(create$2$1(), transform),
|
|
6174
|
-
_mat4$getTranslation2 = _slicedToArray$3(_mat4$getTranslation, 2),
|
|
6175
|
-
tx = _mat4$getTranslation2[0],
|
|
6176
|
-
ty = _mat4$getTranslation2[1];
|
|
6177
|
-
|
|
6178
|
-
var _mat4$getScaling = getScaling(create$2$1(), transform),
|
|
6179
|
-
_mat4$getScaling2 = _slicedToArray$3(_mat4$getScaling, 2),
|
|
6180
|
-
sx = _mat4$getScaling2[0],
|
|
6181
|
-
sy = _mat4$getScaling2[1];
|
|
6182
|
-
|
|
6183
|
-
var rotation = getRotation(create$4$1(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6184
|
-
|
|
6185
|
-
var _getEuler = g.getEuler(create$2$1(), rotation),
|
|
6186
|
-
_getEuler2 = _slicedToArray$3(_getEuler, 3),
|
|
6187
|
-
eux = _getEuler2[0],
|
|
6188
|
-
euy = _getEuler2[1],
|
|
6189
|
-
euz = _getEuler2[2]; // gimbal lock at 90 degrees
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
6193
|
-
|
|
6194
|
-
context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
|
|
6195
|
-
}
|
|
6196
|
-
}, {
|
|
6197
|
-
key: "applyAttributesToContext",
|
|
6198
|
-
value: function applyAttributesToContext(context, object) {
|
|
6199
|
-
var _object$parsedStyle = object.parsedStyle,
|
|
6200
|
-
stroke = _object$parsedStyle.stroke,
|
|
6201
|
-
fill = _object$parsedStyle.fill,
|
|
6202
|
-
opacity = _object$parsedStyle.opacity,
|
|
6203
|
-
lineDash = _object$parsedStyle.lineDash,
|
|
6204
|
-
lineDashOffset = _object$parsedStyle.lineDashOffset,
|
|
6205
|
-
filter = _object$parsedStyle.filter,
|
|
6206
|
-
shadowColor = _object$parsedStyle.shadowColor,
|
|
6207
|
-
shadowBlur = _object$parsedStyle.shadowBlur,
|
|
6208
|
-
shadowOffsetX = _object$parsedStyle.shadowOffsetX,
|
|
6209
|
-
shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
6210
|
-
|
|
6211
|
-
if (lineDash && Array.isArray(lineDash)) {
|
|
6212
|
-
context.setLineDash(lineDash.map(function (segment) {
|
|
6213
|
-
return segment.value;
|
|
6214
|
-
}));
|
|
6215
|
-
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
if (!g.isNil(lineDashOffset)) {
|
|
6219
|
-
context.lineDashOffset = lineDashOffset.value;
|
|
6220
|
-
}
|
|
6221
5514
|
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
5515
|
+
if (!g.isNil(opacity)) {
|
|
5516
|
+
context.globalAlpha *= opacity.value;
|
|
5517
|
+
}
|
|
6225
5518
|
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
5519
|
+
if (!g.isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
|
|
5520
|
+
context.strokeStyle = object.attributes.stroke;
|
|
5521
|
+
}
|
|
6229
5522
|
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
5523
|
+
if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
|
|
5524
|
+
context.fillStyle = object.attributes.fill;
|
|
5525
|
+
}
|
|
6233
5526
|
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
5527
|
+
if (!g.isNil(filter)) {
|
|
5528
|
+
// use raw filter string
|
|
5529
|
+
context.filter = object.style.filter;
|
|
5530
|
+
}
|
|
6238
5531
|
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
}
|
|
5532
|
+
if (!g.isNil(shadowColor)) {
|
|
5533
|
+
context.shadowColor = shadowColor.toString();
|
|
5534
|
+
context.shadowBlur = shadowBlur && shadowBlur.value || 0;
|
|
5535
|
+
context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
|
|
5536
|
+
context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
|
|
6245
5537
|
}
|
|
6246
|
-
}
|
|
6247
|
-
key: "useAnchor",
|
|
6248
|
-
value: function useAnchor(context, object) {
|
|
6249
|
-
var _ref4 = object.parsedStyle || {},
|
|
6250
|
-
anchor = _ref4.anchor;
|
|
5538
|
+
};
|
|
6251
5539
|
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
5540
|
+
_proto.useAnchor = function useAnchor(context, object) {
|
|
5541
|
+
var _ref4 = object.parsedStyle || {},
|
|
5542
|
+
anchor = _ref4.anchor;
|
|
5543
|
+
|
|
5544
|
+
var bounds = object.getGeometryBounds();
|
|
5545
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
5546
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
5547
|
+
var defX = 0;
|
|
5548
|
+
var defY = 0;
|
|
6255
5549
|
|
|
6256
|
-
|
|
5550
|
+
if (object.nodeName === g.Shape.POLYLINE || object.nodeName === g.Shape.POLYGON || object.nodeName === g.Shape.PATH) {
|
|
5551
|
+
defX = object.parsedStyle.defX;
|
|
5552
|
+
defY = object.parsedStyle.defY;
|
|
5553
|
+
}
|
|
6257
5554
|
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
// eg. bounds = true size + half lineWidth
|
|
5555
|
+
var tx = -((anchor && anchor[0].value || 0) * width + defX);
|
|
5556
|
+
var ty = -((anchor && anchor[1].value || 0) * height + defY);
|
|
6261
5557
|
|
|
6262
|
-
|
|
6263
|
-
|
|
5558
|
+
if (tx !== 0 || ty !== 0) {
|
|
5559
|
+
// apply anchor, use true size, not include stroke,
|
|
5560
|
+
// eg. bounds = true size + half lineWidth
|
|
5561
|
+
context.translate(tx, ty);
|
|
6264
5562
|
}
|
|
6265
|
-
}
|
|
6266
|
-
key: "safeMergeAABB",
|
|
6267
|
-
value: function safeMergeAABB() {
|
|
6268
|
-
var merged = new g.AABB();
|
|
5563
|
+
};
|
|
6269
5564
|
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
}
|
|
5565
|
+
_proto.safeMergeAABB = function safeMergeAABB() {
|
|
5566
|
+
var merged = new g.AABB();
|
|
6273
5567
|
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
});
|
|
6277
|
-
return merged;
|
|
5568
|
+
for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5569
|
+
aabbs[_key] = arguments[_key];
|
|
6278
5570
|
}
|
|
6279
|
-
|
|
5571
|
+
|
|
5572
|
+
aabbs.forEach(function (aabb) {
|
|
5573
|
+
merged.add(aabb);
|
|
5574
|
+
});
|
|
5575
|
+
return merged;
|
|
5576
|
+
};
|
|
6280
5577
|
|
|
6281
5578
|
return CanvasRendererPlugin;
|
|
6282
5579
|
}(), _class$2.tag = 'CanvasRenderer', _class$2);
|
|
@@ -6312,7 +5609,7 @@
|
|
|
6312
5609
|
register(PolylineRenderer);
|
|
6313
5610
|
register(PolygonRenderer);
|
|
6314
5611
|
register(PathRenderer);
|
|
6315
|
-
var shape2Token = (_shape2Token = {},
|
|
5612
|
+
var shape2Token = (_shape2Token = {}, _shape2Token[g.Shape.CIRCLE] = CircleRendererContribution, _shape2Token[g.Shape.ELLIPSE] = EllipseRendererContribution, _shape2Token[g.Shape.RECT] = RectRendererContribution, _shape2Token[g.Shape.IMAGE] = ImageRendererContribution, _shape2Token[g.Shape.TEXT] = TextRendererContribution, _shape2Token[g.Shape.LINE] = LineRendererContribution, _shape2Token[g.Shape.POLYLINE] = PolylineRendererContribution, _shape2Token[g.Shape.POLYGON] = PolygonRendererContribution, _shape2Token[g.Shape.PATH] = PathRendererContribution, _shape2Token);
|
|
6316
5613
|
register({
|
|
6317
5614
|
token: StyleRendererFactory,
|
|
6318
5615
|
useFactory: function useFactory(ctx) {
|
|
@@ -6332,22 +5629,18 @@
|
|
|
6332
5629
|
|
|
6333
5630
|
var Plugin$3 = /*#__PURE__*/function () {
|
|
6334
5631
|
function Plugin() {
|
|
6335
|
-
_classCallCheck$4(this, Plugin);
|
|
6336
|
-
|
|
6337
5632
|
this.name = 'canvas-renderer';
|
|
6338
5633
|
}
|
|
6339
5634
|
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
}
|
|
6350
|
-
}]);
|
|
5635
|
+
var _proto = Plugin.prototype;
|
|
5636
|
+
|
|
5637
|
+
_proto.init = function init(container) {
|
|
5638
|
+
container.load(containerModule$3, true);
|
|
5639
|
+
};
|
|
5640
|
+
|
|
5641
|
+
_proto.destroy = function destroy(container) {
|
|
5642
|
+
container.unload(containerModule$3);
|
|
5643
|
+
};
|
|
6351
5644
|
|
|
6352
5645
|
return Plugin;
|
|
6353
5646
|
}();
|
|
@@ -6501,7 +5794,7 @@
|
|
|
6501
5794
|
if ("throw" !== record.type) {
|
|
6502
5795
|
var result = record.arg,
|
|
6503
5796
|
value = result.value;
|
|
6504
|
-
return value && "object" ==
|
|
5797
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
6505
5798
|
invoke("next", value, resolve, reject);
|
|
6506
5799
|
}, function (err) {
|
|
6507
5800
|
invoke("throw", err, resolve, reject);
|
|
@@ -6762,31 +6055,6 @@
|
|
|
6762
6055
|
};
|
|
6763
6056
|
}
|
|
6764
6057
|
|
|
6765
|
-
function _classCallCheck$5(instance, Constructor) {
|
|
6766
|
-
if (!(instance instanceof Constructor)) {
|
|
6767
|
-
throw new TypeError("Cannot call a class as a function");
|
|
6768
|
-
}
|
|
6769
|
-
}
|
|
6770
|
-
|
|
6771
|
-
function _defineProperties$5(target, props) {
|
|
6772
|
-
for (var i = 0; i < props.length; i++) {
|
|
6773
|
-
var descriptor = props[i];
|
|
6774
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
6775
|
-
descriptor.configurable = true;
|
|
6776
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
6777
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
6778
|
-
}
|
|
6779
|
-
}
|
|
6780
|
-
|
|
6781
|
-
function _createClass$5(Constructor, protoProps, staticProps) {
|
|
6782
|
-
if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
|
|
6783
|
-
if (staticProps) _defineProperties$5(Constructor, staticProps);
|
|
6784
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
6785
|
-
writable: false
|
|
6786
|
-
});
|
|
6787
|
-
return Constructor;
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
6058
|
var _class$3;
|
|
6791
6059
|
|
|
6792
6060
|
var DOMInteractionPlugin_1;
|
|
@@ -6796,150 +6064,147 @@
|
|
|
6796
6064
|
|
|
6797
6065
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class$3 = /*#__PURE__*/function () {
|
|
6798
6066
|
function DOMInteractionPlugin() {
|
|
6799
|
-
_classCallCheck$5(this, DOMInteractionPlugin);
|
|
6800
|
-
|
|
6801
6067
|
this.contextService = void 0;
|
|
6802
6068
|
this.renderingContext = void 0;
|
|
6803
6069
|
}
|
|
6804
6070
|
|
|
6805
|
-
|
|
6806
|
-
key: "apply",
|
|
6807
|
-
value: function apply(renderingService) {
|
|
6808
|
-
var _this = this;
|
|
6071
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
6809
6072
|
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
var onPointerMove = function onPointerMove(ev) {
|
|
6813
|
-
renderingService.hooks.pointerMove.call(ev);
|
|
6814
|
-
};
|
|
6073
|
+
_proto.apply = function apply(renderingService) {
|
|
6074
|
+
var _this = this;
|
|
6815
6075
|
|
|
6816
|
-
|
|
6817
|
-
renderingService.hooks.pointerUp.call(ev);
|
|
6818
|
-
};
|
|
6076
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
6819
6077
|
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6078
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
6079
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
6080
|
+
};
|
|
6823
6081
|
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6082
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
6083
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
6084
|
+
};
|
|
6827
6085
|
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6086
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
6087
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
6088
|
+
};
|
|
6831
6089
|
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6090
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
6091
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
6092
|
+
};
|
|
6835
6093
|
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6094
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
6095
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
6096
|
+
};
|
|
6839
6097
|
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
6844
|
-
$el.addEventListener('pointerover', onPointerOver, true);
|
|
6845
|
-
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
6846
|
-
};
|
|
6098
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
6099
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
6100
|
+
};
|
|
6847
6101
|
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
$el.addEventListener('touchmove', onPointerMove, true);
|
|
6852
|
-
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
6853
|
-
};
|
|
6102
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
6103
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
6104
|
+
};
|
|
6854
6105
|
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6106
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
6107
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
6108
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
6109
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
6110
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
6111
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
6112
|
+
};
|
|
6862
6113
|
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
};
|
|
6114
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
6115
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
6116
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
6117
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
6118
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
6119
|
+
};
|
|
6870
6120
|
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6121
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
6122
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
6123
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
6124
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
6125
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
6126
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
6127
|
+
};
|
|
6876
6128
|
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6129
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
6130
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
6131
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
6132
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
6133
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
6134
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
6135
|
+
};
|
|
6884
6136
|
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
case 0:
|
|
6891
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
6137
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
6138
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
6139
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
6140
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
6141
|
+
};
|
|
6892
6142
|
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6143
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
6144
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
6145
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
6146
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
6147
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
6148
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
6149
|
+
};
|
|
6896
6150
|
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6151
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
|
|
6152
|
+
var $el;
|
|
6153
|
+
return _regeneratorRuntime$4().wrap(function _callee$(_context) {
|
|
6154
|
+
while (1) {
|
|
6155
|
+
switch (_context.prev = _context.next) {
|
|
6156
|
+
case 0:
|
|
6157
|
+
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
6158
|
+
|
|
6159
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
6160
|
+
// @ts-ignore
|
|
6161
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
6162
|
+
|
|
6163
|
+
$el.style.msTouchAction = 'none';
|
|
6164
|
+
} else if (canvas.supportsPointerEvents) {
|
|
6165
|
+
$el.style.touchAction = 'none';
|
|
6166
|
+
}
|
|
6901
6167
|
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6168
|
+
if (canvas.supportsPointerEvents) {
|
|
6169
|
+
addPointerEventListener($el);
|
|
6170
|
+
} else {
|
|
6171
|
+
addMouseEventListener($el);
|
|
6172
|
+
}
|
|
6907
6173
|
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6174
|
+
if (canvas.supportsTouchEvents) {
|
|
6175
|
+
addTouchEventListener($el);
|
|
6176
|
+
} // use passive event listeners
|
|
6177
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
6912
6178
|
|
|
6913
6179
|
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6180
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
6181
|
+
passive: true,
|
|
6182
|
+
capture: true
|
|
6183
|
+
});
|
|
6918
6184
|
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
}
|
|
6185
|
+
case 5:
|
|
6186
|
+
case "end":
|
|
6187
|
+
return _context.stop();
|
|
6923
6188
|
}
|
|
6924
|
-
}, _callee);
|
|
6925
|
-
})));
|
|
6926
|
-
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
6927
|
-
var $el = _this.contextService.getDomElement();
|
|
6928
|
-
|
|
6929
|
-
if (canvas.supportsPointerEvents) {
|
|
6930
|
-
removePointerEventListener($el);
|
|
6931
|
-
} else {
|
|
6932
|
-
removeMouseEventListener($el);
|
|
6933
6189
|
}
|
|
6190
|
+
}, _callee);
|
|
6191
|
+
})));
|
|
6192
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
6193
|
+
var $el = _this.contextService.getDomElement();
|
|
6934
6194
|
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6195
|
+
if (canvas.supportsPointerEvents) {
|
|
6196
|
+
removePointerEventListener($el);
|
|
6197
|
+
} else {
|
|
6198
|
+
removeMouseEventListener($el);
|
|
6199
|
+
}
|
|
6938
6200
|
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6201
|
+
if (canvas.supportsTouchEvents) {
|
|
6202
|
+
removeTouchEventListener($el);
|
|
6203
|
+
}
|
|
6204
|
+
|
|
6205
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
6206
|
+
});
|
|
6207
|
+
};
|
|
6943
6208
|
|
|
6944
6209
|
return DOMInteractionPlugin;
|
|
6945
6210
|
}(), _class$3.tag = 'DOMInteraction', _class$3);
|
|
@@ -6957,22 +6222,18 @@
|
|
|
6957
6222
|
|
|
6958
6223
|
var Plugin$4 = /*#__PURE__*/function () {
|
|
6959
6224
|
function Plugin() {
|
|
6960
|
-
_classCallCheck$5(this, Plugin);
|
|
6961
|
-
|
|
6962
6225
|
this.name = 'dom-interaction';
|
|
6963
6226
|
}
|
|
6964
6227
|
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
}
|
|
6975
|
-
}]);
|
|
6228
|
+
var _proto = Plugin.prototype;
|
|
6229
|
+
|
|
6230
|
+
_proto.init = function init(container) {
|
|
6231
|
+
container.load(containerModule$4, true);
|
|
6232
|
+
};
|
|
6233
|
+
|
|
6234
|
+
_proto.destroy = function destroy(container) {
|
|
6235
|
+
container.unload(containerModule$4);
|
|
6236
|
+
};
|
|
6976
6237
|
|
|
6977
6238
|
return Plugin;
|
|
6978
6239
|
}();
|
|
@@ -7107,7 +6368,7 @@
|
|
|
7107
6368
|
if ("throw" !== record.type) {
|
|
7108
6369
|
var result = record.arg,
|
|
7109
6370
|
value = result.value;
|
|
7110
|
-
return value && "object" ==
|
|
6371
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
7111
6372
|
invoke("next", value, resolve, reject);
|
|
7112
6373
|
}, function (err) {
|
|
7113
6374
|
invoke("throw", err, resolve, reject);
|
|
@@ -7368,271 +6629,240 @@
|
|
|
7368
6629
|
};
|
|
7369
6630
|
}
|
|
7370
6631
|
|
|
7371
|
-
function _classCallCheck$6(instance, Constructor) {
|
|
7372
|
-
if (!(instance instanceof Constructor)) {
|
|
7373
|
-
throw new TypeError("Cannot call a class as a function");
|
|
7374
|
-
}
|
|
7375
|
-
}
|
|
7376
|
-
|
|
7377
|
-
function _defineProperties$6(target, props) {
|
|
7378
|
-
for (var i = 0; i < props.length; i++) {
|
|
7379
|
-
var descriptor = props[i];
|
|
7380
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
7381
|
-
descriptor.configurable = true;
|
|
7382
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
7383
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
7384
|
-
}
|
|
7385
|
-
}
|
|
7386
|
-
|
|
7387
|
-
function _createClass$6(Constructor, protoProps, staticProps) {
|
|
7388
|
-
if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
|
7389
|
-
if (staticProps) _defineProperties$6(Constructor, staticProps);
|
|
7390
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
7391
|
-
writable: false
|
|
7392
|
-
});
|
|
7393
|
-
return Constructor;
|
|
7394
|
-
}
|
|
7395
|
-
|
|
7396
6632
|
var _class$4;
|
|
7397
6633
|
|
|
7398
6634
|
var HTMLRenderingPlugin_1;
|
|
7399
6635
|
var HTML_PREFIX = 'g-html-';
|
|
7400
6636
|
var HTMLRenderingPlugin = HTMLRenderingPlugin_1 = (_class$4 = /*#__PURE__*/function () {
|
|
7401
6637
|
function HTMLRenderingPlugin() {
|
|
7402
|
-
_classCallCheck$6(this, HTMLRenderingPlugin);
|
|
7403
|
-
|
|
7404
6638
|
this.contextService = void 0;
|
|
7405
6639
|
this.renderingContext = void 0;
|
|
7406
6640
|
this.canvasConfig = void 0;
|
|
7407
6641
|
this.$camera = void 0;
|
|
7408
6642
|
}
|
|
7409
6643
|
|
|
7410
|
-
|
|
7411
|
-
key: "apply",
|
|
7412
|
-
value: function apply(renderingService) {
|
|
7413
|
-
var _this = this;
|
|
6644
|
+
var _proto = HTMLRenderingPlugin.prototype;
|
|
7414
6645
|
|
|
7415
|
-
|
|
7416
|
-
|
|
6646
|
+
_proto.apply = function apply(renderingService) {
|
|
6647
|
+
var _this = this;
|
|
7417
6648
|
|
|
7418
|
-
|
|
7419
|
-
|
|
6649
|
+
var handleMounted = function handleMounted(e) {
|
|
6650
|
+
var object = e.target;
|
|
7420
6651
|
|
|
6652
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
6653
|
+
var $el = _this.getOrCreateEl(object); // apply documentElement's style
|
|
7421
6654
|
|
|
7422
|
-
var attributes = object.ownerDocument.documentElement.attributes;
|
|
7423
|
-
Object.keys(attributes).forEach(function (name) {
|
|
7424
|
-
$el.style[name] = attributes[name];
|
|
7425
|
-
});
|
|
7426
|
-
Object.keys(object.attributes).forEach(function (name) {
|
|
7427
|
-
_this.updateAttribute(name, object);
|
|
7428
|
-
});
|
|
7429
|
-
}
|
|
7430
|
-
};
|
|
7431
6655
|
|
|
7432
|
-
|
|
7433
|
-
|
|
6656
|
+
var attributes = object.ownerDocument.documentElement.attributes;
|
|
6657
|
+
Object.keys(attributes).forEach(function (name) {
|
|
6658
|
+
$el.style[name] = attributes[name];
|
|
6659
|
+
});
|
|
6660
|
+
Object.keys(object.attributes).forEach(function (name) {
|
|
6661
|
+
_this.updateAttribute(name, object);
|
|
6662
|
+
});
|
|
6663
|
+
}
|
|
6664
|
+
};
|
|
6665
|
+
|
|
6666
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
6667
|
+
var object = e.target;
|
|
7434
6668
|
|
|
7435
|
-
|
|
7436
|
-
|
|
6669
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
6670
|
+
var existedId = _this.getId(object);
|
|
7437
6671
|
|
|
7438
|
-
|
|
6672
|
+
var $container = _this.contextService.getDomElement().parentNode;
|
|
7439
6673
|
|
|
7440
|
-
|
|
7441
|
-
|
|
6674
|
+
if ($container) {
|
|
6675
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
7442
6676
|
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
}
|
|
6677
|
+
if ($existedElement) {
|
|
6678
|
+
$container.removeChild($existedElement);
|
|
7446
6679
|
}
|
|
7447
6680
|
}
|
|
7448
|
-
}
|
|
6681
|
+
}
|
|
6682
|
+
};
|
|
7449
6683
|
|
|
7450
|
-
|
|
7451
|
-
|
|
6684
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
6685
|
+
var object = e.target;
|
|
7452
6686
|
|
|
7453
|
-
|
|
7454
|
-
|
|
6687
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
6688
|
+
var attrName = e.attrName;
|
|
7455
6689
|
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
6690
|
+
_this.updateAttribute(attrName, object);
|
|
6691
|
+
}
|
|
6692
|
+
};
|
|
7459
6693
|
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
6694
|
+
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee() {
|
|
6695
|
+
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
6696
|
+
while (1) {
|
|
6697
|
+
switch (_context.prev = _context.next) {
|
|
6698
|
+
case 0:
|
|
6699
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
7466
6700
|
|
|
7467
|
-
|
|
6701
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
7468
6702
|
|
|
7469
|
-
|
|
6703
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
7470
6704
|
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
}
|
|
6705
|
+
case 3:
|
|
6706
|
+
case "end":
|
|
6707
|
+
return _context.stop();
|
|
7475
6708
|
}
|
|
7476
|
-
}
|
|
7477
|
-
})
|
|
7478
|
-
|
|
7479
|
-
|
|
6709
|
+
}
|
|
6710
|
+
}, _callee);
|
|
6711
|
+
})));
|
|
6712
|
+
renderingService.hooks.destroy.tap(HTMLRenderingPlugin_1.tag, function () {
|
|
6713
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
7480
6714
|
|
|
7481
|
-
|
|
6715
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
7482
6716
|
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
}, {
|
|
7487
|
-
key: "getId",
|
|
7488
|
-
value: function getId(object) {
|
|
7489
|
-
return object.id || HTML_PREFIX + object.entity;
|
|
7490
|
-
}
|
|
7491
|
-
}, {
|
|
7492
|
-
key: "getOrCreateEl",
|
|
7493
|
-
value: function getOrCreateEl(object) {
|
|
7494
|
-
var doc = this.canvasConfig.document;
|
|
7495
|
-
var existedId = this.getId(object);
|
|
7496
|
-
var $container = this.contextService.getDomElement().parentNode;
|
|
6717
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6718
|
+
});
|
|
6719
|
+
};
|
|
7497
6720
|
|
|
7498
|
-
|
|
7499
|
-
|
|
6721
|
+
_proto.getId = function getId(object) {
|
|
6722
|
+
return object.id || HTML_PREFIX + object.entity;
|
|
6723
|
+
};
|
|
7500
6724
|
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
6725
|
+
_proto.getOrCreateEl = function getOrCreateEl(object) {
|
|
6726
|
+
var doc = this.canvasConfig.document;
|
|
6727
|
+
var existedId = this.getId(object);
|
|
6728
|
+
var $container = this.contextService.getDomElement().parentNode;
|
|
7505
6729
|
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
}
|
|
6730
|
+
if ($container) {
|
|
6731
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
7509
6732
|
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
6733
|
+
if (!$existedElement) {
|
|
6734
|
+
$existedElement = (doc || document).createElement('div');
|
|
6735
|
+
object.parsedStyle.$el = $existedElement;
|
|
6736
|
+
$existedElement.id = existedId;
|
|
7513
6737
|
|
|
7514
|
-
|
|
6738
|
+
if (object.name) {
|
|
6739
|
+
$existedElement.setAttribute('name', object.name);
|
|
6740
|
+
}
|
|
7515
6741
|
|
|
7516
|
-
|
|
7517
|
-
$existedElement.
|
|
7518
|
-
$existedElement.style.top = '0';
|
|
7519
|
-
$existedElement.style['will-change'] = 'transform';
|
|
7520
|
-
var worldTransform = object.getWorldTransform();
|
|
7521
|
-
$existedElement.style.transform = "matrix(".concat([worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(','), ")");
|
|
6742
|
+
if (object.className) {
|
|
6743
|
+
$existedElement.className = object.className;
|
|
7522
6744
|
}
|
|
7523
6745
|
|
|
7524
|
-
|
|
6746
|
+
$container.appendChild($existedElement); // use absolute position
|
|
6747
|
+
|
|
6748
|
+
$existedElement.style.position = 'absolute';
|
|
6749
|
+
$existedElement.style.left = '0';
|
|
6750
|
+
$existedElement.style.top = '0';
|
|
6751
|
+
$existedElement.style['will-change'] = 'transform';
|
|
6752
|
+
var worldTransform = object.getWorldTransform();
|
|
6753
|
+
$existedElement.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
7525
6754
|
}
|
|
7526
6755
|
|
|
7527
|
-
return
|
|
6756
|
+
return $existedElement;
|
|
7528
6757
|
}
|
|
7529
|
-
}, {
|
|
7530
|
-
key: "updateAttribute",
|
|
7531
|
-
value: function updateAttribute(name, object) {
|
|
7532
|
-
var $el = this.getOrCreateEl(object);
|
|
7533
6758
|
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
var innerHTML = object.parsedStyle.innerHTML;
|
|
6759
|
+
return null;
|
|
6760
|
+
};
|
|
7537
6761
|
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
} else {
|
|
7541
|
-
$el.innerHTML = '';
|
|
7542
|
-
$el.appendChild(innerHTML);
|
|
7543
|
-
}
|
|
6762
|
+
_proto.updateAttribute = function updateAttribute(name, object) {
|
|
6763
|
+
var $el = this.getOrCreateEl(object);
|
|
7544
6764
|
|
|
7545
|
-
|
|
6765
|
+
switch (name) {
|
|
6766
|
+
case 'innerHTML':
|
|
6767
|
+
var innerHTML = object.parsedStyle.innerHTML;
|
|
7546
6768
|
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
$el.
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
break;
|
|
6769
|
+
if (g.isString(innerHTML)) {
|
|
6770
|
+
$el.innerHTML = innerHTML;
|
|
6771
|
+
} else {
|
|
6772
|
+
$el.innerHTML = '';
|
|
6773
|
+
$el.appendChild(innerHTML);
|
|
6774
|
+
}
|
|
7554
6775
|
|
|
7555
|
-
|
|
7556
|
-
var width = object.computedStyleMap().get('width');
|
|
7557
|
-
$el.style.width = width.toString();
|
|
7558
|
-
break;
|
|
6776
|
+
break;
|
|
7559
6777
|
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
6778
|
+
case 'modelMatrix':
|
|
6779
|
+
case 'transformOrigin':
|
|
6780
|
+
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
6781
|
+
$el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
|
|
6782
|
+
var worldTransform = object.getWorldTransform();
|
|
6783
|
+
$el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
6784
|
+
break;
|
|
7564
6785
|
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
6786
|
+
case 'width':
|
|
6787
|
+
var width = object.computedStyleMap().get('width');
|
|
6788
|
+
$el.style.width = width.toString();
|
|
6789
|
+
break;
|
|
7569
6790
|
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
6791
|
+
case 'height':
|
|
6792
|
+
var height = object.computedStyleMap().get('height');
|
|
6793
|
+
$el.style.height = height.toString();
|
|
6794
|
+
break;
|
|
7574
6795
|
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
6796
|
+
case 'zIndex':
|
|
6797
|
+
var zIndex = object.parsedStyle.zIndex;
|
|
6798
|
+
$el.style['z-index'] = "" + zIndex.value;
|
|
6799
|
+
break;
|
|
7579
6800
|
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
6801
|
+
case 'visibility':
|
|
6802
|
+
var visibility = object.parsedStyle.visibility;
|
|
6803
|
+
$el.style.visibility = visibility.value;
|
|
6804
|
+
break;
|
|
7584
6805
|
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
6806
|
+
case 'pointerEvents':
|
|
6807
|
+
var pointerEvents = object.parsedStyle.pointerEvents;
|
|
6808
|
+
$el.style.pointerEvents = pointerEvents.value;
|
|
6809
|
+
break;
|
|
7588
6810
|
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
6811
|
+
case 'opacity':
|
|
6812
|
+
var opacity = object.parsedStyle.opacity;
|
|
6813
|
+
$el.style.opacity = "" + opacity.value;
|
|
6814
|
+
break;
|
|
6815
|
+
|
|
6816
|
+
case 'fill':
|
|
6817
|
+
var fill = object.parsedStyle.fill;
|
|
6818
|
+
var color = '';
|
|
6819
|
+
|
|
6820
|
+
if (fill instanceof g.CSSRGB) {
|
|
6821
|
+
if (fill.isNone) {
|
|
6822
|
+
color = 'transparent';
|
|
6823
|
+
} else {
|
|
7596
6824
|
color = object.getAttribute('fill');
|
|
7597
|
-
}
|
|
6825
|
+
}
|
|
6826
|
+
} else if (Array.isArray(fill)) {
|
|
6827
|
+
color = object.getAttribute('fill');
|
|
6828
|
+
} else if (g.isPattern(fill)) ;
|
|
7598
6829
|
|
|
7599
|
-
|
|
7600
|
-
|
|
6830
|
+
$el.style.background = color;
|
|
6831
|
+
break;
|
|
7601
6832
|
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
6833
|
+
case 'stroke':
|
|
6834
|
+
var stroke = object.parsedStyle.stroke;
|
|
6835
|
+
var borderColor = '';
|
|
7605
6836
|
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
borderColor = object.getAttribute('stroke');
|
|
7611
|
-
}
|
|
7612
|
-
} else if (Array.isArray(stroke)) {
|
|
6837
|
+
if (stroke instanceof g.CSSRGB) {
|
|
6838
|
+
if (stroke.isNone) {
|
|
6839
|
+
borderColor = 'transparent';
|
|
6840
|
+
} else {
|
|
7613
6841
|
borderColor = object.getAttribute('stroke');
|
|
7614
|
-
}
|
|
6842
|
+
}
|
|
6843
|
+
} else if (Array.isArray(stroke)) {
|
|
6844
|
+
borderColor = object.getAttribute('stroke');
|
|
6845
|
+
} else if (g.isPattern(stroke)) ;
|
|
7615
6846
|
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
6847
|
+
$el.style['border-color'] = borderColor;
|
|
6848
|
+
$el.style['border-style'] = 'solid';
|
|
6849
|
+
break;
|
|
7619
6850
|
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
6851
|
+
case 'lineWidth':
|
|
6852
|
+
var lineWidth = object.parsedStyle.lineWidth;
|
|
6853
|
+
$el.style['border-width'] = (lineWidth.value || 0) + "px";
|
|
6854
|
+
break;
|
|
7624
6855
|
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
6856
|
+
case 'lineDash':
|
|
6857
|
+
$el.style['border-style'] = 'dashed';
|
|
6858
|
+
break;
|
|
7628
6859
|
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
}
|
|
6860
|
+
case 'filter':
|
|
6861
|
+
var filter = object.parsedStyle.filter;
|
|
6862
|
+
$el.style.filter = filter;
|
|
6863
|
+
break;
|
|
7634
6864
|
}
|
|
7635
|
-
}
|
|
6865
|
+
};
|
|
7636
6866
|
|
|
7637
6867
|
return HTMLRenderingPlugin;
|
|
7638
6868
|
}(), _class$4.tag = 'HTMLRendering', _class$4);
|
|
@@ -7652,22 +6882,18 @@
|
|
|
7652
6882
|
|
|
7653
6883
|
var Plugin$5 = /*#__PURE__*/function () {
|
|
7654
6884
|
function Plugin() {
|
|
7655
|
-
_classCallCheck$6(this, Plugin);
|
|
7656
|
-
|
|
7657
6885
|
this.name = 'html-renderer';
|
|
7658
6886
|
}
|
|
7659
6887
|
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
}
|
|
7670
|
-
}]);
|
|
6888
|
+
var _proto = Plugin.prototype;
|
|
6889
|
+
|
|
6890
|
+
_proto.init = function init(container) {
|
|
6891
|
+
container.load(containerModule$5, true);
|
|
6892
|
+
};
|
|
6893
|
+
|
|
6894
|
+
_proto.destroy = function destroy(container) {
|
|
6895
|
+
container.unload(containerModule$5);
|
|
6896
|
+
};
|
|
7671
6897
|
|
|
7672
6898
|
return Plugin;
|
|
7673
6899
|
}();
|
|
@@ -7679,8 +6905,6 @@
|
|
|
7679
6905
|
|
|
7680
6906
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
7681
6907
|
function Canvas2DContextService() {
|
|
7682
|
-
_classCallCheck(this, Canvas2DContextService);
|
|
7683
|
-
|
|
7684
6908
|
this.$container = void 0;
|
|
7685
6909
|
this.$canvas = void 0;
|
|
7686
6910
|
this.dpr = void 0;
|
|
@@ -7688,120 +6912,112 @@
|
|
|
7688
6912
|
this.canvasConfig = void 0;
|
|
7689
6913
|
}
|
|
7690
6914
|
|
|
7691
|
-
|
|
7692
|
-
key: "init",
|
|
7693
|
-
value: function () {
|
|
7694
|
-
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
7695
|
-
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
6915
|
+
var _proto = Canvas2DContextService.prototype;
|
|
7696
6916
|
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
case 0:
|
|
7701
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
6917
|
+
_proto.init = /*#__PURE__*/function () {
|
|
6918
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6919
|
+
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
7702
6920
|
|
|
7703
|
-
|
|
7704
|
-
|
|
6921
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6922
|
+
while (1) {
|
|
6923
|
+
switch (_context.prev = _context.next) {
|
|
6924
|
+
case 0:
|
|
6925
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
7705
6926
|
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
}
|
|
6927
|
+
if (canvas) {
|
|
6928
|
+
this.$canvas = canvas;
|
|
7709
6929
|
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
}
|
|
7713
|
-
// create container
|
|
7714
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
6930
|
+
if (container && canvas.parentElement !== container) {
|
|
6931
|
+
container.appendChild(canvas);
|
|
6932
|
+
}
|
|
7715
6933
|
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
6934
|
+
this.$container = canvas.parentElement;
|
|
6935
|
+
this.canvasConfig.container = this.$container;
|
|
6936
|
+
} else if (container) {
|
|
6937
|
+
// create container
|
|
6938
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
7720
6939
|
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
6940
|
+
if (this.$container) {
|
|
6941
|
+
// create canvas
|
|
6942
|
+
$canvas = document.createElement('canvas');
|
|
6943
|
+
this.$container.appendChild($canvas);
|
|
7724
6944
|
|
|
7725
|
-
|
|
6945
|
+
if (!this.$container.style.position) {
|
|
6946
|
+
this.$container.style.position = 'relative';
|
|
7726
6947
|
}
|
|
6948
|
+
|
|
6949
|
+
this.$canvas = $canvas;
|
|
7727
6950
|
}
|
|
6951
|
+
}
|
|
7728
6952
|
|
|
7729
|
-
|
|
6953
|
+
this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
|
|
7730
6954
|
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
6955
|
+
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
6956
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
6957
|
+
this.dpr = dpr;
|
|
6958
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
7735
6959
|
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
}
|
|
6960
|
+
case 7:
|
|
6961
|
+
case "end":
|
|
6962
|
+
return _context.stop();
|
|
7740
6963
|
}
|
|
7741
|
-
}
|
|
7742
|
-
})
|
|
6964
|
+
}
|
|
6965
|
+
}, _callee, this);
|
|
6966
|
+
}));
|
|
7743
6967
|
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
6968
|
+
function init() {
|
|
6969
|
+
return _init.apply(this, arguments);
|
|
6970
|
+
}
|
|
7747
6971
|
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
key: "getBoundingClientRect",
|
|
7767
|
-
value: function getBoundingClientRect() {
|
|
7768
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
7769
|
-
return this.$canvas.getBoundingClientRect();
|
|
7770
|
-
}
|
|
6972
|
+
return init;
|
|
6973
|
+
}();
|
|
6974
|
+
|
|
6975
|
+
_proto.getContext = function getContext() {
|
|
6976
|
+
return this.context;
|
|
6977
|
+
};
|
|
6978
|
+
|
|
6979
|
+
_proto.getDomElement = function getDomElement() {
|
|
6980
|
+
return this.$canvas;
|
|
6981
|
+
};
|
|
6982
|
+
|
|
6983
|
+
_proto.getDPR = function getDPR() {
|
|
6984
|
+
return this.dpr;
|
|
6985
|
+
};
|
|
6986
|
+
|
|
6987
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
6988
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
6989
|
+
return this.$canvas.getBoundingClientRect();
|
|
7771
6990
|
}
|
|
7772
|
-
}
|
|
7773
|
-
|
|
7774
|
-
|
|
6991
|
+
};
|
|
6992
|
+
|
|
6993
|
+
_proto.destroy = function destroy() {
|
|
6994
|
+
// @ts-ignore
|
|
6995
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
6996
|
+
// destroy context
|
|
7775
6997
|
// @ts-ignore
|
|
7776
|
-
|
|
7777
|
-
// destroy context
|
|
7778
|
-
// @ts-ignore
|
|
7779
|
-
this.$container.removeChild(this.$canvas);
|
|
7780
|
-
}
|
|
6998
|
+
this.$container.removeChild(this.$canvas);
|
|
7781
6999
|
}
|
|
7782
|
-
}
|
|
7783
|
-
key: "resize",
|
|
7784
|
-
value: function resize(width, height) {
|
|
7785
|
-
if (this.$canvas) {
|
|
7786
|
-
// set canvas width & height
|
|
7787
|
-
this.$canvas.width = this.dpr * width;
|
|
7788
|
-
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
7000
|
+
};
|
|
7789
7001
|
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7002
|
+
_proto.resize = function resize(width, height) {
|
|
7003
|
+
if (this.$canvas) {
|
|
7004
|
+
// set canvas width & height
|
|
7005
|
+
this.$canvas.width = this.dpr * width;
|
|
7006
|
+
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
7793
7007
|
|
|
7794
|
-
|
|
7795
|
-
|
|
7008
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
7009
|
+
var dpr = this.getDPR(); // scale all drawing operations by the dpr
|
|
7010
|
+
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
7011
|
+
|
|
7012
|
+
this.context.scale(dpr, dpr);
|
|
7796
7013
|
}
|
|
7797
|
-
}
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
}
|
|
7014
|
+
};
|
|
7015
|
+
|
|
7016
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
7017
|
+
if (this.$container && this.$container.style) {
|
|
7018
|
+
this.$container.style.cursor = cursor;
|
|
7803
7019
|
}
|
|
7804
|
-
}
|
|
7020
|
+
};
|
|
7805
7021
|
|
|
7806
7022
|
return Canvas2DContextService;
|
|
7807
7023
|
}();
|
|
@@ -7820,37 +7036,29 @@
|
|
|
7820
7036
|
});
|
|
7821
7037
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
7822
7038
|
function ContextRegisterPlugin() {
|
|
7823
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
7824
|
-
|
|
7825
7039
|
this.name = 'canvas-context-register';
|
|
7826
7040
|
}
|
|
7827
7041
|
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
}
|
|
7838
|
-
}]);
|
|
7042
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
7043
|
+
|
|
7044
|
+
_proto.init = function init(container) {
|
|
7045
|
+
container.load(containerModule$6, true);
|
|
7046
|
+
};
|
|
7047
|
+
|
|
7048
|
+
_proto.destroy = function destroy(container) {
|
|
7049
|
+
container.unload(containerModule$6);
|
|
7050
|
+
};
|
|
7839
7051
|
|
|
7840
7052
|
return ContextRegisterPlugin;
|
|
7841
7053
|
}();
|
|
7842
7054
|
|
|
7843
7055
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
var _super = _createSuper(Renderer);
|
|
7056
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
7847
7057
|
|
|
7848
7058
|
function Renderer(config) {
|
|
7849
7059
|
var _this;
|
|
7850
7060
|
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
_this = _super.call(this, config); // register Canvas2DContext
|
|
7061
|
+
_this = _AbstractRenderer.call(this, config) || this; // register Canvas2DContext
|
|
7854
7062
|
|
|
7855
7063
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
7856
7064
|
|
|
@@ -7872,7 +7080,7 @@
|
|
|
7872
7080
|
return _this;
|
|
7873
7081
|
}
|
|
7874
7082
|
|
|
7875
|
-
return
|
|
7083
|
+
return Renderer;
|
|
7876
7084
|
}(g.AbstractRenderer);
|
|
7877
7085
|
|
|
7878
7086
|
exports.CanvasPathGenerator = index_esm;
|