@antv/g-canvas 1.2.0 → 1.2.1
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 +214 -104
- package/dist/index.js +214 -104
- package/dist/index.umd.js +2295 -1509
- package/dist/index.umd.min.js +6 -6
- package/package.json +8 -8
package/dist/index.umd.js
CHANGED
|
@@ -349,6 +349,16 @@
|
|
|
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
|
+
|
|
352
362
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
353
363
|
try {
|
|
354
364
|
var info = gen[key](arg);
|
|
@@ -385,22 +395,216 @@
|
|
|
385
395
|
};
|
|
386
396
|
}
|
|
387
397
|
|
|
388
|
-
function
|
|
389
|
-
|
|
390
|
-
|
|
398
|
+
function _classCallCheck(instance, Constructor) {
|
|
399
|
+
if (!(instance instanceof Constructor)) {
|
|
400
|
+
throw new TypeError("Cannot call a class as a function");
|
|
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
|
+
}
|
|
391
440
|
|
|
392
|
-
|
|
441
|
+
function _getPrototypeOf(o) {
|
|
442
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
443
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
444
|
+
};
|
|
445
|
+
return _getPrototypeOf(o);
|
|
393
446
|
}
|
|
394
447
|
|
|
395
448
|
function _setPrototypeOf(o, p) {
|
|
396
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
449
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
397
450
|
o.__proto__ = p;
|
|
398
451
|
return o;
|
|
399
452
|
};
|
|
400
|
-
|
|
401
453
|
return _setPrototypeOf(o, p);
|
|
402
454
|
}
|
|
403
455
|
|
|
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
|
+
|
|
404
608
|
var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
|
|
405
609
|
var PathGenerator = g.Syringe.defineToken('PathGenerator');
|
|
406
610
|
|
|
@@ -449,7 +653,9 @@
|
|
|
449
653
|
var _parsedStyle$path = parsedStyle.path,
|
|
450
654
|
curve = _parsedStyle$path.curve,
|
|
451
655
|
zCommandIndexes = _parsedStyle$path.zCommandIndexes;
|
|
452
|
-
|
|
656
|
+
|
|
657
|
+
var path = _toConsumableArray(curve);
|
|
658
|
+
|
|
453
659
|
zCommandIndexes.forEach(function (zIndex, index) {
|
|
454
660
|
path.splice(zIndex + index, 1, ['Z']);
|
|
455
661
|
});
|
|
@@ -538,10 +744,11 @@
|
|
|
538
744
|
var _radius$map = radius.map(function (r) {
|
|
539
745
|
return g.clamp(r.value, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
|
|
540
746
|
}),
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
747
|
+
_radius$map2 = _slicedToArray(_radius$map, 4),
|
|
748
|
+
tlr = _radius$map2[0],
|
|
749
|
+
trr = _radius$map2[1],
|
|
750
|
+
brr = _radius$map2[2],
|
|
751
|
+
blr = _radius$map2[3];
|
|
545
752
|
|
|
546
753
|
context.moveTo(signX * tlr, 0);
|
|
547
754
|
context.lineTo(w - signX * trr, 0);
|
|
@@ -639,18 +846,22 @@
|
|
|
639
846
|
|
|
640
847
|
var Plugin = /*#__PURE__*/function () {
|
|
641
848
|
function Plugin() {
|
|
849
|
+
_classCallCheck$1(this, Plugin);
|
|
850
|
+
|
|
642
851
|
this.name = 'canvas-path-generator';
|
|
643
852
|
}
|
|
644
853
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
container
|
|
653
|
-
|
|
854
|
+
_createClass$1(Plugin, [{
|
|
855
|
+
key: "init",
|
|
856
|
+
value: function init(container) {
|
|
857
|
+
container.load(containerModule, true);
|
|
858
|
+
}
|
|
859
|
+
}, {
|
|
860
|
+
key: "destroy",
|
|
861
|
+
value: function destroy(container) {
|
|
862
|
+
container.unload(containerModule);
|
|
863
|
+
}
|
|
864
|
+
}]);
|
|
654
865
|
|
|
655
866
|
return Plugin;
|
|
656
867
|
}();
|
|
@@ -813,7 +1024,7 @@
|
|
|
813
1024
|
if ("throw" !== record.type) {
|
|
814
1025
|
var result = record.arg,
|
|
815
1026
|
value = result.value;
|
|
816
|
-
return value && "object" ==
|
|
1027
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
817
1028
|
invoke("next", value, resolve, reject);
|
|
818
1029
|
}, function (err) {
|
|
819
1030
|
invoke("throw", err, resolve, reject);
|
|
@@ -1073,6 +1284,92 @@
|
|
|
1073
1284
|
});
|
|
1074
1285
|
};
|
|
1075
1286
|
}
|
|
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
|
+
}
|
|
1076
1373
|
/**
|
|
1077
1374
|
* Common utilities
|
|
1078
1375
|
* @module glMatrix
|
|
@@ -1667,6 +1964,8 @@
|
|
|
1667
1964
|
function CanvasPickerPlugin() {
|
|
1668
1965
|
var _this = this;
|
|
1669
1966
|
|
|
1967
|
+
_classCallCheck$2(this, CanvasPickerPlugin);
|
|
1968
|
+
|
|
1670
1969
|
this.displayObjectPool = void 0;
|
|
1671
1970
|
this.canvasConfig = void 0;
|
|
1672
1971
|
this.offscreenCanvas = void 0;
|
|
@@ -1717,108 +2016,109 @@
|
|
|
1717
2016
|
};
|
|
1718
2017
|
}
|
|
1719
2018
|
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
2019
|
+
_createClass$2(CanvasPickerPlugin, [{
|
|
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);
|
|
1756
2058
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
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;
|
|
1759
2071
|
}
|
|
1760
|
-
}); // find group with max z-index
|
|
1761
|
-
|
|
1762
|
-
hitTestList.sort(function (a, b) {
|
|
1763
|
-
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
1764
|
-
});
|
|
1765
|
-
pickedDisplayObjects = [];
|
|
1766
|
-
_i = 0, _hitTestList = hitTestList;
|
|
1767
|
-
|
|
1768
|
-
case 9:
|
|
1769
|
-
if (!(_i < _hitTestList.length)) {
|
|
1770
|
-
_context.next = 25;
|
|
1771
|
-
break;
|
|
1772
|
-
}
|
|
1773
2072
|
|
|
1774
|
-
|
|
2073
|
+
displayObject = _hitTestList[_i]; // test with clip path
|
|
1775
2074
|
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
2075
|
+
clipPath = displayObject.parsedStyle.clipPath;
|
|
2076
|
+
objectToTest = clipPath || displayObject;
|
|
2077
|
+
worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
|
|
1779
2078
|
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
2079
|
+
if (clipPath) {
|
|
2080
|
+
worldTransform = multiply$1(create$1(), worldTransform, clipPath.getLocalTransform());
|
|
2081
|
+
}
|
|
1783
2082
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
2083
|
+
if (!_this2.isHit(objectToTest, position, worldTransform)) {
|
|
2084
|
+
_context.next = 22;
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
1788
2087
|
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
2088
|
+
if (!topmost) {
|
|
2089
|
+
_context.next = 21;
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
1793
2092
|
|
|
1794
|
-
|
|
1795
|
-
|
|
2093
|
+
result.picked = [displayObject];
|
|
2094
|
+
return _context.abrupt("return", result);
|
|
1796
2095
|
|
|
1797
|
-
|
|
1798
|
-
|
|
2096
|
+
case 21:
|
|
2097
|
+
pickedDisplayObjects.push(displayObject);
|
|
1799
2098
|
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
2099
|
+
case 22:
|
|
2100
|
+
_i++;
|
|
2101
|
+
_context.next = 9;
|
|
2102
|
+
break;
|
|
1804
2103
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2104
|
+
case 25:
|
|
2105
|
+
result.picked = pickedDisplayObjects;
|
|
2106
|
+
return _context.abrupt("return", result);
|
|
1808
2107
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2108
|
+
case 27:
|
|
2109
|
+
case "end":
|
|
2110
|
+
return _context.stop();
|
|
2111
|
+
}
|
|
1812
2112
|
}
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
}));
|
|
2113
|
+
}, _callee);
|
|
2114
|
+
}));
|
|
1816
2115
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
2116
|
+
return function (_x) {
|
|
2117
|
+
return _ref.apply(this, arguments);
|
|
2118
|
+
};
|
|
2119
|
+
}());
|
|
2120
|
+
}
|
|
2121
|
+
}]);
|
|
1822
2122
|
|
|
1823
2123
|
return CanvasPickerPlugin;
|
|
1824
2124
|
}(), _class.tag = 'CanvasPicker', _class);
|
|
@@ -1838,6 +2138,41 @@
|
|
|
1838
2138
|
CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([g.singleton({
|
|
1839
2139
|
contrib: g.RenderingPluginContribution
|
|
1840
2140
|
})], 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
|
+
}
|
|
1841
2176
|
/**
|
|
1842
2177
|
* 两点之间的距离
|
|
1843
2178
|
* @param {number} x1 起始点 x
|
|
@@ -1847,6 +2182,7 @@
|
|
|
1847
2182
|
* @return {number} 距离
|
|
1848
2183
|
*/
|
|
1849
2184
|
|
|
2185
|
+
|
|
1850
2186
|
function distance(x1, y1, x2, y2) {
|
|
1851
2187
|
var dx = x1 - x2;
|
|
1852
2188
|
var dy = y1 - y2;
|
|
@@ -1858,10 +2194,10 @@
|
|
|
1858
2194
|
}
|
|
1859
2195
|
|
|
1860
2196
|
function getBBoxByArray(xArr, yArr) {
|
|
1861
|
-
var minX = Math.min.apply(Math, xArr);
|
|
1862
|
-
var minY = Math.min.apply(Math, yArr);
|
|
1863
|
-
var maxX = Math.max.apply(Math, xArr);
|
|
1864
|
-
var maxY = Math.max.apply(Math, yArr);
|
|
2197
|
+
var minX = Math.min.apply(Math, _toConsumableArray$1(xArr));
|
|
2198
|
+
var minY = Math.min.apply(Math, _toConsumableArray$1(yArr));
|
|
2199
|
+
var maxX = Math.max.apply(Math, _toConsumableArray$1(xArr));
|
|
2200
|
+
var maxY = Math.max.apply(Math, _toConsumableArray$1(yArr));
|
|
1865
2201
|
return {
|
|
1866
2202
|
x: minX,
|
|
1867
2203
|
y: minY,
|
|
@@ -2004,7 +2340,7 @@
|
|
|
2004
2340
|
for (var i = 0; i <= segNum; i++) {
|
|
2005
2341
|
var _t = i * increaseRate;
|
|
2006
2342
|
|
|
2007
|
-
var v1 = [tCallback.apply(void 0, xArr.concat([_t])), tCallback.apply(void 0, yArr.concat([_t]))];
|
|
2343
|
+
var v1 = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([_t]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([_t])))];
|
|
2008
2344
|
var d1 = distance(v0[0], v0[1], v1[0], v1[1]);
|
|
2009
2345
|
|
|
2010
2346
|
if (d1 < d) {
|
|
@@ -2038,7 +2374,7 @@
|
|
|
2038
2374
|
|
|
2039
2375
|
var prev = t - interval;
|
|
2040
2376
|
var next = t + interval;
|
|
2041
|
-
var _v = [tCallback.apply(void 0, xArr.concat([prev])), tCallback.apply(void 0, yArr.concat([prev]))];
|
|
2377
|
+
var _v = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([prev]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([prev])))];
|
|
2042
2378
|
|
|
2043
2379
|
var _d = distance(v0[0], v0[1], _v[0], _v[1]);
|
|
2044
2380
|
|
|
@@ -2046,7 +2382,7 @@
|
|
|
2046
2382
|
t = prev;
|
|
2047
2383
|
d = _d;
|
|
2048
2384
|
} else {
|
|
2049
|
-
var v2 = [tCallback.apply(void 0, xArr.concat([next])), tCallback.apply(void 0, yArr.concat([next]))];
|
|
2385
|
+
var v2 = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([next]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([next])))];
|
|
2050
2386
|
var d2 = distance(v0[0], v0[1], v2[0], v2[1]);
|
|
2051
2387
|
|
|
2052
2388
|
if (next <= 1 && d2 < d) {
|
|
@@ -2059,8 +2395,8 @@
|
|
|
2059
2395
|
}
|
|
2060
2396
|
|
|
2061
2397
|
return {
|
|
2062
|
-
x: tCallback.apply(void 0, xArr.concat([t])),
|
|
2063
|
-
y: tCallback.apply(void 0, yArr.concat([t]))
|
|
2398
|
+
x: tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([t]))),
|
|
2399
|
+
y: tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([t])))
|
|
2064
2400
|
};
|
|
2065
2401
|
} // 近似求解 https://community.khronos.org/t/3d-cubic-bezier-segment-length/62363/2
|
|
2066
2402
|
|
|
@@ -2129,7 +2465,7 @@
|
|
|
2129
2465
|
var right = quadratics[1];
|
|
2130
2466
|
left.push(iterationCount - 1);
|
|
2131
2467
|
right.push(iterationCount - 1);
|
|
2132
|
-
return quadraticLength.apply(void 0, left) + quadraticLength.apply(void 0, right);
|
|
2468
|
+
return quadraticLength.apply(void 0, _toConsumableArray$1(left)) + quadraticLength.apply(void 0, _toConsumableArray$1(right));
|
|
2133
2469
|
}
|
|
2134
2470
|
|
|
2135
2471
|
var quadratic = {
|
|
@@ -2250,9 +2586,9 @@
|
|
|
2250
2586
|
}
|
|
2251
2587
|
|
|
2252
2588
|
var cubics = divideCubic(x1, y1, x2, y2, x3, y3, x4, y4, 0.5);
|
|
2253
|
-
var left = [].concat(cubics[0], [iterationCount - 1]);
|
|
2254
|
-
var right = [].concat(cubics[1], [iterationCount - 1]);
|
|
2255
|
-
return cubicLength.apply(void 0, left) + cubicLength.apply(void 0, right);
|
|
2589
|
+
var left = [].concat(_toConsumableArray$1(cubics[0]), [iterationCount - 1]);
|
|
2590
|
+
var right = [].concat(_toConsumableArray$1(cubics[1]), [iterationCount - 1]);
|
|
2591
|
+
return cubicLength.apply(void 0, _toConsumableArray$1(left)) + cubicLength.apply(void 0, _toConsumableArray$1(right));
|
|
2256
2592
|
}
|
|
2257
2593
|
|
|
2258
2594
|
var cubic = {
|
|
@@ -2760,10 +3096,12 @@
|
|
|
2760
3096
|
}
|
|
2761
3097
|
|
|
2762
3098
|
function inRectWithRadius(minX, minY, width, height, radiusArray, lineWidth, x, y) {
|
|
2763
|
-
var
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
3099
|
+
var _radiusArray = _slicedToArray$1(radiusArray, 4),
|
|
3100
|
+
tlr = _radiusArray[0],
|
|
3101
|
+
trr = _radiusArray[1],
|
|
3102
|
+
brr = _radiusArray[2],
|
|
3103
|
+
blr = _radiusArray[3];
|
|
3104
|
+
|
|
2767
3105
|
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);
|
|
2768
3106
|
}
|
|
2769
3107
|
|
|
@@ -2802,18 +3140,22 @@
|
|
|
2802
3140
|
|
|
2803
3141
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
2804
3142
|
function Plugin() {
|
|
3143
|
+
_classCallCheck$2(this, Plugin);
|
|
3144
|
+
|
|
2805
3145
|
this.name = 'canvas-picker';
|
|
2806
3146
|
}
|
|
2807
3147
|
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
container
|
|
2816
|
-
|
|
3148
|
+
_createClass$2(Plugin, [{
|
|
3149
|
+
key: "init",
|
|
3150
|
+
value: function init(container) {
|
|
3151
|
+
container.load(containerModule$1, true);
|
|
3152
|
+
}
|
|
3153
|
+
}, {
|
|
3154
|
+
key: "destroy",
|
|
3155
|
+
value: function destroy(container) {
|
|
3156
|
+
container.unload(containerModule$1);
|
|
3157
|
+
}
|
|
3158
|
+
}]);
|
|
2817
3159
|
|
|
2818
3160
|
return Plugin;
|
|
2819
3161
|
}();
|
|
@@ -2823,219 +3165,56 @@
|
|
|
2823
3165
|
Plugin: Plugin$1
|
|
2824
3166
|
});
|
|
2825
3167
|
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
this.patternCache = {};
|
|
2831
|
-
this.canvasConfig = void 0;
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
var _proto = ImagePool.prototype;
|
|
2835
|
-
|
|
2836
|
-
_proto.getImageSync = function getImageSync(src, callback) {
|
|
2837
|
-
if (!this.imageCache[src]) {
|
|
2838
|
-
this.getOrCreateImage(src).then(function () {
|
|
2839
|
-
if (callback) {
|
|
2840
|
-
callback();
|
|
2841
|
-
}
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
|
|
2845
|
-
return this.imageCache[src];
|
|
3168
|
+
function _regeneratorRuntime$2() {
|
|
3169
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3170
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
3171
|
+
return exports;
|
|
2846
3172
|
};
|
|
2847
3173
|
|
|
2848
|
-
|
|
2849
|
-
|
|
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";
|
|
2850
3181
|
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
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
|
+
}
|
|
2854
3190
|
|
|
3191
|
+
try {
|
|
3192
|
+
define({}, "");
|
|
3193
|
+
} catch (err) {
|
|
3194
|
+
define = function define(obj, key, value) {
|
|
3195
|
+
return obj[key] = value;
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
2855
3198
|
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
3199
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
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");
|
|
2859
3207
|
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
}
|
|
3208
|
+
if ("completed" === state) {
|
|
3209
|
+
if ("throw" === method) throw arg;
|
|
3210
|
+
return doneResult();
|
|
3211
|
+
}
|
|
2865
3212
|
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
resolve(image);
|
|
2869
|
-
};
|
|
3213
|
+
for (context.method = method, context.arg = arg;;) {
|
|
3214
|
+
var delegate = context.delegate;
|
|
2870
3215
|
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
};
|
|
2874
|
-
|
|
2875
|
-
image.crossOrigin = 'Anonymous';
|
|
2876
|
-
image.src = src;
|
|
2877
|
-
_this.imageCache[src] = image;
|
|
2878
|
-
}
|
|
2879
|
-
});
|
|
2880
|
-
};
|
|
2881
|
-
|
|
2882
|
-
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
|
|
2883
|
-
var patternKey = this.generatePatternKey(pattern);
|
|
2884
|
-
|
|
2885
|
-
if (patternKey && this.patternCache[patternKey]) {
|
|
2886
|
-
return this.patternCache[patternKey];
|
|
2887
|
-
}
|
|
2888
|
-
|
|
2889
|
-
var image = pattern.image,
|
|
2890
|
-
repetition = pattern.repetition;
|
|
2891
|
-
var src; // Image URL
|
|
2892
|
-
|
|
2893
|
-
if (g.isString(image)) {
|
|
2894
|
-
src = this.getImageSync(image, callback);
|
|
2895
|
-
} else {
|
|
2896
|
-
src = image;
|
|
2897
|
-
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
var canvasPattern = src && context.createPattern(src, repetition);
|
|
2901
|
-
|
|
2902
|
-
if (patternKey && canvasPattern) {
|
|
2903
|
-
this.patternCache[patternKey] = canvasPattern;
|
|
2904
|
-
}
|
|
2905
|
-
|
|
2906
|
-
return canvasPattern;
|
|
2907
|
-
};
|
|
2908
|
-
|
|
2909
|
-
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
2910
|
-
var key = this.generateGradientKey(params); // @ts-ignore
|
|
2911
|
-
|
|
2912
|
-
var type = params.type,
|
|
2913
|
-
steps = params.steps,
|
|
2914
|
-
width = params.width,
|
|
2915
|
-
height = params.height,
|
|
2916
|
-
angle = params.angle,
|
|
2917
|
-
cx = params.cx,
|
|
2918
|
-
cy = params.cy;
|
|
2919
|
-
|
|
2920
|
-
if (this.gradientCache[key]) {
|
|
2921
|
-
return this.gradientCache[key];
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
var gradient = null;
|
|
2925
|
-
|
|
2926
|
-
if (type === g.GradientType.LinearGradient) {
|
|
2927
|
-
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
2928
|
-
x1 = _computeLinearGradien.x1,
|
|
2929
|
-
y1 = _computeLinearGradien.y1,
|
|
2930
|
-
x2 = _computeLinearGradien.x2,
|
|
2931
|
-
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
2935
|
-
} else if (type === g.GradientType.RadialGradient) {
|
|
2936
|
-
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
2937
|
-
x = _computeRadialGradien.x,
|
|
2938
|
-
y = _computeRadialGradien.y,
|
|
2939
|
-
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
2943
|
-
}
|
|
2944
|
-
|
|
2945
|
-
if (gradient) {
|
|
2946
|
-
steps.forEach(function (_ref) {
|
|
2947
|
-
var _gradient;
|
|
2948
|
-
|
|
2949
|
-
var offset = _ref[0],
|
|
2950
|
-
color = _ref[1];
|
|
2951
|
-
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
2952
|
-
});
|
|
2953
|
-
this.gradientCache[key] = gradient;
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
return this.gradientCache[key];
|
|
2957
|
-
};
|
|
2958
|
-
|
|
2959
|
-
_proto.generateGradientKey = function generateGradientKey(params) {
|
|
2960
|
-
// @ts-ignore
|
|
2961
|
-
var type = params.type,
|
|
2962
|
-
width = params.width,
|
|
2963
|
-
height = params.height,
|
|
2964
|
-
steps = params.steps,
|
|
2965
|
-
angle = params.angle,
|
|
2966
|
-
cx = params.cx,
|
|
2967
|
-
cy = params.cy;
|
|
2968
|
-
return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
2969
|
-
return step.join('');
|
|
2970
|
-
}).join('-');
|
|
2971
|
-
};
|
|
2972
|
-
|
|
2973
|
-
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2974
|
-
var image = pattern.image,
|
|
2975
|
-
repetition = pattern.repetition; // only generate cache for Image
|
|
2976
|
-
|
|
2977
|
-
if (g.isString(image)) {
|
|
2978
|
-
return "pattern-" + image + "-" + repetition;
|
|
2979
|
-
}
|
|
2980
|
-
};
|
|
2981
|
-
|
|
2982
|
-
return ImagePool;
|
|
2983
|
-
}();
|
|
2984
|
-
|
|
2985
|
-
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
2986
|
-
|
|
2987
|
-
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
2988
|
-
|
|
2989
|
-
function _regeneratorRuntime$2() {
|
|
2990
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2991
|
-
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2992
|
-
return exports;
|
|
2993
|
-
};
|
|
2994
|
-
|
|
2995
|
-
var exports = {},
|
|
2996
|
-
Op = Object.prototype,
|
|
2997
|
-
hasOwn = Op.hasOwnProperty,
|
|
2998
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
2999
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
3000
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
3001
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
3002
|
-
|
|
3003
|
-
function define(obj, key, value) {
|
|
3004
|
-
return Object.defineProperty(obj, key, {
|
|
3005
|
-
value: value,
|
|
3006
|
-
enumerable: !0,
|
|
3007
|
-
configurable: !0,
|
|
3008
|
-
writable: !0
|
|
3009
|
-
}), obj[key];
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3012
|
-
try {
|
|
3013
|
-
define({}, "");
|
|
3014
|
-
} catch (err) {
|
|
3015
|
-
define = function define(obj, key, value) {
|
|
3016
|
-
return obj[key] = value;
|
|
3017
|
-
};
|
|
3018
|
-
}
|
|
3019
|
-
|
|
3020
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
3021
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
3022
|
-
generator = Object.create(protoGenerator.prototype),
|
|
3023
|
-
context = new Context(tryLocsList || []);
|
|
3024
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
3025
|
-
var state = "suspendedStart";
|
|
3026
|
-
return function (method, arg) {
|
|
3027
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
3028
|
-
|
|
3029
|
-
if ("completed" === state) {
|
|
3030
|
-
if ("throw" === method) throw arg;
|
|
3031
|
-
return doneResult();
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
for (context.method = method, context.arg = arg;;) {
|
|
3035
|
-
var delegate = context.delegate;
|
|
3036
|
-
|
|
3037
|
-
if (delegate) {
|
|
3038
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
3216
|
+
if (delegate) {
|
|
3217
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
3039
3218
|
|
|
3040
3219
|
if (delegateResult) {
|
|
3041
3220
|
if (delegateResult === ContinueSentinel) continue;
|
|
@@ -3111,7 +3290,7 @@
|
|
|
3111
3290
|
if ("throw" !== record.type) {
|
|
3112
3291
|
var result = record.arg,
|
|
3113
3292
|
value = result.value;
|
|
3114
|
-
return value && "object" ==
|
|
3293
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3115
3294
|
invoke("next", value, resolve, reject);
|
|
3116
3295
|
}, function (err) {
|
|
3117
3296
|
invoke("throw", err, resolve, reject);
|
|
@@ -3372,78 +3551,340 @@
|
|
|
3372
3551
|
};
|
|
3373
3552
|
}
|
|
3374
3553
|
|
|
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
|
+
|
|
3375
3813
|
var _class$1;
|
|
3376
3814
|
|
|
3377
3815
|
var LoadImagePlugin_1;
|
|
3378
3816
|
var LoadImagePlugin = LoadImagePlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
3379
3817
|
function LoadImagePlugin() {
|
|
3818
|
+
_classCallCheck$3(this, LoadImagePlugin);
|
|
3819
|
+
|
|
3380
3820
|
this.imagePool = void 0;
|
|
3381
3821
|
this.renderingContext = void 0;
|
|
3382
3822
|
}
|
|
3383
3823
|
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
var handleMounted = function handleMounted(e) {
|
|
3390
|
-
var object = e.target;
|
|
3391
|
-
var nodeName = object.nodeName,
|
|
3392
|
-
attributes = object.attributes;
|
|
3824
|
+
_createClass$3(LoadImagePlugin, [{
|
|
3825
|
+
key: "apply",
|
|
3826
|
+
value: function apply(renderingService) {
|
|
3827
|
+
var _this = this;
|
|
3393
3828
|
|
|
3394
|
-
|
|
3395
|
-
var
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
_this.imagePool.getImageSync(img, function () {
|
|
3399
|
-
// set dirty rectangle flag
|
|
3400
|
-
object.renderable.dirty = true;
|
|
3401
|
-
renderingService.dirtify();
|
|
3402
|
-
});
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
};
|
|
3829
|
+
var handleMounted = function handleMounted(e) {
|
|
3830
|
+
var object = e.target;
|
|
3831
|
+
var nodeName = object.nodeName,
|
|
3832
|
+
attributes = object.attributes;
|
|
3406
3833
|
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
var attrName = e.attrName,
|
|
3410
|
-
newValue = e.newValue;
|
|
3834
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
3835
|
+
var img = attributes.img;
|
|
3411
3836
|
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
if (g.isString(newValue)) {
|
|
3415
|
-
_this.imagePool.getOrCreateImage(newValue).then(function () {
|
|
3837
|
+
if (g.isString(img)) {
|
|
3838
|
+
_this.imagePool.getImageSync(img, function () {
|
|
3416
3839
|
// set dirty rectangle flag
|
|
3417
3840
|
object.renderable.dirty = true;
|
|
3418
3841
|
renderingService.dirtify();
|
|
3419
3842
|
});
|
|
3420
3843
|
}
|
|
3421
3844
|
}
|
|
3422
|
-
}
|
|
3423
|
-
|
|
3845
|
+
};
|
|
3846
|
+
|
|
3847
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
3848
|
+
var object = e.target;
|
|
3849
|
+
var attrName = e.attrName,
|
|
3850
|
+
newValue = e.newValue;
|
|
3851
|
+
|
|
3852
|
+
if (object.nodeName === g.Shape.IMAGE) {
|
|
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
|
+
};
|
|
3424
3864
|
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3865
|
+
renderingService.hooks.init.tapPromise(LoadImagePlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
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);
|
|
3431
3871
|
|
|
3432
|
-
|
|
3872
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3433
3873
|
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3874
|
+
case 2:
|
|
3875
|
+
case "end":
|
|
3876
|
+
return _context.stop();
|
|
3877
|
+
}
|
|
3437
3878
|
}
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3879
|
+
}, _callee);
|
|
3880
|
+
})));
|
|
3881
|
+
renderingService.hooks.destroy.tap(LoadImagePlugin_1.tag, function () {
|
|
3882
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3443
3883
|
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3884
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3887
|
+
}]);
|
|
3447
3888
|
|
|
3448
3889
|
return LoadImagePlugin;
|
|
3449
3890
|
}(), _class$1.tag = 'LoadImage', _class$1);
|
|
@@ -3462,18 +3903,22 @@
|
|
|
3462
3903
|
|
|
3463
3904
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
3464
3905
|
function Plugin() {
|
|
3906
|
+
_classCallCheck$3(this, Plugin);
|
|
3907
|
+
|
|
3465
3908
|
this.name = 'image-loader';
|
|
3466
3909
|
}
|
|
3467
3910
|
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
container
|
|
3476
|
-
|
|
3911
|
+
_createClass$3(Plugin, [{
|
|
3912
|
+
key: "init",
|
|
3913
|
+
value: function init(container) {
|
|
3914
|
+
container.load(containerModule$2, true);
|
|
3915
|
+
}
|
|
3916
|
+
}, {
|
|
3917
|
+
key: "destroy",
|
|
3918
|
+
value: function destroy(container) {
|
|
3919
|
+
container.unload(containerModule$2);
|
|
3920
|
+
}
|
|
3921
|
+
}]);
|
|
3477
3922
|
|
|
3478
3923
|
return Plugin;
|
|
3479
3924
|
}();
|
|
@@ -3484,6 +3929,32 @@
|
|
|
3484
3929
|
Plugin: Plugin$2
|
|
3485
3930
|
});
|
|
3486
3931
|
|
|
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
|
+
|
|
3487
3958
|
function _regeneratorRuntime$3() {
|
|
3488
3959
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3489
3960
|
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
@@ -3609,7 +4080,7 @@
|
|
|
3609
4080
|
if ("throw" !== record.type) {
|
|
3610
4081
|
var result = record.arg,
|
|
3611
4082
|
value = result.value;
|
|
3612
|
-
return value && "object" ==
|
|
4083
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3613
4084
|
invoke("next", value, resolve, reject);
|
|
3614
4085
|
}, function (err) {
|
|
3615
4086
|
invoke("throw", err, resolve, reject);
|
|
@@ -3834,74 +4305,240 @@
|
|
|
3834
4305
|
}, exports;
|
|
3835
4306
|
}
|
|
3836
4307
|
|
|
3837
|
-
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
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
|
+
|
|
3838
4422
|
try {
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
} catch (
|
|
3842
|
-
|
|
3843
|
-
return;
|
|
4423
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4424
|
+
return true;
|
|
4425
|
+
} catch (e) {
|
|
4426
|
+
return false;
|
|
3844
4427
|
}
|
|
4428
|
+
}
|
|
3845
4429
|
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
Promise.resolve(value).then(_next, _throw);
|
|
4430
|
+
function _assertThisInitialized$1(self) {
|
|
4431
|
+
if (self === void 0) {
|
|
4432
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3850
4433
|
}
|
|
4434
|
+
|
|
4435
|
+
return self;
|
|
3851
4436
|
}
|
|
3852
4437
|
|
|
3853
|
-
function
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
4438
|
+
function _possibleConstructorReturn$1(self, call) {
|
|
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");
|
|
4443
|
+
}
|
|
3859
4444
|
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
}
|
|
4445
|
+
return _assertThisInitialized$1(self);
|
|
4446
|
+
}
|
|
3863
4447
|
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
}
|
|
4448
|
+
function _createSuper$1(Derived) {
|
|
4449
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
3867
4450
|
|
|
3868
|
-
|
|
3869
|
-
|
|
4451
|
+
return function _createSuperInternal() {
|
|
4452
|
+
var Super = _getPrototypeOf$1(Derived),
|
|
4453
|
+
result;
|
|
4454
|
+
|
|
4455
|
+
if (hasNativeReflectConstruct) {
|
|
4456
|
+
var NewTarget = _getPrototypeOf$1(this).constructor;
|
|
4457
|
+
|
|
4458
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
4459
|
+
} else {
|
|
4460
|
+
result = Super.apply(this, arguments);
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
return _possibleConstructorReturn$1(this, result);
|
|
3870
4464
|
};
|
|
3871
4465
|
}
|
|
3872
4466
|
|
|
3873
|
-
function
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
4467
|
+
function _slicedToArray$3(arr, i) {
|
|
4468
|
+
return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$3();
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
function _toConsumableArray$2(arr) {
|
|
4472
|
+
return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread$2();
|
|
4473
|
+
}
|
|
3877
4474
|
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
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;
|
|
4496
|
+
|
|
4497
|
+
try {
|
|
4498
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
4499
|
+
_arr.push(_s.value);
|
|
4500
|
+
|
|
4501
|
+
if (i && _arr.length === i) break;
|
|
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;
|
|
3883
4511
|
}
|
|
4512
|
+
}
|
|
3884
4513
|
|
|
3885
|
-
|
|
3886
|
-
|
|
4514
|
+
return _arr;
|
|
4515
|
+
}
|
|
3887
4516
|
|
|
3888
|
-
|
|
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);
|
|
3889
4524
|
}
|
|
3890
4525
|
|
|
3891
|
-
function
|
|
3892
|
-
|
|
3893
|
-
|
|
4526
|
+
function _arrayLikeToArray$3(arr, len) {
|
|
4527
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4528
|
+
|
|
4529
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
4530
|
+
arr2[i] = arr[i];
|
|
4531
|
+
}
|
|
3894
4532
|
|
|
3895
|
-
|
|
4533
|
+
return arr2;
|
|
3896
4534
|
}
|
|
3897
4535
|
|
|
3898
|
-
function
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
return o;
|
|
3902
|
-
};
|
|
4536
|
+
function _nonIterableSpread$2() {
|
|
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.");
|
|
4538
|
+
}
|
|
3903
4539
|
|
|
3904
|
-
|
|
4540
|
+
function _nonIterableRest$3() {
|
|
4541
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3905
4542
|
}
|
|
3906
4543
|
/**
|
|
3907
4544
|
* Common utilities
|
|
@@ -4629,36 +5266,39 @@
|
|
|
4629
5266
|
|
|
4630
5267
|
var ImageRenderer = /*#__PURE__*/function () {
|
|
4631
5268
|
function ImageRenderer() {
|
|
5269
|
+
_classCallCheck$4(this, ImageRenderer);
|
|
5270
|
+
|
|
4632
5271
|
this.imagePool = void 0;
|
|
4633
5272
|
}
|
|
4634
5273
|
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
5274
|
+
_createClass$4(ImageRenderer, [{
|
|
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;
|
|
4644
5283
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
5284
|
+
if (g.isString(img)) {
|
|
5285
|
+
// image has been loaded in `mounted` hook
|
|
5286
|
+
image = this.imagePool.getImageSync(img);
|
|
5287
|
+
} else {
|
|
5288
|
+
iw || (iw = img.width);
|
|
5289
|
+
ih || (ih = img.height);
|
|
5290
|
+
image = img;
|
|
5291
|
+
}
|
|
4653
5292
|
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
5293
|
+
if (image) {
|
|
5294
|
+
// node-canvas will throw the following err:
|
|
5295
|
+
// Error: Image given has not completed loading
|
|
5296
|
+
try {
|
|
5297
|
+
context.drawImage(image, 0, 0, iw, ih);
|
|
5298
|
+
} catch (e) {}
|
|
5299
|
+
}
|
|
4660
5300
|
}
|
|
4661
|
-
};
|
|
5301
|
+
}]);
|
|
4662
5302
|
|
|
4663
5303
|
return ImageRenderer;
|
|
4664
5304
|
}();
|
|
@@ -4670,154 +5310,157 @@
|
|
|
4670
5310
|
})], ImageRenderer);
|
|
4671
5311
|
|
|
4672
5312
|
var TextRenderer = /*#__PURE__*/function () {
|
|
4673
|
-
function TextRenderer() {
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
4723
|
-
linePositionY += dy.value;
|
|
4724
|
-
} // draw lines line by line
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
for (var i = 0; i < lines.length; i++) {
|
|
4728
|
-
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
4729
|
-
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
4730
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
4731
|
-
|
|
4732
|
-
if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
|
|
4733
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
4734
|
-
}
|
|
4735
|
-
|
|
4736
|
-
if (!g.isNil(fill)) {
|
|
4737
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
|
|
5313
|
+
function TextRenderer() {
|
|
5314
|
+
_classCallCheck$4(this, TextRenderer);
|
|
5315
|
+
}
|
|
5316
|
+
|
|
5317
|
+
_createClass$4(TextRenderer, [{
|
|
5318
|
+
key: "render",
|
|
5319
|
+
value: function render(context, parsedStyle, object) {
|
|
5320
|
+
var lineWidth = parsedStyle.lineWidth,
|
|
5321
|
+
textAlign = parsedStyle.textAlign,
|
|
5322
|
+
textBaseline = parsedStyle.textBaseline,
|
|
5323
|
+
lineJoin = parsedStyle.lineJoin,
|
|
5324
|
+
_parsedStyle$miterLim = parsedStyle.miterLimit,
|
|
5325
|
+
miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
|
|
5326
|
+
_parsedStyle$letterSp = parsedStyle.letterSpacing,
|
|
5327
|
+
letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
|
|
5328
|
+
stroke = parsedStyle.stroke,
|
|
5329
|
+
fill = parsedStyle.fill,
|
|
5330
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
5331
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
5332
|
+
opacity = parsedStyle.opacity,
|
|
5333
|
+
metrics = parsedStyle.metrics,
|
|
5334
|
+
dx = parsedStyle.dx,
|
|
5335
|
+
dy = parsedStyle.dy;
|
|
5336
|
+
var font = metrics.font,
|
|
5337
|
+
lines = metrics.lines,
|
|
5338
|
+
height = metrics.height,
|
|
5339
|
+
lineHeight = metrics.lineHeight,
|
|
5340
|
+
lineMetrics = metrics.lineMetrics;
|
|
5341
|
+
context.font = font;
|
|
5342
|
+
context.lineWidth = lineWidth.value;
|
|
5343
|
+
context.textAlign = textAlign.value;
|
|
5344
|
+
context.textBaseline = textBaseline.value;
|
|
5345
|
+
context.lineJoin = lineJoin.value;
|
|
5346
|
+
context.miterLimit = miterLimit;
|
|
5347
|
+
var linePositionY = 0; // handle vertical text baseline
|
|
5348
|
+
|
|
5349
|
+
if (textBaseline.value === 'middle') {
|
|
5350
|
+
linePositionY = -height / 2 - lineHeight / 2;
|
|
5351
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
5352
|
+
linePositionY = -height;
|
|
5353
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
5354
|
+
linePositionY = -lineHeight;
|
|
5355
|
+
} // account for dx & dy
|
|
5356
|
+
|
|
5357
|
+
|
|
5358
|
+
var offsetX = 0;
|
|
5359
|
+
|
|
5360
|
+
if (dx && dx.unit === g.UnitType.kPixels) {
|
|
5361
|
+
offsetX += dx.value;
|
|
4738
5362
|
}
|
|
4739
|
-
}
|
|
4740
|
-
};
|
|
4741
5363
|
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
} // letterSpacing of 0 means normal, render all texts directly
|
|
5364
|
+
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
5365
|
+
linePositionY += dy.value;
|
|
5366
|
+
} // draw lines line by line
|
|
4746
5367
|
|
|
4747
5368
|
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
4753
|
-
}
|
|
5369
|
+
for (var i = 0; i < lines.length; i++) {
|
|
5370
|
+
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
5371
|
+
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
5372
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
4754
5373
|
|
|
4755
|
-
|
|
4756
|
-
|
|
5374
|
+
if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
|
|
5375
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
5376
|
+
}
|
|
4757
5377
|
|
|
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
|
|
4758
5387
|
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
5388
|
+
if (letterSpacing === 0) {
|
|
5389
|
+
if (isStroke) {
|
|
5390
|
+
this.strokeText(context, text, x, y, strokeOpacity);
|
|
5391
|
+
} else {
|
|
5392
|
+
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
5393
|
+
}
|
|
4762
5394
|
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
4766
|
-
currentPosition = x - lineMetrics.width;
|
|
4767
|
-
}
|
|
5395
|
+
return;
|
|
5396
|
+
} // draw text using left align
|
|
4768
5397
|
|
|
4769
|
-
var stringArray = Array.from(text);
|
|
4770
|
-
var previousWidth = context.measureText(text).width;
|
|
4771
|
-
var currentWidth = 0;
|
|
4772
5398
|
|
|
4773
|
-
|
|
4774
|
-
|
|
5399
|
+
var currentTextAlign = context.textAlign;
|
|
5400
|
+
context.textAlign = 'left';
|
|
5401
|
+
var currentPosition = x;
|
|
4775
5402
|
|
|
4776
|
-
if (
|
|
4777
|
-
|
|
4778
|
-
} else {
|
|
4779
|
-
|
|
5403
|
+
if (textAlign === 'center') {
|
|
5404
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
5405
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
5406
|
+
currentPosition = x - lineMetrics.width;
|
|
4780
5407
|
}
|
|
4781
5408
|
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
}
|
|
4786
|
-
|
|
4787
|
-
context.textAlign = currentTextAlign;
|
|
4788
|
-
};
|
|
5409
|
+
var stringArray = Array.from(text);
|
|
5410
|
+
var previousWidth = context.measureText(text).width;
|
|
5411
|
+
var currentWidth = 0;
|
|
4789
5412
|
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
5413
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
5414
|
+
var currentChar = stringArray[i];
|
|
4793
5415
|
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
5416
|
+
if (isStroke) {
|
|
5417
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
5418
|
+
} else {
|
|
5419
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
5420
|
+
}
|
|
4798
5421
|
|
|
4799
|
-
|
|
5422
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
5423
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
5424
|
+
previousWidth = currentWidth;
|
|
5425
|
+
}
|
|
4800
5426
|
|
|
4801
|
-
|
|
4802
|
-
context.globalAlpha = currentGlobalAlpha;
|
|
5427
|
+
context.textAlign = currentTextAlign;
|
|
4803
5428
|
}
|
|
4804
|
-
}
|
|
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
|
+
}
|
|
4805
5439
|
|
|
4806
|
-
|
|
4807
|
-
var currentGlobalAlpha;
|
|
4808
|
-
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
5440
|
+
context.fillText(text, x, y);
|
|
4809
5441
|
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
5442
|
+
if (applyOpacity) {
|
|
5443
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5444
|
+
}
|
|
4813
5445
|
}
|
|
5446
|
+
}, {
|
|
5447
|
+
key: "strokeText",
|
|
5448
|
+
value: function strokeText(context, text, x, y, strokeOpacity) {
|
|
5449
|
+
var currentGlobalAlpha;
|
|
5450
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
5451
|
+
|
|
5452
|
+
if (applyOpacity) {
|
|
5453
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
5454
|
+
context.globalAlpha = strokeOpacity;
|
|
5455
|
+
}
|
|
4814
5456
|
|
|
4815
|
-
|
|
5457
|
+
context.strokeText(text, x, y);
|
|
4816
5458
|
|
|
4817
|
-
|
|
4818
|
-
|
|
5459
|
+
if (applyOpacity) {
|
|
5460
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5461
|
+
}
|
|
4819
5462
|
}
|
|
4820
|
-
};
|
|
5463
|
+
}]);
|
|
4821
5464
|
|
|
4822
5465
|
return TextRenderer;
|
|
4823
5466
|
}();
|
|
@@ -4828,170 +5471,177 @@
|
|
|
4828
5471
|
|
|
4829
5472
|
var DefaultRenderer = /*#__PURE__*/function () {
|
|
4830
5473
|
function DefaultRenderer() {
|
|
5474
|
+
_classCallCheck$4(this, DefaultRenderer);
|
|
5475
|
+
|
|
4831
5476
|
this.imagePool = void 0;
|
|
4832
5477
|
}
|
|
4833
5478
|
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
5479
|
+
_createClass$4(DefaultRenderer, [{
|
|
5480
|
+
key: "render",
|
|
5481
|
+
value: function render(context, parsedStyle, object, renderingService) {
|
|
5482
|
+
var fill = parsedStyle.fill,
|
|
5483
|
+
opacity = parsedStyle.opacity,
|
|
5484
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
5485
|
+
stroke = parsedStyle.stroke,
|
|
5486
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
5487
|
+
lineWidth = parsedStyle.lineWidth,
|
|
5488
|
+
lineCap = parsedStyle.lineCap,
|
|
5489
|
+
lineJoin = parsedStyle.lineJoin,
|
|
5490
|
+
shadowColor = parsedStyle.shadowColor,
|
|
5491
|
+
filter = parsedStyle.filter,
|
|
5492
|
+
miterLimit = parsedStyle.miterLimit;
|
|
5493
|
+
var hasFill = !g.isNil(fill) && !fill.isNone;
|
|
5494
|
+
var hasStroke = !g.isNil(stroke) && !stroke.isNone;
|
|
5495
|
+
var isFillTransparent = fill.alpha === 0;
|
|
5496
|
+
|
|
5497
|
+
if (hasFill) {
|
|
5498
|
+
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
5499
|
+
context.globalAlpha = fillOpacity.value;
|
|
5500
|
+
this.fill(context, object, fill, renderingService);
|
|
5501
|
+
context.globalAlpha = opacity.value;
|
|
5502
|
+
} else {
|
|
5503
|
+
this.fill(context, object, fill, renderingService);
|
|
5504
|
+
}
|
|
4859
5505
|
}
|
|
4860
|
-
}
|
|
4861
5506
|
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
5507
|
+
if (hasStroke) {
|
|
5508
|
+
if (lineWidth && lineWidth.value > 0) {
|
|
5509
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
4865
5510
|
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5511
|
+
if (applyOpacity) {
|
|
5512
|
+
context.globalAlpha = strokeOpacity.value;
|
|
5513
|
+
}
|
|
4869
5514
|
|
|
4870
|
-
|
|
5515
|
+
context.lineWidth = lineWidth.value;
|
|
4871
5516
|
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
5517
|
+
if (!g.isNil(miterLimit)) {
|
|
5518
|
+
context.miterLimit = miterLimit;
|
|
5519
|
+
}
|
|
4875
5520
|
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
5521
|
+
if (!g.isNil(lineCap)) {
|
|
5522
|
+
context.lineCap = lineCap.value;
|
|
5523
|
+
}
|
|
4879
5524
|
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
5525
|
+
if (!g.isNil(lineJoin)) {
|
|
5526
|
+
context.lineJoin = lineJoin.value;
|
|
5527
|
+
}
|
|
4883
5528
|
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
5529
|
+
var oldShadowBlur;
|
|
5530
|
+
var oldShadowColor;
|
|
5531
|
+
var oldFilter;
|
|
5532
|
+
var hasShadowColor = !g.isNil(shadowColor);
|
|
5533
|
+
var hasFilter = !g.isNil(filter);
|
|
5534
|
+
|
|
5535
|
+
if (hasShadowColor) {
|
|
5536
|
+
// prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
|
|
5537
|
+
// save shadow blur
|
|
5538
|
+
oldShadowBlur = context.shadowBlur;
|
|
5539
|
+
oldShadowColor = context.shadowColor;
|
|
5540
|
+
|
|
5541
|
+
if (!g.isNil(oldShadowBlur)) {
|
|
5542
|
+
context.shadowColor = 'transparent';
|
|
5543
|
+
context.shadowBlur = 0;
|
|
5544
|
+
}
|
|
4899
5545
|
}
|
|
4900
|
-
}
|
|
4901
5546
|
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5547
|
+
if (hasFilter) {
|
|
5548
|
+
// save drop-shadow filter
|
|
5549
|
+
oldFilter = context.filter;
|
|
4905
5550
|
|
|
4906
|
-
|
|
4907
|
-
|
|
5551
|
+
if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
5552
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
5553
|
+
}
|
|
4908
5554
|
}
|
|
4909
|
-
}
|
|
4910
5555
|
|
|
4911
|
-
|
|
5556
|
+
var drawStroke = hasFill && !isFillTransparent;
|
|
4912
5557
|
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
5558
|
+
if (drawStroke) {
|
|
5559
|
+
this.stroke(context, object, stroke, renderingService);
|
|
5560
|
+
} // restore shadow blur
|
|
4916
5561
|
|
|
4917
5562
|
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
5563
|
+
if (hasShadowColor) {
|
|
5564
|
+
context.shadowColor = oldShadowColor;
|
|
5565
|
+
context.shadowBlur = oldShadowBlur;
|
|
5566
|
+
} // restore filters
|
|
4922
5567
|
|
|
4923
5568
|
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
5569
|
+
if (hasFilter) {
|
|
5570
|
+
context.filter = oldFilter;
|
|
5571
|
+
}
|
|
4927
5572
|
|
|
4928
|
-
|
|
4929
|
-
|
|
5573
|
+
if (!drawStroke) {
|
|
5574
|
+
this.stroke(context, object, stroke, renderingService);
|
|
5575
|
+
}
|
|
4930
5576
|
}
|
|
4931
5577
|
}
|
|
4932
5578
|
}
|
|
4933
|
-
}
|
|
5579
|
+
}, {
|
|
5580
|
+
key: "fill",
|
|
5581
|
+
value: function fill(context, object, _fill, renderingService) {
|
|
5582
|
+
var _this = this;
|
|
4934
5583
|
|
|
4935
|
-
|
|
4936
|
-
|
|
5584
|
+
if (Array.isArray(_fill)) {
|
|
5585
|
+
_fill.forEach(function (gradient) {
|
|
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
|
+
}
|
|
4937
5593
|
|
|
4938
|
-
if (Array.isArray(_fill)) {
|
|
4939
|
-
_fill.forEach(function (gradient) {
|
|
4940
|
-
context.fillStyle = _this.getColor(gradient, object, context);
|
|
4941
5594
|
context.fill();
|
|
4942
|
-
});
|
|
4943
|
-
} else {
|
|
4944
|
-
if (g.isPattern(_fill)) {
|
|
4945
|
-
context.fillStyle = this.getPattern(_fill, object, context, renderingService);
|
|
4946
5595
|
}
|
|
4947
|
-
|
|
4948
|
-
context.fill();
|
|
4949
5596
|
}
|
|
4950
|
-
}
|
|
5597
|
+
}, {
|
|
5598
|
+
key: "stroke",
|
|
5599
|
+
value: function stroke(context, object, _stroke, renderingService) {
|
|
5600
|
+
var _this2 = this;
|
|
4951
5601
|
|
|
4952
|
-
|
|
4953
|
-
|
|
5602
|
+
if (Array.isArray(_stroke)) {
|
|
5603
|
+
_stroke.forEach(function (gradient) {
|
|
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
|
+
}
|
|
4954
5611
|
|
|
4955
|
-
if (Array.isArray(_stroke)) {
|
|
4956
|
-
_stroke.forEach(function (gradient) {
|
|
4957
|
-
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
4958
5612
|
context.stroke();
|
|
4959
|
-
});
|
|
4960
|
-
} else {
|
|
4961
|
-
if (g.isPattern(_stroke)) {
|
|
4962
|
-
context.strokeStyle = this.getPattern(_stroke, object, context, renderingService);
|
|
4963
5613
|
}
|
|
4964
|
-
|
|
4965
|
-
context.stroke();
|
|
4966
5614
|
}
|
|
4967
|
-
}
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
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
|
+
});
|
|
5623
|
+
return canvasPattern;
|
|
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);
|
|
5640
|
+
}
|
|
4980
5641
|
|
|
4981
|
-
|
|
4982
|
-
var bounds = object.getGeometryBounds();
|
|
4983
|
-
var width = bounds && bounds.halfExtents[0] * 2 || 1;
|
|
4984
|
-
var height = bounds && bounds.halfExtents[1] * 2 || 1;
|
|
4985
|
-
color = this.imagePool.getOrCreateGradient(_extends({
|
|
4986
|
-
type: parsedColor.type
|
|
4987
|
-
}, parsedColor.value, {
|
|
4988
|
-
width: width,
|
|
4989
|
-
height: height
|
|
4990
|
-
}), context);
|
|
5642
|
+
return color;
|
|
4991
5643
|
}
|
|
4992
|
-
|
|
4993
|
-
return color;
|
|
4994
|
-
};
|
|
5644
|
+
}]);
|
|
4995
5645
|
|
|
4996
5646
|
return DefaultRenderer;
|
|
4997
5647
|
}();
|
|
@@ -5001,13 +5651,17 @@
|
|
|
5001
5651
|
DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
|
|
5002
5652
|
|
|
5003
5653
|
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5004
|
-
|
|
5654
|
+
_inherits$1(RectRenderer, _DefaultRenderer);
|
|
5655
|
+
|
|
5656
|
+
var _super = _createSuper$1(RectRenderer);
|
|
5005
5657
|
|
|
5006
5658
|
function RectRenderer() {
|
|
5007
|
-
|
|
5659
|
+
_classCallCheck$4(this, RectRenderer);
|
|
5660
|
+
|
|
5661
|
+
return _super.apply(this, arguments);
|
|
5008
5662
|
}
|
|
5009
5663
|
|
|
5010
|
-
return RectRenderer;
|
|
5664
|
+
return _createClass$4(RectRenderer);
|
|
5011
5665
|
}(DefaultRenderer);
|
|
5012
5666
|
|
|
5013
5667
|
RectRenderer = __decorate([g.singleton({
|
|
@@ -5015,13 +5669,17 @@
|
|
|
5015
5669
|
})], RectRenderer);
|
|
5016
5670
|
|
|
5017
5671
|
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5018
|
-
|
|
5672
|
+
_inherits$1(CircleRenderer, _DefaultRenderer);
|
|
5673
|
+
|
|
5674
|
+
var _super = _createSuper$1(CircleRenderer);
|
|
5019
5675
|
|
|
5020
5676
|
function CircleRenderer() {
|
|
5021
|
-
|
|
5677
|
+
_classCallCheck$4(this, CircleRenderer);
|
|
5678
|
+
|
|
5679
|
+
return _super.apply(this, arguments);
|
|
5022
5680
|
}
|
|
5023
5681
|
|
|
5024
|
-
return CircleRenderer;
|
|
5682
|
+
return _createClass$4(CircleRenderer);
|
|
5025
5683
|
}(DefaultRenderer);
|
|
5026
5684
|
|
|
5027
5685
|
CircleRenderer = __decorate([g.singleton({
|
|
@@ -5029,13 +5687,17 @@
|
|
|
5029
5687
|
})], CircleRenderer);
|
|
5030
5688
|
|
|
5031
5689
|
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5032
|
-
|
|
5690
|
+
_inherits$1(EllipseRenderer, _DefaultRenderer);
|
|
5691
|
+
|
|
5692
|
+
var _super = _createSuper$1(EllipseRenderer);
|
|
5033
5693
|
|
|
5034
5694
|
function EllipseRenderer() {
|
|
5035
|
-
|
|
5695
|
+
_classCallCheck$4(this, EllipseRenderer);
|
|
5696
|
+
|
|
5697
|
+
return _super.apply(this, arguments);
|
|
5036
5698
|
}
|
|
5037
5699
|
|
|
5038
|
-
return EllipseRenderer;
|
|
5700
|
+
return _createClass$4(EllipseRenderer);
|
|
5039
5701
|
}(DefaultRenderer);
|
|
5040
5702
|
|
|
5041
5703
|
EllipseRenderer = __decorate([g.singleton({
|
|
@@ -5043,13 +5705,17 @@
|
|
|
5043
5705
|
})], EllipseRenderer);
|
|
5044
5706
|
|
|
5045
5707
|
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5046
|
-
|
|
5708
|
+
_inherits$1(LineRenderer, _DefaultRenderer);
|
|
5709
|
+
|
|
5710
|
+
var _super = _createSuper$1(LineRenderer);
|
|
5047
5711
|
|
|
5048
5712
|
function LineRenderer() {
|
|
5049
|
-
|
|
5713
|
+
_classCallCheck$4(this, LineRenderer);
|
|
5714
|
+
|
|
5715
|
+
return _super.apply(this, arguments);
|
|
5050
5716
|
}
|
|
5051
5717
|
|
|
5052
|
-
return LineRenderer;
|
|
5718
|
+
return _createClass$4(LineRenderer);
|
|
5053
5719
|
}(DefaultRenderer);
|
|
5054
5720
|
|
|
5055
5721
|
LineRenderer = __decorate([g.singleton({
|
|
@@ -5057,13 +5723,17 @@
|
|
|
5057
5723
|
})], LineRenderer);
|
|
5058
5724
|
|
|
5059
5725
|
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5060
|
-
|
|
5726
|
+
_inherits$1(PolylineRenderer, _DefaultRenderer);
|
|
5727
|
+
|
|
5728
|
+
var _super = _createSuper$1(PolylineRenderer);
|
|
5061
5729
|
|
|
5062
5730
|
function PolylineRenderer() {
|
|
5063
|
-
|
|
5731
|
+
_classCallCheck$4(this, PolylineRenderer);
|
|
5732
|
+
|
|
5733
|
+
return _super.apply(this, arguments);
|
|
5064
5734
|
}
|
|
5065
5735
|
|
|
5066
|
-
return PolylineRenderer;
|
|
5736
|
+
return _createClass$4(PolylineRenderer);
|
|
5067
5737
|
}(DefaultRenderer);
|
|
5068
5738
|
|
|
5069
5739
|
PolylineRenderer = __decorate([g.singleton({
|
|
@@ -5071,13 +5741,17 @@
|
|
|
5071
5741
|
})], PolylineRenderer);
|
|
5072
5742
|
|
|
5073
5743
|
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5074
|
-
|
|
5744
|
+
_inherits$1(PolygonRenderer, _DefaultRenderer);
|
|
5745
|
+
|
|
5746
|
+
var _super = _createSuper$1(PolygonRenderer);
|
|
5075
5747
|
|
|
5076
5748
|
function PolygonRenderer() {
|
|
5077
|
-
|
|
5749
|
+
_classCallCheck$4(this, PolygonRenderer);
|
|
5750
|
+
|
|
5751
|
+
return _super.apply(this, arguments);
|
|
5078
5752
|
}
|
|
5079
5753
|
|
|
5080
|
-
return PolygonRenderer;
|
|
5754
|
+
return _createClass$4(PolygonRenderer);
|
|
5081
5755
|
}(DefaultRenderer);
|
|
5082
5756
|
|
|
5083
5757
|
PolygonRenderer = __decorate([g.singleton({
|
|
@@ -5085,13 +5759,17 @@
|
|
|
5085
5759
|
})], PolygonRenderer);
|
|
5086
5760
|
|
|
5087
5761
|
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
5088
|
-
|
|
5762
|
+
_inherits$1(PathRenderer, _DefaultRenderer);
|
|
5763
|
+
|
|
5764
|
+
var _super = _createSuper$1(PathRenderer);
|
|
5089
5765
|
|
|
5090
5766
|
function PathRenderer() {
|
|
5091
|
-
|
|
5767
|
+
_classCallCheck$4(this, PathRenderer);
|
|
5768
|
+
|
|
5769
|
+
return _super.apply(this, arguments);
|
|
5092
5770
|
}
|
|
5093
5771
|
|
|
5094
|
-
return PathRenderer;
|
|
5772
|
+
return _createClass$4(PathRenderer);
|
|
5095
5773
|
}(DefaultRenderer);
|
|
5096
5774
|
|
|
5097
5775
|
PathRenderer = __decorate([g.singleton({
|
|
@@ -5109,6 +5787,8 @@
|
|
|
5109
5787
|
|
|
5110
5788
|
var CanvasRendererPlugin = CanvasRendererPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
5111
5789
|
function CanvasRendererPlugin() {
|
|
5790
|
+
_classCallCheck$4(this, CanvasRendererPlugin);
|
|
5791
|
+
|
|
5112
5792
|
this.canvasConfig = void 0;
|
|
5113
5793
|
this.camera = void 0;
|
|
5114
5794
|
this.contextService = void 0;
|
|
@@ -5127,459 +5807,476 @@
|
|
|
5127
5807
|
this.tmpMat4 = create$1$1();
|
|
5128
5808
|
}
|
|
5129
5809
|
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5810
|
+
_createClass$4(CanvasRendererPlugin, [{
|
|
5811
|
+
key: "apply",
|
|
5812
|
+
value: function apply(renderingService) {
|
|
5813
|
+
var _this = this;
|
|
5134
5814
|
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5815
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
5816
|
+
var object = e.target; // remove r-bush node
|
|
5817
|
+
// @ts-ignore
|
|
5138
5818
|
|
|
5139
|
-
|
|
5819
|
+
var rBushNode = object.rBushNode;
|
|
5140
5820
|
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5821
|
+
if (rBushNode.aabb) {
|
|
5822
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5823
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5824
|
+
}
|
|
5825
|
+
};
|
|
5146
5826
|
|
|
5147
|
-
|
|
5148
|
-
|
|
5827
|
+
var handleCulled = function handleCulled(e) {
|
|
5828
|
+
var object = e.target; // @ts-ignore
|
|
5149
5829
|
|
|
5150
|
-
|
|
5830
|
+
var rBushNode = object.rBushNode;
|
|
5151
5831
|
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5832
|
+
if (rBushNode.aabb) {
|
|
5833
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5834
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5835
|
+
}
|
|
5836
|
+
};
|
|
5157
5837
|
|
|
5158
|
-
|
|
5159
|
-
|
|
5838
|
+
renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
5839
|
+
var _this$canvasConfig, width, height, context;
|
|
5160
5840
|
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5841
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
5842
|
+
while (1) {
|
|
5843
|
+
switch (_context.prev = _context.next) {
|
|
5844
|
+
case 0:
|
|
5845
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5166
5846
|
|
|
5167
|
-
|
|
5847
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.CULLED, handleCulled); // clear fullscreen
|
|
5168
5848
|
|
|
5169
5849
|
|
|
5170
|
-
|
|
5171
|
-
|
|
5850
|
+
_this$canvasConfig = _this.canvasConfig, width = _this$canvasConfig.width, height = _this$canvasConfig.height;
|
|
5851
|
+
context = _this.contextService.getContext();
|
|
5172
5852
|
|
|
5173
|
-
|
|
5853
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5174
5854
|
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5855
|
+
case 5:
|
|
5856
|
+
case "end":
|
|
5857
|
+
return _context.stop();
|
|
5858
|
+
}
|
|
5178
5859
|
}
|
|
5179
|
-
}
|
|
5180
|
-
}
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5184
|
-
|
|
5185
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.CULLED, handleCulled);
|
|
5186
|
-
});
|
|
5187
|
-
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5188
|
-
var context = _this.contextService.getContext();
|
|
5860
|
+
}, _callee);
|
|
5861
|
+
})));
|
|
5862
|
+
renderingService.hooks.destroy.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5863
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5189
5864
|
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
// 2. camera changed
|
|
5865
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.CULLED, handleCulled);
|
|
5866
|
+
});
|
|
5867
|
+
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5868
|
+
var context = _this.contextService.getContext();
|
|
5195
5869
|
|
|
5196
|
-
|
|
5870
|
+
var _this$canvasConfig2 = _this.canvasConfig,
|
|
5871
|
+
width = _this$canvasConfig2.width,
|
|
5872
|
+
height = _this$canvasConfig2.height; // clear fullscreen when:
|
|
5873
|
+
// 1. dirty rectangle rendering disabled
|
|
5874
|
+
// 2. camera changed
|
|
5197
5875
|
|
|
5198
|
-
|
|
5199
|
-
context.save();
|
|
5876
|
+
_this.clearFullScreen = _this.shouldClearFullScreen();
|
|
5200
5877
|
|
|
5201
|
-
if (
|
|
5202
|
-
|
|
5203
|
-
} // account for camera's world matrix
|
|
5878
|
+
if (context) {
|
|
5879
|
+
context.save();
|
|
5204
5880
|
|
|
5881
|
+
if (_this.clearFullScreen) {
|
|
5882
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5883
|
+
} // account for camera's world matrix
|
|
5205
5884
|
|
|
5206
|
-
_this.applyTransform(context, _this.camera.getOrthoMatrix());
|
|
5207
|
-
}
|
|
5208
|
-
}); // render at the end of frame
|
|
5209
5885
|
|
|
5210
|
-
|
|
5211
|
-
|
|
5886
|
+
_this.applyTransform(context, _this.camera.getOrthoMatrix());
|
|
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
|
|
5212
5947
|
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
// this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
|
|
5217
|
-
_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
5218
|
-
var minX = _ref2.minX,
|
|
5219
|
-
minY = _ref2.minY,
|
|
5220
|
-
maxX = _ref2.maxX,
|
|
5221
|
-
maxY = _ref2.maxY;
|
|
5222
|
-
var aabb = new g.AABB();
|
|
5223
|
-
aabb.setMinMax(fromValues$2(minX, minY, 0), fromValues$2(maxX, maxY, 0));
|
|
5224
|
-
return aabb;
|
|
5225
|
-
})));
|
|
5948
|
+
_this.renderQueue.forEach(function (object) {
|
|
5949
|
+
_this.saveDirtyAABB(object);
|
|
5950
|
+
}); // clear queue
|
|
5226
5951
|
|
|
5227
|
-
_this.removedRBushNodeAABBs = [];
|
|
5228
5952
|
|
|
5229
|
-
if (g.AABB.isEmpty(dirtyRenderBounds)) {
|
|
5230
5953
|
_this.renderQueue = [];
|
|
5231
|
-
|
|
5232
|
-
} // clear & clip dirty rectangle
|
|
5954
|
+
} // pop restore stack, eg. root -> parent -> child
|
|
5233
5955
|
|
|
5956
|
+
_this.restoreStack.forEach(function (s) {
|
|
5957
|
+
context.restore();
|
|
5958
|
+
}); // clear restore stack
|
|
5234
5959
|
|
|
5235
|
-
var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
|
|
5236
|
-
x = _this$convertAABB2Rec.x,
|
|
5237
|
-
y = _this$convertAABB2Rec.y,
|
|
5238
|
-
width = _this$convertAABB2Rec.width,
|
|
5239
|
-
height = _this$convertAABB2Rec.height;
|
|
5240
5960
|
|
|
5241
|
-
_this.
|
|
5242
|
-
|
|
5243
|
-
context.
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
// Math.random() * 255
|
|
5250
|
-
// }, 1)`;
|
|
5251
|
-
// context.strokeRect(x, y, width, height);
|
|
5252
|
-
// }
|
|
5253
|
-
// search objects intersect with dirty rectangle
|
|
5254
|
-
|
|
5255
|
-
var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds); // do rendering
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
dirtyObjects // sort by z-index
|
|
5259
|
-
.sort(function (a, b) {
|
|
5260
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
5261
|
-
}).forEach(function (object) {
|
|
5262
|
-
// culled object should not be rendered
|
|
5263
|
-
if (object && object.isVisible() && !object.isCulled()) {
|
|
5961
|
+
_this.restoreStack = [];
|
|
5962
|
+
_this.clearFullScreen = false;
|
|
5963
|
+
context.restore();
|
|
5964
|
+
});
|
|
5965
|
+
renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
|
|
5966
|
+
if (_this.clearFullScreen) {
|
|
5967
|
+
if (object.isVisible() && !object.isCulled()) {
|
|
5968
|
+
// render immediately
|
|
5264
5969
|
_this.renderDisplayObject(object, renderingService);
|
|
5265
5970
|
}
|
|
5266
|
-
}
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
_this.saveDirtyAABB(object);
|
|
5270
|
-
}); // clear queue
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
_this.renderQueue = [];
|
|
5274
|
-
} // pop restore stack, eg. root -> parent -> child
|
|
5275
|
-
|
|
5276
|
-
_this.restoreStack.forEach(function (s) {
|
|
5277
|
-
context.restore();
|
|
5278
|
-
}); // clear restore stack
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
_this.restoreStack = [];
|
|
5282
|
-
_this.clearFullScreen = false;
|
|
5283
|
-
context.restore();
|
|
5284
|
-
});
|
|
5285
|
-
renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
|
|
5286
|
-
if (_this.clearFullScreen) {
|
|
5287
|
-
if (object.isVisible() && !object.isCulled()) {
|
|
5288
|
-
// render immediately
|
|
5289
|
-
_this.renderDisplayObject(object, renderingService);
|
|
5971
|
+
} else {
|
|
5972
|
+
// render at the end of frame
|
|
5973
|
+
_this.renderQueue.push(object);
|
|
5290
5974
|
}
|
|
5291
|
-
}
|
|
5292
|
-
// render at the end of frame
|
|
5293
|
-
_this.renderQueue.push(object);
|
|
5294
|
-
}
|
|
5295
|
-
});
|
|
5296
|
-
};
|
|
5297
|
-
|
|
5298
|
-
_proto.clearRect = function clearRect(context, x, y, width, height) {
|
|
5299
|
-
context.clearRect(x, y, width, height);
|
|
5300
|
-
var background = this.canvasConfig.background;
|
|
5301
|
-
|
|
5302
|
-
if (background) {
|
|
5303
|
-
context.fillStyle = background;
|
|
5304
|
-
context.fillRect(x, y, width, height);
|
|
5305
|
-
}
|
|
5306
|
-
};
|
|
5307
|
-
|
|
5308
|
-
_proto.renderDisplayObject = function renderDisplayObject(object, renderingService) {
|
|
5309
|
-
var context = this.contextService.getContext(); // restore to its parent
|
|
5310
|
-
|
|
5311
|
-
var parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5312
|
-
|
|
5313
|
-
while (parent && object.parentNode !== parent) {
|
|
5314
|
-
context.restore();
|
|
5315
|
-
this.restoreStack.pop();
|
|
5316
|
-
parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5975
|
+
});
|
|
5317
5976
|
}
|
|
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;
|
|
5318
5982
|
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5983
|
+
if (background) {
|
|
5984
|
+
context.fillStyle = background;
|
|
5985
|
+
context.fillRect(x, y, width, height);
|
|
5986
|
+
}
|
|
5323
5987
|
}
|
|
5988
|
+
}, {
|
|
5989
|
+
key: "renderDisplayObject",
|
|
5990
|
+
value: function renderDisplayObject(object, renderingService) {
|
|
5991
|
+
var context = this.contextService.getContext(); // restore to its parent
|
|
5324
5992
|
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
context.save(); // apply RTS transformation in world space
|
|
5328
|
-
|
|
5329
|
-
this.applyTransform(context, object.getLocalTransform()); // clip path
|
|
5330
|
-
|
|
5331
|
-
var clipPathShape = object.style.clipPath;
|
|
5332
|
-
|
|
5333
|
-
if (clipPathShape) {
|
|
5334
|
-
context.save(); // const parentTransform =
|
|
5335
|
-
// (object.parentElement as DisplayObject)?.getWorldTransform() || mat4.identity(this.tmpMat4);
|
|
5336
|
-
// mat4.multiply(this.tmpMat4, parentTransform, clipPathShape.getLocalTransform());
|
|
5337
|
-
// apply clip shape's RTS
|
|
5993
|
+
var parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5338
5994
|
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
this.
|
|
5995
|
+
while (parent && object.parentNode !== parent) {
|
|
5996
|
+
context.restore();
|
|
5997
|
+
this.restoreStack.pop();
|
|
5998
|
+
parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5343
5999
|
}
|
|
5344
6000
|
|
|
5345
|
-
var
|
|
5346
|
-
|
|
5347
|
-
if (_generatePath) {
|
|
5348
|
-
this.useAnchor(context, clipPathShape);
|
|
5349
|
-
context.beginPath();
|
|
5350
|
-
|
|
5351
|
-
_generatePath(context, clipPathShape.parsedStyle);
|
|
6001
|
+
var nodeName = object.nodeName;
|
|
5352
6002
|
|
|
5353
|
-
|
|
6003
|
+
if (this.styleRendererFactoryCache[nodeName] === undefined) {
|
|
6004
|
+
this.styleRendererFactoryCache[nodeName] = this.styleRendererFactory(nodeName);
|
|
5354
6005
|
}
|
|
5355
6006
|
|
|
5356
|
-
|
|
5357
|
-
context.clip();
|
|
5358
|
-
} // fill & stroke
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
context.save(); // apply attributes to context
|
|
6007
|
+
var styleRenderer = this.styleRendererFactoryCache[nodeName]; // reset transformation
|
|
5362
6008
|
|
|
5363
|
-
|
|
6009
|
+
context.save(); // apply RTS transformation in world space
|
|
5364
6010
|
|
|
5365
|
-
|
|
6011
|
+
this.applyTransform(context, object.getLocalTransform()); // clip path
|
|
5366
6012
|
|
|
5367
|
-
|
|
5368
|
-
this.pathGeneratorFactoryCache[object.nodeName] = this.pathGeneratorFactory(object.nodeName);
|
|
5369
|
-
}
|
|
5370
|
-
|
|
5371
|
-
var generatePath = this.pathGeneratorFactoryCache[object.nodeName];
|
|
6013
|
+
var clipPathShape = object.style.clipPath;
|
|
5372
6014
|
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
6015
|
+
if (clipPathShape) {
|
|
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
|
|
5376
6020
|
|
|
5377
|
-
|
|
5378
|
-
context.closePath();
|
|
5379
|
-
}
|
|
5380
|
-
} // fill & stroke
|
|
6021
|
+
this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
|
|
5381
6022
|
|
|
6023
|
+
if (this.pathGeneratorFactoryCache[clipPathShape.nodeName] === undefined) {
|
|
6024
|
+
this.pathGeneratorFactoryCache[clipPathShape.nodeName] = this.pathGeneratorFactory(clipPathShape.nodeName);
|
|
6025
|
+
}
|
|
5382
6026
|
|
|
5383
|
-
|
|
5384
|
-
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
5385
|
-
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
6027
|
+
var _generatePath = this.pathGeneratorFactoryCache[clipPathShape.nodeName];
|
|
5386
6028
|
|
|
6029
|
+
if (_generatePath) {
|
|
6030
|
+
this.useAnchor(context, clipPathShape);
|
|
6031
|
+
context.beginPath();
|
|
5387
6032
|
|
|
5388
|
-
|
|
6033
|
+
_generatePath(context, clipPathShape.parsedStyle);
|
|
5389
6034
|
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
};
|
|
6035
|
+
context.closePath();
|
|
6036
|
+
}
|
|
5393
6037
|
|
|
5394
|
-
|
|
5395
|
-
|
|
6038
|
+
context.restore();
|
|
6039
|
+
context.clip();
|
|
6040
|
+
} // fill & stroke
|
|
5396
6041
|
|
|
5397
|
-
var _renderer$getConfig = renderer.getConfig(),
|
|
5398
|
-
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
5399
6042
|
|
|
5400
|
-
|
|
5401
|
-
};
|
|
6043
|
+
context.save(); // apply attributes to context
|
|
5402
6044
|
|
|
5403
|
-
|
|
5404
|
-
var min = aabb.getMin();
|
|
5405
|
-
var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
|
|
5406
|
-
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
5407
|
-
|
|
5408
|
-
var minX = Math.floor(min[0]);
|
|
5409
|
-
var minY = Math.floor(min[1]);
|
|
5410
|
-
var maxX = Math.ceil(max[0]);
|
|
5411
|
-
var maxY = Math.ceil(max[1]);
|
|
5412
|
-
var width = maxX - minX;
|
|
5413
|
-
var height = maxY - minY;
|
|
5414
|
-
return {
|
|
5415
|
-
x: minX,
|
|
5416
|
-
y: minY,
|
|
5417
|
-
width: width,
|
|
5418
|
-
height: height
|
|
5419
|
-
};
|
|
5420
|
-
}
|
|
5421
|
-
/**
|
|
5422
|
-
* TODO: merge dirty rectangles with some strategies.
|
|
5423
|
-
* For now, we just simply merge all the rectangles into one.
|
|
5424
|
-
* @see https://idom.me/articles/841.html
|
|
5425
|
-
*/
|
|
5426
|
-
;
|
|
6045
|
+
this.applyAttributesToContext(context, object); // apply anchor in local space
|
|
5427
6046
|
|
|
5428
|
-
|
|
5429
|
-
// merge into a big AABB
|
|
5430
|
-
var aabb = new g.AABB();
|
|
5431
|
-
dirtyObjects.forEach(function (object) {
|
|
5432
|
-
var renderBounds = object.getRenderBounds();
|
|
5433
|
-
aabb.add(renderBounds);
|
|
5434
|
-
var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
|
|
6047
|
+
this.useAnchor(context, object); // generate path in local space
|
|
5435
6048
|
|
|
5436
|
-
if (
|
|
5437
|
-
|
|
6049
|
+
if (this.pathGeneratorFactoryCache[object.nodeName] === undefined) {
|
|
6050
|
+
this.pathGeneratorFactoryCache[object.nodeName] = this.pathGeneratorFactory(object.nodeName);
|
|
5438
6051
|
}
|
|
5439
|
-
});
|
|
5440
|
-
return aabb;
|
|
5441
|
-
};
|
|
5442
|
-
|
|
5443
|
-
_proto.searchDirtyObjects = function searchDirtyObjects(dirtyRectangle) {
|
|
5444
|
-
var _this2 = this; // search in r-tree, get all affected nodes
|
|
5445
6052
|
|
|
6053
|
+
var generatePath = this.pathGeneratorFactoryCache[object.nodeName];
|
|
5446
6054
|
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
6055
|
+
if (generatePath) {
|
|
6056
|
+
context.beginPath();
|
|
6057
|
+
generatePath(context, object.parsedStyle);
|
|
5450
6058
|
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
6059
|
+
if (object.nodeName !== g.Shape.LINE && object.nodeName !== g.Shape.PATH && object.nodeName !== g.Shape.POLYLINE) {
|
|
6060
|
+
context.closePath();
|
|
6061
|
+
}
|
|
6062
|
+
} // fill & stroke
|
|
5454
6063
|
|
|
5455
|
-
var rBushNodes = this.rBush.search({
|
|
5456
|
-
minX: minX,
|
|
5457
|
-
minY: minY,
|
|
5458
|
-
maxX: maxX,
|
|
5459
|
-
maxY: maxY
|
|
5460
|
-
});
|
|
5461
|
-
return rBushNodes.map(function (_ref3) {
|
|
5462
|
-
var id = _ref3.id;
|
|
5463
|
-
return _this2.displayObjectPool.getByEntity(id);
|
|
5464
|
-
});
|
|
5465
|
-
};
|
|
5466
6064
|
|
|
5467
|
-
|
|
5468
|
-
|
|
6065
|
+
if (styleRenderer) {
|
|
6066
|
+
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
6067
|
+
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
5469
6068
|
|
|
5470
|
-
if (!renderable.dirtyRenderBounds) {
|
|
5471
|
-
renderable.dirtyRenderBounds = new g.AABB();
|
|
5472
|
-
}
|
|
5473
6069
|
|
|
5474
|
-
|
|
6070
|
+
context.restore(); // finish rendering, clear dirty flag
|
|
5475
6071
|
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
6072
|
+
object.renderable.dirty = false;
|
|
6073
|
+
this.restoreStack.push(object);
|
|
5479
6074
|
}
|
|
5480
|
-
}
|
|
6075
|
+
}, {
|
|
6076
|
+
key: "shouldClearFullScreen",
|
|
6077
|
+
value: function shouldClearFullScreen() {
|
|
6078
|
+
var renderer = this.canvasConfig.renderer;
|
|
5481
6079
|
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
tx = _mat4$getTranslation[0],
|
|
5485
|
-
ty = _mat4$getTranslation[1];
|
|
6080
|
+
var _renderer$getConfig = renderer.getConfig(),
|
|
6081
|
+
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
5486
6082
|
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
6083
|
+
return !enableDirtyRectangleRendering || this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
|
|
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
|
|
5490
6091
|
|
|
5491
|
-
|
|
6092
|
+
var minX = Math.floor(min[0]);
|
|
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
|
|
5492
6131
|
|
|
5493
|
-
var _getEuler = g.getEuler(create$2$1(), rotation),
|
|
5494
|
-
eux = _getEuler[0],
|
|
5495
|
-
euy = _getEuler[1],
|
|
5496
|
-
euz = _getEuler[2]; // gimbal lock at 90 degrees
|
|
5497
6132
|
|
|
6133
|
+
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
6134
|
+
_dirtyRectangle$getMi2 = _slicedToArray$3(_dirtyRectangle$getMi, 2),
|
|
6135
|
+
minX = _dirtyRectangle$getMi2[0],
|
|
6136
|
+
minY = _dirtyRectangle$getMi2[1];
|
|
5498
6137
|
|
|
5499
|
-
|
|
6138
|
+
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
6139
|
+
_dirtyRectangle$getMa2 = _slicedToArray$3(_dirtyRectangle$getMa, 2),
|
|
6140
|
+
maxX = _dirtyRectangle$getMa2[0],
|
|
6141
|
+
maxY = _dirtyRectangle$getMa2[1];
|
|
5500
6142
|
|
|
5501
|
-
|
|
5502
|
-
|
|
6143
|
+
var rBushNodes = this.rBush.search({
|
|
6144
|
+
minX: minX,
|
|
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;
|
|
5503
6158
|
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
fill = _object$parsedStyle.fill,
|
|
5508
|
-
opacity = _object$parsedStyle.opacity,
|
|
5509
|
-
lineDash = _object$parsedStyle.lineDash,
|
|
5510
|
-
lineDashOffset = _object$parsedStyle.lineDashOffset,
|
|
5511
|
-
filter = _object$parsedStyle.filter,
|
|
5512
|
-
shadowColor = _object$parsedStyle.shadowColor,
|
|
5513
|
-
shadowBlur = _object$parsedStyle.shadowBlur,
|
|
5514
|
-
shadowOffsetX = _object$parsedStyle.shadowOffsetX,
|
|
5515
|
-
shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
5516
|
-
|
|
5517
|
-
if (lineDash && Array.isArray(lineDash)) {
|
|
5518
|
-
context.setLineDash(lineDash.map(function (segment) {
|
|
5519
|
-
return segment.value;
|
|
5520
|
-
}));
|
|
5521
|
-
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
6159
|
+
if (!renderable.dirtyRenderBounds) {
|
|
6160
|
+
renderable.dirtyRenderBounds = new g.AABB();
|
|
6161
|
+
}
|
|
5522
6162
|
|
|
6163
|
+
var renderBounds = object.getRenderBounds();
|
|
5523
6164
|
|
|
5524
|
-
|
|
5525
|
-
|
|
6165
|
+
if (renderBounds) {
|
|
6166
|
+
// save last dirty aabb
|
|
6167
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
6168
|
+
}
|
|
5526
6169
|
}
|
|
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
|
+
}
|
|
5527
6221
|
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
6222
|
+
if (!g.isNil(opacity)) {
|
|
6223
|
+
context.globalAlpha *= opacity.value;
|
|
6224
|
+
}
|
|
5531
6225
|
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
6226
|
+
if (!g.isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
|
|
6227
|
+
context.strokeStyle = object.attributes.stroke;
|
|
6228
|
+
}
|
|
5535
6229
|
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
6230
|
+
if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
|
|
6231
|
+
context.fillStyle = object.attributes.fill;
|
|
6232
|
+
}
|
|
5539
6233
|
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
6234
|
+
if (!g.isNil(filter)) {
|
|
6235
|
+
// use raw filter string
|
|
6236
|
+
context.filter = object.style.filter;
|
|
6237
|
+
}
|
|
5544
6238
|
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
6239
|
+
if (!g.isNil(shadowColor)) {
|
|
6240
|
+
context.shadowColor = shadowColor.toString();
|
|
6241
|
+
context.shadowBlur = shadowBlur && shadowBlur.value || 0;
|
|
6242
|
+
context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
|
|
6243
|
+
context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
|
|
6244
|
+
}
|
|
5550
6245
|
}
|
|
5551
|
-
}
|
|
6246
|
+
}, {
|
|
6247
|
+
key: "useAnchor",
|
|
6248
|
+
value: function useAnchor(context, object) {
|
|
6249
|
+
var _ref4 = object.parsedStyle || {},
|
|
6250
|
+
anchor = _ref4.anchor;
|
|
5552
6251
|
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
if (!anchor || anchor[0].value === 0 && anchor[1].value === 0) {
|
|
5558
|
-
return;
|
|
5559
|
-
}
|
|
6252
|
+
if (!anchor || anchor[0].value === 0 && anchor[1].value === 0) {
|
|
6253
|
+
return;
|
|
6254
|
+
}
|
|
5560
6255
|
|
|
5561
|
-
|
|
6256
|
+
var contentBounds = object.getGeometryBounds();
|
|
5562
6257
|
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
6258
|
+
if (contentBounds) {
|
|
6259
|
+
var halfExtents = contentBounds.halfExtents; // apply anchor, use true size, not include stroke,
|
|
6260
|
+
// eg. bounds = true size + half lineWidth
|
|
5566
6261
|
|
|
5567
|
-
|
|
6262
|
+
context.translate(-anchor[0].value * halfExtents[0] * 2, -anchor[1].value * halfExtents[1] * 2);
|
|
6263
|
+
}
|
|
5568
6264
|
}
|
|
5569
|
-
}
|
|
6265
|
+
}, {
|
|
6266
|
+
key: "safeMergeAABB",
|
|
6267
|
+
value: function safeMergeAABB() {
|
|
6268
|
+
var merged = new g.AABB();
|
|
5570
6269
|
|
|
5571
|
-
|
|
5572
|
-
|
|
6270
|
+
for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6271
|
+
aabbs[_key] = arguments[_key];
|
|
6272
|
+
}
|
|
5573
6273
|
|
|
5574
|
-
|
|
5575
|
-
|
|
6274
|
+
aabbs.forEach(function (aabb) {
|
|
6275
|
+
merged.add(aabb);
|
|
6276
|
+
});
|
|
6277
|
+
return merged;
|
|
5576
6278
|
}
|
|
5577
|
-
|
|
5578
|
-
aabbs.forEach(function (aabb) {
|
|
5579
|
-
merged.add(aabb);
|
|
5580
|
-
});
|
|
5581
|
-
return merged;
|
|
5582
|
-
};
|
|
6279
|
+
}]);
|
|
5583
6280
|
|
|
5584
6281
|
return CanvasRendererPlugin;
|
|
5585
6282
|
}(), _class$2.tag = 'CanvasRenderer', _class$2);
|
|
@@ -5615,7 +6312,7 @@
|
|
|
5615
6312
|
register(PolylineRenderer);
|
|
5616
6313
|
register(PolygonRenderer);
|
|
5617
6314
|
register(PathRenderer);
|
|
5618
|
-
var shape2Token = (_shape2Token = {}, _shape2Token
|
|
6315
|
+
var shape2Token = (_shape2Token = {}, _defineProperty(_shape2Token, g.Shape.CIRCLE, CircleRendererContribution), _defineProperty(_shape2Token, g.Shape.ELLIPSE, EllipseRendererContribution), _defineProperty(_shape2Token, g.Shape.RECT, RectRendererContribution), _defineProperty(_shape2Token, g.Shape.IMAGE, ImageRendererContribution), _defineProperty(_shape2Token, g.Shape.TEXT, TextRendererContribution), _defineProperty(_shape2Token, g.Shape.LINE, LineRendererContribution), _defineProperty(_shape2Token, g.Shape.POLYLINE, PolylineRendererContribution), _defineProperty(_shape2Token, g.Shape.POLYGON, PolygonRendererContribution), _defineProperty(_shape2Token, g.Shape.PATH, PathRendererContribution), _shape2Token);
|
|
5619
6316
|
register({
|
|
5620
6317
|
token: StyleRendererFactory,
|
|
5621
6318
|
useFactory: function useFactory(ctx) {
|
|
@@ -5635,18 +6332,22 @@
|
|
|
5635
6332
|
|
|
5636
6333
|
var Plugin$3 = /*#__PURE__*/function () {
|
|
5637
6334
|
function Plugin() {
|
|
6335
|
+
_classCallCheck$4(this, Plugin);
|
|
6336
|
+
|
|
5638
6337
|
this.name = 'canvas-renderer';
|
|
5639
6338
|
}
|
|
5640
6339
|
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
container
|
|
5649
|
-
|
|
6340
|
+
_createClass$4(Plugin, [{
|
|
6341
|
+
key: "init",
|
|
6342
|
+
value: function init(container) {
|
|
6343
|
+
container.load(containerModule$3, true);
|
|
6344
|
+
}
|
|
6345
|
+
}, {
|
|
6346
|
+
key: "destroy",
|
|
6347
|
+
value: function destroy(container) {
|
|
6348
|
+
container.unload(containerModule$3);
|
|
6349
|
+
}
|
|
6350
|
+
}]);
|
|
5650
6351
|
|
|
5651
6352
|
return Plugin;
|
|
5652
6353
|
}();
|
|
@@ -5800,7 +6501,7 @@
|
|
|
5800
6501
|
if ("throw" !== record.type) {
|
|
5801
6502
|
var result = record.arg,
|
|
5802
6503
|
value = result.value;
|
|
5803
|
-
return value && "object" ==
|
|
6504
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
5804
6505
|
invoke("next", value, resolve, reject);
|
|
5805
6506
|
}, function (err) {
|
|
5806
6507
|
invoke("throw", err, resolve, reject);
|
|
@@ -6061,6 +6762,31 @@
|
|
|
6061
6762
|
};
|
|
6062
6763
|
}
|
|
6063
6764
|
|
|
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
|
+
|
|
6064
6790
|
var _class$3;
|
|
6065
6791
|
|
|
6066
6792
|
var DOMInteractionPlugin_1;
|
|
@@ -6070,147 +6796,150 @@
|
|
|
6070
6796
|
|
|
6071
6797
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class$3 = /*#__PURE__*/function () {
|
|
6072
6798
|
function DOMInteractionPlugin() {
|
|
6799
|
+
_classCallCheck$5(this, DOMInteractionPlugin);
|
|
6800
|
+
|
|
6073
6801
|
this.contextService = void 0;
|
|
6074
6802
|
this.renderingContext = void 0;
|
|
6075
6803
|
}
|
|
6076
6804
|
|
|
6077
|
-
|
|
6805
|
+
_createClass$5(DOMInteractionPlugin, [{
|
|
6806
|
+
key: "apply",
|
|
6807
|
+
value: function apply(renderingService) {
|
|
6808
|
+
var _this = this;
|
|
6078
6809
|
|
|
6079
|
-
|
|
6080
|
-
var _this = this;
|
|
6810
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
6081
6811
|
|
|
6082
|
-
|
|
6812
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
6813
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
6814
|
+
};
|
|
6083
6815
|
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6816
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
6817
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
6818
|
+
};
|
|
6087
6819
|
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6820
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
6821
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
6822
|
+
};
|
|
6091
6823
|
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6824
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
6825
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
6826
|
+
};
|
|
6095
6827
|
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6828
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
6829
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
6830
|
+
};
|
|
6099
6831
|
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6832
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
6833
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
6834
|
+
};
|
|
6103
6835
|
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6836
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
6837
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
6838
|
+
};
|
|
6107
6839
|
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6840
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
6841
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
6842
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
6843
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
6844
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
6845
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
6846
|
+
};
|
|
6111
6847
|
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
};
|
|
6848
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
6849
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
6850
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
6851
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
6852
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
6853
|
+
};
|
|
6119
6854
|
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6855
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
6856
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
6857
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
6858
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
6859
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
6860
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
6861
|
+
};
|
|
6126
6862
|
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6863
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
6864
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
6865
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
6866
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
6867
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
6868
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
6869
|
+
};
|
|
6134
6870
|
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
6141
|
-
};
|
|
6871
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
6872
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
6873
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
6874
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
6875
|
+
};
|
|
6142
6876
|
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6877
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
6878
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
6879
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
6880
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
6881
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
6882
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
6883
|
+
};
|
|
6148
6884
|
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6885
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
|
|
6886
|
+
var $el;
|
|
6887
|
+
return _regeneratorRuntime$4().wrap(function _callee$(_context) {
|
|
6888
|
+
while (1) {
|
|
6889
|
+
switch (_context.prev = _context.next) {
|
|
6890
|
+
case 0:
|
|
6891
|
+
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
6156
6892
|
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
while (1) {
|
|
6161
|
-
switch (_context.prev = _context.next) {
|
|
6162
|
-
case 0:
|
|
6163
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
6164
|
-
|
|
6165
|
-
if (globalThis.navigator.msPointerEnabled) {
|
|
6166
|
-
// @ts-ignore
|
|
6167
|
-
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
6168
|
-
|
|
6169
|
-
$el.style.msTouchAction = 'none';
|
|
6170
|
-
} else if (canvas.supportsPointerEvents) {
|
|
6171
|
-
$el.style.touchAction = 'none';
|
|
6172
|
-
}
|
|
6893
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
6894
|
+
// @ts-ignore
|
|
6895
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
6173
6896
|
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6897
|
+
$el.style.msTouchAction = 'none';
|
|
6898
|
+
} else if (canvas.supportsPointerEvents) {
|
|
6899
|
+
$el.style.touchAction = 'none';
|
|
6900
|
+
}
|
|
6901
|
+
|
|
6902
|
+
if (canvas.supportsPointerEvents) {
|
|
6903
|
+
addPointerEventListener($el);
|
|
6904
|
+
} else {
|
|
6905
|
+
addMouseEventListener($el);
|
|
6906
|
+
}
|
|
6179
6907
|
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6908
|
+
if (canvas.supportsTouchEvents) {
|
|
6909
|
+
addTouchEventListener($el);
|
|
6910
|
+
} // use passive event listeners
|
|
6911
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
6184
6912
|
|
|
6185
6913
|
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6914
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
6915
|
+
passive: true,
|
|
6916
|
+
capture: true
|
|
6917
|
+
});
|
|
6190
6918
|
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6919
|
+
case 5:
|
|
6920
|
+
case "end":
|
|
6921
|
+
return _context.stop();
|
|
6922
|
+
}
|
|
6194
6923
|
}
|
|
6195
|
-
}
|
|
6196
|
-
}
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
var $el = _this.contextService.getDomElement();
|
|
6924
|
+
}, _callee);
|
|
6925
|
+
})));
|
|
6926
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
6927
|
+
var $el = _this.contextService.getDomElement();
|
|
6200
6928
|
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6929
|
+
if (canvas.supportsPointerEvents) {
|
|
6930
|
+
removePointerEventListener($el);
|
|
6931
|
+
} else {
|
|
6932
|
+
removeMouseEventListener($el);
|
|
6933
|
+
}
|
|
6206
6934
|
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6935
|
+
if (canvas.supportsTouchEvents) {
|
|
6936
|
+
removeTouchEventListener($el);
|
|
6937
|
+
}
|
|
6210
6938
|
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6939
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
6940
|
+
});
|
|
6941
|
+
}
|
|
6942
|
+
}]);
|
|
6214
6943
|
|
|
6215
6944
|
return DOMInteractionPlugin;
|
|
6216
6945
|
}(), _class$3.tag = 'DOMInteraction', _class$3);
|
|
@@ -6228,18 +6957,22 @@
|
|
|
6228
6957
|
|
|
6229
6958
|
var Plugin$4 = /*#__PURE__*/function () {
|
|
6230
6959
|
function Plugin() {
|
|
6960
|
+
_classCallCheck$5(this, Plugin);
|
|
6961
|
+
|
|
6231
6962
|
this.name = 'dom-interaction';
|
|
6232
6963
|
}
|
|
6233
6964
|
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
container
|
|
6242
|
-
|
|
6965
|
+
_createClass$5(Plugin, [{
|
|
6966
|
+
key: "init",
|
|
6967
|
+
value: function init(container) {
|
|
6968
|
+
container.load(containerModule$4, true);
|
|
6969
|
+
}
|
|
6970
|
+
}, {
|
|
6971
|
+
key: "destroy",
|
|
6972
|
+
value: function destroy(container) {
|
|
6973
|
+
container.unload(containerModule$4);
|
|
6974
|
+
}
|
|
6975
|
+
}]);
|
|
6243
6976
|
|
|
6244
6977
|
return Plugin;
|
|
6245
6978
|
}();
|
|
@@ -6374,7 +7107,7 @@
|
|
|
6374
7107
|
if ("throw" !== record.type) {
|
|
6375
7108
|
var result = record.arg,
|
|
6376
7109
|
value = result.value;
|
|
6377
|
-
return value && "object" ==
|
|
7110
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
6378
7111
|
invoke("next", value, resolve, reject);
|
|
6379
7112
|
}, function (err) {
|
|
6380
7113
|
invoke("throw", err, resolve, reject);
|
|
@@ -6635,240 +7368,271 @@
|
|
|
6635
7368
|
};
|
|
6636
7369
|
}
|
|
6637
7370
|
|
|
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
|
+
|
|
6638
7396
|
var _class$4;
|
|
6639
7397
|
|
|
6640
7398
|
var HTMLRenderingPlugin_1;
|
|
6641
7399
|
var HTML_PREFIX = 'g-html-';
|
|
6642
7400
|
var HTMLRenderingPlugin = HTMLRenderingPlugin_1 = (_class$4 = /*#__PURE__*/function () {
|
|
6643
7401
|
function HTMLRenderingPlugin() {
|
|
7402
|
+
_classCallCheck$6(this, HTMLRenderingPlugin);
|
|
7403
|
+
|
|
6644
7404
|
this.contextService = void 0;
|
|
6645
7405
|
this.renderingContext = void 0;
|
|
6646
7406
|
this.canvasConfig = void 0;
|
|
6647
7407
|
this.$camera = void 0;
|
|
6648
7408
|
}
|
|
6649
7409
|
|
|
6650
|
-
|
|
7410
|
+
_createClass$6(HTMLRenderingPlugin, [{
|
|
7411
|
+
key: "apply",
|
|
7412
|
+
value: function apply(renderingService) {
|
|
7413
|
+
var _this = this;
|
|
6651
7414
|
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
var handleMounted = function handleMounted(e) {
|
|
6656
|
-
var object = e.target;
|
|
7415
|
+
var handleMounted = function handleMounted(e) {
|
|
7416
|
+
var object = e.target;
|
|
6657
7417
|
|
|
6658
|
-
|
|
6659
|
-
|
|
7418
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7419
|
+
var $el = _this.getOrCreateEl(object); // apply documentElement's style
|
|
6660
7420
|
|
|
6661
7421
|
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
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
|
+
};
|
|
6671
7431
|
|
|
6672
|
-
|
|
6673
|
-
|
|
7432
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
7433
|
+
var object = e.target;
|
|
6674
7434
|
|
|
6675
|
-
|
|
6676
|
-
|
|
7435
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7436
|
+
var existedId = _this.getId(object);
|
|
6677
7437
|
|
|
6678
|
-
|
|
7438
|
+
var $container = _this.contextService.getDomElement().parentNode;
|
|
6679
7439
|
|
|
6680
|
-
|
|
6681
|
-
|
|
7440
|
+
if ($container) {
|
|
7441
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
6682
7442
|
|
|
6683
|
-
|
|
6684
|
-
|
|
7443
|
+
if ($existedElement) {
|
|
7444
|
+
$container.removeChild($existedElement);
|
|
7445
|
+
}
|
|
6685
7446
|
}
|
|
6686
7447
|
}
|
|
6687
|
-
}
|
|
6688
|
-
};
|
|
7448
|
+
};
|
|
6689
7449
|
|
|
6690
|
-
|
|
6691
|
-
|
|
7450
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
7451
|
+
var object = e.target;
|
|
6692
7452
|
|
|
6693
|
-
|
|
6694
|
-
|
|
7453
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7454
|
+
var attrName = e.attrName;
|
|
6695
7455
|
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
7456
|
+
_this.updateAttribute(attrName, object);
|
|
7457
|
+
}
|
|
7458
|
+
};
|
|
6699
7459
|
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
7460
|
+
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee() {
|
|
7461
|
+
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
7462
|
+
while (1) {
|
|
7463
|
+
switch (_context.prev = _context.next) {
|
|
7464
|
+
case 0:
|
|
7465
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
6706
7466
|
|
|
6707
|
-
|
|
7467
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
6708
7468
|
|
|
6709
|
-
|
|
7469
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6710
7470
|
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
7471
|
+
case 3:
|
|
7472
|
+
case "end":
|
|
7473
|
+
return _context.stop();
|
|
7474
|
+
}
|
|
6714
7475
|
}
|
|
6715
|
-
}
|
|
6716
|
-
}
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
7476
|
+
}, _callee);
|
|
7477
|
+
})));
|
|
7478
|
+
renderingService.hooks.destroy.tap(HTMLRenderingPlugin_1.tag, function () {
|
|
7479
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
6720
7480
|
|
|
6721
|
-
|
|
7481
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
6722
7482
|
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
7483
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
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;
|
|
6726
7497
|
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
};
|
|
7498
|
+
if ($container) {
|
|
7499
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
6730
7500
|
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
7501
|
+
if (!$existedElement) {
|
|
7502
|
+
$existedElement = (doc || document).createElement('div');
|
|
7503
|
+
object.parsedStyle.$el = $existedElement;
|
|
7504
|
+
$existedElement.id = existedId;
|
|
6735
7505
|
|
|
6736
|
-
|
|
6737
|
-
|
|
7506
|
+
if (object.name) {
|
|
7507
|
+
$existedElement.setAttribute('name', object.name);
|
|
7508
|
+
}
|
|
6738
7509
|
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
$existedElement.id = existedId;
|
|
7510
|
+
if (object.className) {
|
|
7511
|
+
$existedElement.className = object.className;
|
|
7512
|
+
}
|
|
6743
7513
|
|
|
6744
|
-
|
|
6745
|
-
$existedElement.setAttribute('name', object.name);
|
|
6746
|
-
}
|
|
7514
|
+
$container.appendChild($existedElement); // use absolute position
|
|
6747
7515
|
|
|
6748
|
-
|
|
6749
|
-
$existedElement.
|
|
7516
|
+
$existedElement.style.position = 'absolute';
|
|
7517
|
+
$existedElement.style.left = '0';
|
|
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(','), ")");
|
|
6750
7522
|
}
|
|
6751
7523
|
|
|
6752
|
-
$
|
|
6753
|
-
|
|
6754
|
-
$existedElement.style.position = 'absolute';
|
|
6755
|
-
$existedElement.style.left = '0';
|
|
6756
|
-
$existedElement.style.top = '0';
|
|
6757
|
-
$existedElement.style['will-change'] = 'transform';
|
|
6758
|
-
var worldTransform = object.getWorldTransform();
|
|
6759
|
-
$existedElement.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
7524
|
+
return $existedElement;
|
|
6760
7525
|
}
|
|
6761
7526
|
|
|
6762
|
-
return
|
|
7527
|
+
return null;
|
|
6763
7528
|
}
|
|
7529
|
+
}, {
|
|
7530
|
+
key: "updateAttribute",
|
|
7531
|
+
value: function updateAttribute(name, object) {
|
|
7532
|
+
var $el = this.getOrCreateEl(object);
|
|
6764
7533
|
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
_proto.updateAttribute = function updateAttribute(name, object) {
|
|
6769
|
-
var $el = this.getOrCreateEl(object);
|
|
6770
|
-
|
|
6771
|
-
switch (name) {
|
|
6772
|
-
case 'innerHTML':
|
|
6773
|
-
var innerHTML = object.parsedStyle.innerHTML;
|
|
7534
|
+
switch (name) {
|
|
7535
|
+
case 'innerHTML':
|
|
7536
|
+
var innerHTML = object.parsedStyle.innerHTML;
|
|
6774
7537
|
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
7538
|
+
if (g.isString(innerHTML)) {
|
|
7539
|
+
$el.innerHTML = innerHTML;
|
|
7540
|
+
} else {
|
|
7541
|
+
$el.innerHTML = '';
|
|
7542
|
+
$el.appendChild(innerHTML);
|
|
7543
|
+
}
|
|
6781
7544
|
|
|
6782
|
-
|
|
7545
|
+
break;
|
|
6783
7546
|
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
7547
|
+
case 'modelMatrix':
|
|
7548
|
+
case 'transformOrigin':
|
|
7549
|
+
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
7550
|
+
$el.style['transform-origin'] = "".concat(transformOrigin[0].value, " ").concat(transformOrigin[1].value);
|
|
7551
|
+
var worldTransform = object.getWorldTransform();
|
|
7552
|
+
$el.style.transform = "matrix(".concat([worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(','), ")");
|
|
7553
|
+
break;
|
|
6791
7554
|
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
7555
|
+
case 'width':
|
|
7556
|
+
var width = object.computedStyleMap().get('width');
|
|
7557
|
+
$el.style.width = width.toString();
|
|
7558
|
+
break;
|
|
6796
7559
|
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
7560
|
+
case 'height':
|
|
7561
|
+
var height = object.computedStyleMap().get('height');
|
|
7562
|
+
$el.style.height = height.toString();
|
|
7563
|
+
break;
|
|
6801
7564
|
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
7565
|
+
case 'zIndex':
|
|
7566
|
+
var zIndex = object.parsedStyle.zIndex;
|
|
7567
|
+
$el.style['z-index'] = "".concat(zIndex.value);
|
|
7568
|
+
break;
|
|
6806
7569
|
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
7570
|
+
case 'visibility':
|
|
7571
|
+
var visibility = object.parsedStyle.visibility;
|
|
7572
|
+
$el.style.visibility = visibility.value;
|
|
7573
|
+
break;
|
|
6811
7574
|
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
7575
|
+
case 'pointerEvents':
|
|
7576
|
+
var pointerEvents = object.parsedStyle.pointerEvents;
|
|
7577
|
+
$el.style.pointerEvents = pointerEvents.value;
|
|
7578
|
+
break;
|
|
6816
7579
|
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
7580
|
+
case 'opacity':
|
|
7581
|
+
var opacity = object.parsedStyle.opacity;
|
|
7582
|
+
$el.style.opacity = "".concat(opacity.value);
|
|
7583
|
+
break;
|
|
6821
7584
|
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
7585
|
+
case 'fill':
|
|
7586
|
+
var fill = object.parsedStyle.fill;
|
|
7587
|
+
var color = '';
|
|
6825
7588
|
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
7589
|
+
if (fill instanceof g.CSSRGB) {
|
|
7590
|
+
if (fill.isNone) {
|
|
7591
|
+
color = 'transparent';
|
|
7592
|
+
} else {
|
|
7593
|
+
color = object.getAttribute('fill');
|
|
7594
|
+
}
|
|
7595
|
+
} else if (Array.isArray(fill)) {
|
|
6830
7596
|
color = object.getAttribute('fill');
|
|
6831
|
-
}
|
|
6832
|
-
} else if (Array.isArray(fill)) {
|
|
6833
|
-
color = object.getAttribute('fill');
|
|
6834
|
-
} else if (g.isPattern(fill)) ;
|
|
7597
|
+
} else if (g.isPattern(fill)) ;
|
|
6835
7598
|
|
|
6836
|
-
|
|
6837
|
-
|
|
7599
|
+
$el.style.background = color;
|
|
7600
|
+
break;
|
|
6838
7601
|
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
7602
|
+
case 'stroke':
|
|
7603
|
+
var stroke = object.parsedStyle.stroke;
|
|
7604
|
+
var borderColor = '';
|
|
6842
7605
|
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
7606
|
+
if (stroke instanceof g.CSSRGB) {
|
|
7607
|
+
if (stroke.isNone) {
|
|
7608
|
+
borderColor = 'transparent';
|
|
7609
|
+
} else {
|
|
7610
|
+
borderColor = object.getAttribute('stroke');
|
|
7611
|
+
}
|
|
7612
|
+
} else if (Array.isArray(stroke)) {
|
|
6847
7613
|
borderColor = object.getAttribute('stroke');
|
|
6848
|
-
}
|
|
6849
|
-
} else if (Array.isArray(stroke)) {
|
|
6850
|
-
borderColor = object.getAttribute('stroke');
|
|
6851
|
-
} else if (g.isPattern(stroke)) ;
|
|
7614
|
+
} else if (g.isPattern(stroke)) ;
|
|
6852
7615
|
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
7616
|
+
$el.style['border-color'] = borderColor;
|
|
7617
|
+
$el.style['border-style'] = 'solid';
|
|
7618
|
+
break;
|
|
6856
7619
|
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
7620
|
+
case 'lineWidth':
|
|
7621
|
+
var lineWidth = object.parsedStyle.lineWidth;
|
|
7622
|
+
$el.style['border-width'] = "".concat(lineWidth.value || 0, "px");
|
|
7623
|
+
break;
|
|
6861
7624
|
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
7625
|
+
case 'lineDash':
|
|
7626
|
+
$el.style['border-style'] = 'dashed';
|
|
7627
|
+
break;
|
|
6865
7628
|
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
7629
|
+
case 'filter':
|
|
7630
|
+
var filter = object.parsedStyle.filter;
|
|
7631
|
+
$el.style.filter = filter;
|
|
7632
|
+
break;
|
|
7633
|
+
}
|
|
6870
7634
|
}
|
|
6871
|
-
};
|
|
7635
|
+
}]);
|
|
6872
7636
|
|
|
6873
7637
|
return HTMLRenderingPlugin;
|
|
6874
7638
|
}(), _class$4.tag = 'HTMLRendering', _class$4);
|
|
@@ -6888,18 +7652,22 @@
|
|
|
6888
7652
|
|
|
6889
7653
|
var Plugin$5 = /*#__PURE__*/function () {
|
|
6890
7654
|
function Plugin() {
|
|
7655
|
+
_classCallCheck$6(this, Plugin);
|
|
7656
|
+
|
|
6891
7657
|
this.name = 'html-renderer';
|
|
6892
7658
|
}
|
|
6893
7659
|
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
container
|
|
6902
|
-
|
|
7660
|
+
_createClass$6(Plugin, [{
|
|
7661
|
+
key: "init",
|
|
7662
|
+
value: function init(container) {
|
|
7663
|
+
container.load(containerModule$5, true);
|
|
7664
|
+
}
|
|
7665
|
+
}, {
|
|
7666
|
+
key: "destroy",
|
|
7667
|
+
value: function destroy(container) {
|
|
7668
|
+
container.unload(containerModule$5);
|
|
7669
|
+
}
|
|
7670
|
+
}]);
|
|
6903
7671
|
|
|
6904
7672
|
return Plugin;
|
|
6905
7673
|
}();
|
|
@@ -6911,6 +7679,8 @@
|
|
|
6911
7679
|
|
|
6912
7680
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
6913
7681
|
function Canvas2DContextService() {
|
|
7682
|
+
_classCallCheck(this, Canvas2DContextService);
|
|
7683
|
+
|
|
6914
7684
|
this.$container = void 0;
|
|
6915
7685
|
this.$canvas = void 0;
|
|
6916
7686
|
this.dpr = void 0;
|
|
@@ -6918,112 +7688,120 @@
|
|
|
6918
7688
|
this.canvasConfig = void 0;
|
|
6919
7689
|
}
|
|
6920
7690
|
|
|
6921
|
-
|
|
7691
|
+
_createClass(Canvas2DContextService, [{
|
|
7692
|
+
key: "init",
|
|
7693
|
+
value: function () {
|
|
7694
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
7695
|
+
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
6922
7696
|
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
7697
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7698
|
+
while (1) {
|
|
7699
|
+
switch (_context.prev = _context.next) {
|
|
7700
|
+
case 0:
|
|
7701
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
6926
7702
|
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
switch (_context.prev = _context.next) {
|
|
6930
|
-
case 0:
|
|
6931
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
7703
|
+
if (canvas) {
|
|
7704
|
+
this.$canvas = canvas;
|
|
6932
7705
|
|
|
6933
|
-
|
|
6934
|
-
|
|
7706
|
+
if (container && canvas.parentElement !== container) {
|
|
7707
|
+
container.appendChild(canvas);
|
|
7708
|
+
}
|
|
6935
7709
|
|
|
6936
|
-
|
|
6937
|
-
container
|
|
6938
|
-
}
|
|
7710
|
+
this.$container = canvas.parentElement;
|
|
7711
|
+
this.canvasConfig.container = this.$container;
|
|
7712
|
+
} else if (container) {
|
|
7713
|
+
// create container
|
|
7714
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
6939
7715
|
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
7716
|
+
if (this.$container) {
|
|
7717
|
+
// create canvas
|
|
7718
|
+
$canvas = document.createElement('canvas');
|
|
7719
|
+
this.$container.appendChild($canvas);
|
|
6945
7720
|
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
this.$container.appendChild($canvas);
|
|
7721
|
+
if (!this.$container.style.position) {
|
|
7722
|
+
this.$container.style.position = 'relative';
|
|
7723
|
+
}
|
|
6950
7724
|
|
|
6951
|
-
|
|
6952
|
-
this.$container.style.position = 'relative';
|
|
7725
|
+
this.$canvas = $canvas;
|
|
6953
7726
|
}
|
|
6954
|
-
|
|
6955
|
-
this.$canvas = $canvas;
|
|
6956
7727
|
}
|
|
6957
|
-
}
|
|
6958
7728
|
|
|
6959
|
-
|
|
7729
|
+
this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
|
|
6960
7730
|
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
7731
|
+
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
7732
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
7733
|
+
this.dpr = dpr;
|
|
7734
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
6965
7735
|
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
7736
|
+
case 7:
|
|
7737
|
+
case "end":
|
|
7738
|
+
return _context.stop();
|
|
7739
|
+
}
|
|
6969
7740
|
}
|
|
6970
|
-
}
|
|
6971
|
-
}
|
|
6972
|
-
}));
|
|
6973
|
-
|
|
6974
|
-
function init() {
|
|
6975
|
-
return _init.apply(this, arguments);
|
|
6976
|
-
}
|
|
6977
|
-
|
|
6978
|
-
return init;
|
|
6979
|
-
}();
|
|
6980
|
-
|
|
6981
|
-
_proto.getContext = function getContext() {
|
|
6982
|
-
return this.context;
|
|
6983
|
-
};
|
|
6984
|
-
|
|
6985
|
-
_proto.getDomElement = function getDomElement() {
|
|
6986
|
-
return this.$canvas;
|
|
6987
|
-
};
|
|
7741
|
+
}, _callee, this);
|
|
7742
|
+
}));
|
|
6988
7743
|
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
7744
|
+
function init() {
|
|
7745
|
+
return _init.apply(this, arguments);
|
|
7746
|
+
}
|
|
6992
7747
|
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
7748
|
+
return init;
|
|
7749
|
+
}()
|
|
7750
|
+
}, {
|
|
7751
|
+
key: "getContext",
|
|
7752
|
+
value: function getContext() {
|
|
7753
|
+
return this.context;
|
|
7754
|
+
}
|
|
7755
|
+
}, {
|
|
7756
|
+
key: "getDomElement",
|
|
7757
|
+
value: function getDomElement() {
|
|
7758
|
+
return this.$canvas;
|
|
7759
|
+
}
|
|
7760
|
+
}, {
|
|
7761
|
+
key: "getDPR",
|
|
7762
|
+
value: function getDPR() {
|
|
7763
|
+
return this.dpr;
|
|
7764
|
+
}
|
|
7765
|
+
}, {
|
|
7766
|
+
key: "getBoundingClientRect",
|
|
7767
|
+
value: function getBoundingClientRect() {
|
|
7768
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
7769
|
+
return this.$canvas.getBoundingClientRect();
|
|
7770
|
+
}
|
|
6996
7771
|
}
|
|
6997
|
-
}
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
// @ts-ignore
|
|
7001
|
-
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
7002
|
-
// destroy context
|
|
7772
|
+
}, {
|
|
7773
|
+
key: "destroy",
|
|
7774
|
+
value: function destroy() {
|
|
7003
7775
|
// @ts-ignore
|
|
7004
|
-
this.$container
|
|
7776
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
7777
|
+
// destroy context
|
|
7778
|
+
// @ts-ignore
|
|
7779
|
+
this.$container.removeChild(this.$canvas);
|
|
7780
|
+
}
|
|
7005
7781
|
}
|
|
7006
|
-
}
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
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
|
|
7013
7789
|
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7790
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
7791
|
+
var dpr = this.getDPR(); // scale all drawing operations by the dpr
|
|
7792
|
+
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
7017
7793
|
|
|
7018
|
-
|
|
7794
|
+
this.context.scale(dpr, dpr);
|
|
7795
|
+
}
|
|
7019
7796
|
}
|
|
7020
|
-
}
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7797
|
+
}, {
|
|
7798
|
+
key: "applyCursorStyle",
|
|
7799
|
+
value: function applyCursorStyle(cursor) {
|
|
7800
|
+
if (this.$container && this.$container.style) {
|
|
7801
|
+
this.$container.style.cursor = cursor;
|
|
7802
|
+
}
|
|
7025
7803
|
}
|
|
7026
|
-
};
|
|
7804
|
+
}]);
|
|
7027
7805
|
|
|
7028
7806
|
return Canvas2DContextService;
|
|
7029
7807
|
}();
|
|
@@ -7042,29 +7820,37 @@
|
|
|
7042
7820
|
});
|
|
7043
7821
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
7044
7822
|
function ContextRegisterPlugin() {
|
|
7823
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
7824
|
+
|
|
7045
7825
|
this.name = 'canvas-context-register';
|
|
7046
7826
|
}
|
|
7047
7827
|
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
container
|
|
7056
|
-
|
|
7828
|
+
_createClass(ContextRegisterPlugin, [{
|
|
7829
|
+
key: "init",
|
|
7830
|
+
value: function init(container) {
|
|
7831
|
+
container.load(containerModule$6, true);
|
|
7832
|
+
}
|
|
7833
|
+
}, {
|
|
7834
|
+
key: "destroy",
|
|
7835
|
+
value: function destroy(container) {
|
|
7836
|
+
container.unload(containerModule$6);
|
|
7837
|
+
}
|
|
7838
|
+
}]);
|
|
7057
7839
|
|
|
7058
7840
|
return ContextRegisterPlugin;
|
|
7059
7841
|
}();
|
|
7060
7842
|
|
|
7061
7843
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
7062
|
-
|
|
7844
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
7845
|
+
|
|
7846
|
+
var _super = _createSuper(Renderer);
|
|
7063
7847
|
|
|
7064
7848
|
function Renderer(config) {
|
|
7065
7849
|
var _this;
|
|
7066
7850
|
|
|
7067
|
-
|
|
7851
|
+
_classCallCheck(this, Renderer);
|
|
7852
|
+
|
|
7853
|
+
_this = _super.call(this, config); // register Canvas2DContext
|
|
7068
7854
|
|
|
7069
7855
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
7070
7856
|
|
|
@@ -7086,7 +7872,7 @@
|
|
|
7086
7872
|
return _this;
|
|
7087
7873
|
}
|
|
7088
7874
|
|
|
7089
|
-
return Renderer;
|
|
7875
|
+
return _createClass(Renderer);
|
|
7090
7876
|
}(g.AbstractRenderer);
|
|
7091
7877
|
|
|
7092
7878
|
exports.CanvasPathGenerator = index_esm;
|