@antv/g-canvas 1.1.8-alpha.2 → 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.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +226 -104
- package/dist/index.js +247 -104
- package/dist/index.umd.js +2327 -1457
- 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
|
});
|
|
@@ -528,39 +734,45 @@
|
|
|
528
734
|
});
|
|
529
735
|
|
|
530
736
|
if (!hasRadius) {
|
|
737
|
+
// Canvas support negative width/height of rect
|
|
531
738
|
context.rect(0, 0, w, h);
|
|
532
739
|
} else {
|
|
740
|
+
var signX = width.value > 0 ? 1 : -1;
|
|
741
|
+
var signY = height.value > 0 ? 1 : -1;
|
|
742
|
+
var sweepFlag = signX + signY === 0;
|
|
743
|
+
|
|
533
744
|
var _radius$map = radius.map(function (r) {
|
|
534
|
-
return r.value;
|
|
745
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
|
|
535
746
|
}),
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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];
|
|
540
752
|
|
|
541
|
-
context.moveTo(
|
|
542
|
-
context.lineTo(w -
|
|
753
|
+
context.moveTo(signX * tlr, 0);
|
|
754
|
+
context.lineTo(w - signX * trr, 0);
|
|
543
755
|
|
|
544
|
-
if (
|
|
545
|
-
context.arc(w -
|
|
756
|
+
if (trr !== 0) {
|
|
757
|
+
context.arc(w - signX * trr, signY * trr, trr, -signY * Math.PI / 2, signX > 0 ? 0 : Math.PI, sweepFlag);
|
|
546
758
|
}
|
|
547
759
|
|
|
548
|
-
context.lineTo(w, h -
|
|
760
|
+
context.lineTo(w, h - signY * brr);
|
|
549
761
|
|
|
550
|
-
if (
|
|
551
|
-
context.arc(w -
|
|
762
|
+
if (brr !== 0) {
|
|
763
|
+
context.arc(w - signX * brr, h - signY * brr, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag);
|
|
552
764
|
}
|
|
553
765
|
|
|
554
|
-
context.lineTo(
|
|
766
|
+
context.lineTo(signX * blr, h);
|
|
555
767
|
|
|
556
|
-
if (
|
|
557
|
-
context.arc(
|
|
768
|
+
if (blr !== 0) {
|
|
769
|
+
context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag);
|
|
558
770
|
}
|
|
559
771
|
|
|
560
|
-
context.lineTo(0,
|
|
772
|
+
context.lineTo(0, signY * tlr);
|
|
561
773
|
|
|
562
|
-
if (
|
|
563
|
-
context.arc(
|
|
774
|
+
if (tlr !== 0) {
|
|
775
|
+
context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag);
|
|
564
776
|
}
|
|
565
777
|
}
|
|
566
778
|
}
|
|
@@ -634,22 +846,33 @@
|
|
|
634
846
|
|
|
635
847
|
var Plugin = /*#__PURE__*/function () {
|
|
636
848
|
function Plugin() {
|
|
849
|
+
_classCallCheck$1(this, Plugin);
|
|
850
|
+
|
|
637
851
|
this.name = 'canvas-path-generator';
|
|
638
852
|
}
|
|
639
853
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
container
|
|
648
|
-
|
|
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
|
+
}]);
|
|
649
865
|
|
|
650
866
|
return Plugin;
|
|
651
867
|
}();
|
|
652
868
|
|
|
869
|
+
var index_esm = /*#__PURE__*/Object.freeze({
|
|
870
|
+
__proto__: null,
|
|
871
|
+
PathGenerator: PathGenerator,
|
|
872
|
+
PathGeneratorFactory: PathGeneratorFactory,
|
|
873
|
+
Plugin: Plugin
|
|
874
|
+
});
|
|
875
|
+
|
|
653
876
|
/******************************************************************************
|
|
654
877
|
Copyright (c) Microsoft Corporation.
|
|
655
878
|
|
|
@@ -801,7 +1024,7 @@
|
|
|
801
1024
|
if ("throw" !== record.type) {
|
|
802
1025
|
var result = record.arg,
|
|
803
1026
|
value = result.value;
|
|
804
|
-
return value && "object" ==
|
|
1027
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
805
1028
|
invoke("next", value, resolve, reject);
|
|
806
1029
|
}, function (err) {
|
|
807
1030
|
invoke("throw", err, resolve, reject);
|
|
@@ -1061,6 +1284,92 @@
|
|
|
1061
1284
|
});
|
|
1062
1285
|
};
|
|
1063
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
|
+
}
|
|
1064
1373
|
/**
|
|
1065
1374
|
* Common utilities
|
|
1066
1375
|
* @module glMatrix
|
|
@@ -1655,6 +1964,8 @@
|
|
|
1655
1964
|
function CanvasPickerPlugin() {
|
|
1656
1965
|
var _this = this;
|
|
1657
1966
|
|
|
1967
|
+
_classCallCheck$2(this, CanvasPickerPlugin);
|
|
1968
|
+
|
|
1658
1969
|
this.displayObjectPool = void 0;
|
|
1659
1970
|
this.canvasConfig = void 0;
|
|
1660
1971
|
this.offscreenCanvas = void 0;
|
|
@@ -1705,108 +2016,109 @@
|
|
|
1705
2016
|
};
|
|
1706
2017
|
}
|
|
1707
2018
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
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);
|
|
1744
2058
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
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;
|
|
1747
2071
|
}
|
|
1748
|
-
}); // find group with max z-index
|
|
1749
|
-
|
|
1750
|
-
hitTestList.sort(function (a, b) {
|
|
1751
|
-
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
1752
|
-
});
|
|
1753
|
-
pickedDisplayObjects = [];
|
|
1754
|
-
_i = 0, _hitTestList = hitTestList;
|
|
1755
|
-
|
|
1756
|
-
case 9:
|
|
1757
|
-
if (!(_i < _hitTestList.length)) {
|
|
1758
|
-
_context.next = 25;
|
|
1759
|
-
break;
|
|
1760
|
-
}
|
|
1761
2072
|
|
|
1762
|
-
|
|
2073
|
+
displayObject = _hitTestList[_i]; // test with clip path
|
|
1763
2074
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
2075
|
+
clipPath = displayObject.parsedStyle.clipPath;
|
|
2076
|
+
objectToTest = clipPath || displayObject;
|
|
2077
|
+
worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
|
|
1767
2078
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
2079
|
+
if (clipPath) {
|
|
2080
|
+
worldTransform = multiply$1(create$1(), worldTransform, clipPath.getLocalTransform());
|
|
2081
|
+
}
|
|
1771
2082
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
2083
|
+
if (!_this2.isHit(objectToTest, position, worldTransform)) {
|
|
2084
|
+
_context.next = 22;
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
1776
2087
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
2088
|
+
if (!topmost) {
|
|
2089
|
+
_context.next = 21;
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
1781
2092
|
|
|
1782
|
-
|
|
1783
|
-
|
|
2093
|
+
result.picked = [displayObject];
|
|
2094
|
+
return _context.abrupt("return", result);
|
|
1784
2095
|
|
|
1785
|
-
|
|
1786
|
-
|
|
2096
|
+
case 21:
|
|
2097
|
+
pickedDisplayObjects.push(displayObject);
|
|
1787
2098
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2099
|
+
case 22:
|
|
2100
|
+
_i++;
|
|
2101
|
+
_context.next = 9;
|
|
2102
|
+
break;
|
|
1792
2103
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
2104
|
+
case 25:
|
|
2105
|
+
result.picked = pickedDisplayObjects;
|
|
2106
|
+
return _context.abrupt("return", result);
|
|
1796
2107
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
2108
|
+
case 27:
|
|
2109
|
+
case "end":
|
|
2110
|
+
return _context.stop();
|
|
2111
|
+
}
|
|
1800
2112
|
}
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
}));
|
|
2113
|
+
}, _callee);
|
|
2114
|
+
}));
|
|
1804
2115
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
2116
|
+
return function (_x) {
|
|
2117
|
+
return _ref.apply(this, arguments);
|
|
2118
|
+
};
|
|
2119
|
+
}());
|
|
2120
|
+
}
|
|
2121
|
+
}]);
|
|
1810
2122
|
|
|
1811
2123
|
return CanvasPickerPlugin;
|
|
1812
2124
|
}(), _class.tag = 'CanvasPicker', _class);
|
|
@@ -1826,6 +2138,41 @@
|
|
|
1826
2138
|
CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([g.singleton({
|
|
1827
2139
|
contrib: g.RenderingPluginContribution
|
|
1828
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
|
+
}
|
|
1829
2176
|
/**
|
|
1830
2177
|
* 两点之间的距离
|
|
1831
2178
|
* @param {number} x1 起始点 x
|
|
@@ -1835,6 +2182,7 @@
|
|
|
1835
2182
|
* @return {number} 距离
|
|
1836
2183
|
*/
|
|
1837
2184
|
|
|
2185
|
+
|
|
1838
2186
|
function distance(x1, y1, x2, y2) {
|
|
1839
2187
|
var dx = x1 - x2;
|
|
1840
2188
|
var dy = y1 - y2;
|
|
@@ -1846,10 +2194,10 @@
|
|
|
1846
2194
|
}
|
|
1847
2195
|
|
|
1848
2196
|
function getBBoxByArray(xArr, yArr) {
|
|
1849
|
-
var minX = Math.min.apply(Math, xArr);
|
|
1850
|
-
var minY = Math.min.apply(Math, yArr);
|
|
1851
|
-
var maxX = Math.max.apply(Math, xArr);
|
|
1852
|
-
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));
|
|
1853
2201
|
return {
|
|
1854
2202
|
x: minX,
|
|
1855
2203
|
y: minY,
|
|
@@ -1992,7 +2340,7 @@
|
|
|
1992
2340
|
for (var i = 0; i <= segNum; i++) {
|
|
1993
2341
|
var _t = i * increaseRate;
|
|
1994
2342
|
|
|
1995
|
-
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])))];
|
|
1996
2344
|
var d1 = distance(v0[0], v0[1], v1[0], v1[1]);
|
|
1997
2345
|
|
|
1998
2346
|
if (d1 < d) {
|
|
@@ -2026,7 +2374,7 @@
|
|
|
2026
2374
|
|
|
2027
2375
|
var prev = t - interval;
|
|
2028
2376
|
var next = t + interval;
|
|
2029
|
-
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])))];
|
|
2030
2378
|
|
|
2031
2379
|
var _d = distance(v0[0], v0[1], _v[0], _v[1]);
|
|
2032
2380
|
|
|
@@ -2034,7 +2382,7 @@
|
|
|
2034
2382
|
t = prev;
|
|
2035
2383
|
d = _d;
|
|
2036
2384
|
} else {
|
|
2037
|
-
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])))];
|
|
2038
2386
|
var d2 = distance(v0[0], v0[1], v2[0], v2[1]);
|
|
2039
2387
|
|
|
2040
2388
|
if (next <= 1 && d2 < d) {
|
|
@@ -2047,8 +2395,8 @@
|
|
|
2047
2395
|
}
|
|
2048
2396
|
|
|
2049
2397
|
return {
|
|
2050
|
-
x: tCallback.apply(void 0, xArr.concat([t])),
|
|
2051
|
-
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])))
|
|
2052
2400
|
};
|
|
2053
2401
|
} // 近似求解 https://community.khronos.org/t/3d-cubic-bezier-segment-length/62363/2
|
|
2054
2402
|
|
|
@@ -2117,7 +2465,7 @@
|
|
|
2117
2465
|
var right = quadratics[1];
|
|
2118
2466
|
left.push(iterationCount - 1);
|
|
2119
2467
|
right.push(iterationCount - 1);
|
|
2120
|
-
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));
|
|
2121
2469
|
}
|
|
2122
2470
|
|
|
2123
2471
|
var quadratic = {
|
|
@@ -2238,9 +2586,9 @@
|
|
|
2238
2586
|
}
|
|
2239
2587
|
|
|
2240
2588
|
var cubics = divideCubic(x1, y1, x2, y2, x3, y3, x4, y4, 0.5);
|
|
2241
|
-
var left = [].concat(cubics[0], [iterationCount - 1]);
|
|
2242
|
-
var right = [].concat(cubics[1], [iterationCount - 1]);
|
|
2243
|
-
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));
|
|
2244
2592
|
}
|
|
2245
2593
|
|
|
2246
2594
|
var cubic = {
|
|
@@ -2731,7 +3079,7 @@
|
|
|
2731
3079
|
|
|
2732
3080
|
if (hasStroke || isClipPath) {
|
|
2733
3081
|
isHit = inRectWithRadius(0, 0, width, height, radius.map(function (r) {
|
|
2734
|
-
return r.value;
|
|
3082
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
|
|
2735
3083
|
}), lineWidthForHitTesting, position.x, position.y);
|
|
2736
3084
|
} // 仅填充时带有圆角的矩形直接通过图形拾取
|
|
2737
3085
|
// 以后可以改成纯数学的近似拾取,将圆弧切割成多边形
|
|
@@ -2748,10 +3096,12 @@
|
|
|
2748
3096
|
}
|
|
2749
3097
|
|
|
2750
3098
|
function inRectWithRadius(minX, minY, width, height, radiusArray, lineWidth, x, y) {
|
|
2751
|
-
var
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
3099
|
+
var _radiusArray = _slicedToArray$1(radiusArray, 4),
|
|
3100
|
+
tlr = _radiusArray[0],
|
|
3101
|
+
trr = _radiusArray[1],
|
|
3102
|
+
brr = _radiusArray[2],
|
|
3103
|
+
blr = _radiusArray[3];
|
|
3104
|
+
|
|
2755
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);
|
|
2756
3106
|
}
|
|
2757
3107
|
|
|
@@ -2790,106 +3140,30 @@
|
|
|
2790
3140
|
|
|
2791
3141
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
2792
3142
|
function Plugin() {
|
|
2793
|
-
this
|
|
2794
|
-
}
|
|
2795
|
-
|
|
2796
|
-
var _proto = Plugin.prototype;
|
|
3143
|
+
_classCallCheck$2(this, Plugin);
|
|
2797
3144
|
|
|
2798
|
-
|
|
2799
|
-
container.load(containerModule$1, true);
|
|
2800
|
-
};
|
|
2801
|
-
|
|
2802
|
-
_proto.destroy = function destroy(container) {
|
|
2803
|
-
container.unload(containerModule$1);
|
|
2804
|
-
};
|
|
2805
|
-
|
|
2806
|
-
return Plugin;
|
|
2807
|
-
}();
|
|
2808
|
-
|
|
2809
|
-
var ImagePool = /*#__PURE__*/function () {
|
|
2810
|
-
function ImagePool() {
|
|
2811
|
-
this.imageCache = {};
|
|
2812
|
-
this.patternCache = {};
|
|
2813
|
-
this.canvasConfig = void 0;
|
|
3145
|
+
this.name = 'canvas-picker';
|
|
2814
3146
|
}
|
|
2815
3147
|
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
};
|
|
2821
|
-
|
|
2822
|
-
_proto.getOrCreateImage = function getOrCreateImage(src) {
|
|
2823
|
-
var _this = this;
|
|
2824
|
-
|
|
2825
|
-
if (this.imageCache[src]) {
|
|
2826
|
-
return Promise.resolve(this.imageCache[src]);
|
|
2827
|
-
} // @see https://github.com/antvis/g/issues/938
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
var createImage = this.canvasConfig.createImage;
|
|
2831
|
-
return new Promise(function (resolve, reject) {
|
|
2832
|
-
var image;
|
|
2833
|
-
|
|
2834
|
-
if (createImage) {
|
|
2835
|
-
image = createImage(src);
|
|
2836
|
-
} else if (g.isBrowser) {
|
|
2837
|
-
image = new window.Image();
|
|
2838
|
-
}
|
|
2839
|
-
|
|
2840
|
-
if (image) {
|
|
2841
|
-
image.onload = function () {
|
|
2842
|
-
resolve(image);
|
|
2843
|
-
};
|
|
2844
|
-
|
|
2845
|
-
image.onerror = function (ev) {
|
|
2846
|
-
reject(ev);
|
|
2847
|
-
};
|
|
2848
|
-
|
|
2849
|
-
image.crossOrigin = 'Anonymous';
|
|
2850
|
-
image.src = src;
|
|
2851
|
-
_this.imageCache[src] = image;
|
|
2852
|
-
}
|
|
2853
|
-
});
|
|
2854
|
-
};
|
|
2855
|
-
|
|
2856
|
-
_proto.getPatternSync = function getPatternSync(pattern) {
|
|
2857
|
-
var patternKey = this.generatePatternKey(pattern);
|
|
2858
|
-
|
|
2859
|
-
if (this.patternCache[patternKey]) {
|
|
2860
|
-
return this.patternCache[patternKey];
|
|
3148
|
+
_createClass$2(Plugin, [{
|
|
3149
|
+
key: "init",
|
|
3150
|
+
value: function init(container) {
|
|
3151
|
+
container.load(containerModule$1, true);
|
|
2861
3152
|
}
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
var pattern = context.createPattern(image, patternParams.repetition);
|
|
2872
|
-
|
|
2873
|
-
if (pattern) {
|
|
2874
|
-
_this2.patternCache[patternKey] = pattern;
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
return _this2.patternCache[patternKey];
|
|
2878
|
-
});
|
|
2879
|
-
};
|
|
2880
|
-
|
|
2881
|
-
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2882
|
-
var src = pattern.src,
|
|
2883
|
-
repetition = pattern.repetition;
|
|
2884
|
-
return "pattern-" + src + "-" + repetition;
|
|
2885
|
-
};
|
|
3153
|
+
}, {
|
|
3154
|
+
key: "destroy",
|
|
3155
|
+
value: function destroy(container) {
|
|
3156
|
+
container.unload(containerModule$1);
|
|
3157
|
+
}
|
|
3158
|
+
}]);
|
|
2886
3159
|
|
|
2887
|
-
return
|
|
3160
|
+
return Plugin;
|
|
2888
3161
|
}();
|
|
2889
3162
|
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
3163
|
+
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
3164
|
+
__proto__: null,
|
|
3165
|
+
Plugin: Plugin$1
|
|
3166
|
+
});
|
|
2893
3167
|
|
|
2894
3168
|
function _regeneratorRuntime$2() {
|
|
2895
3169
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -3016,7 +3290,7 @@
|
|
|
3016
3290
|
if ("throw" !== record.type) {
|
|
3017
3291
|
var result = record.arg,
|
|
3018
3292
|
value = result.value;
|
|
3019
|
-
return value && "object" ==
|
|
3293
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3020
3294
|
invoke("next", value, resolve, reject);
|
|
3021
3295
|
}, function (err) {
|
|
3022
3296
|
invoke("throw", err, resolve, reject);
|
|
@@ -3277,78 +3551,340 @@
|
|
|
3277
3551
|
};
|
|
3278
3552
|
}
|
|
3279
3553
|
|
|
3280
|
-
|
|
3554
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
3555
|
+
if (!(instance instanceof Constructor)) {
|
|
3556
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3281
3559
|
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
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);
|
|
3287
3567
|
}
|
|
3568
|
+
}
|
|
3288
3569
|
|
|
3289
|
-
|
|
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
|
+
}
|
|
3290
3578
|
|
|
3291
|
-
|
|
3292
|
-
|
|
3579
|
+
function _slicedToArray$2(arr, i) {
|
|
3580
|
+
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2();
|
|
3581
|
+
}
|
|
3293
3582
|
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
attributes = object.attributes;
|
|
3583
|
+
function _arrayWithHoles$2(arr) {
|
|
3584
|
+
if (Array.isArray(arr)) return arr;
|
|
3585
|
+
}
|
|
3298
3586
|
|
|
3299
|
-
|
|
3300
|
-
|
|
3587
|
+
function _iterableToArrayLimit$2(arr, i) {
|
|
3588
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
3301
3589
|
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
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;
|
|
3308
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];
|
|
3309
3705
|
}
|
|
3310
|
-
};
|
|
3311
3706
|
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
var
|
|
3315
|
-
|
|
3707
|
+
var image = pattern.image,
|
|
3708
|
+
repetition = pattern.repetition;
|
|
3709
|
+
var src; // Image URL
|
|
3710
|
+
|
|
3711
|
+
if (g.isString(image)) {
|
|
3712
|
+
src = this.getImageSync(image, callback);
|
|
3713
|
+
} else {
|
|
3714
|
+
src = image;
|
|
3715
|
+
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
3719
|
+
|
|
3720
|
+
if (patternKey && canvasPattern) {
|
|
3721
|
+
this.patternCache[patternKey] = canvasPattern;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
return canvasPattern;
|
|
3725
|
+
}
|
|
3726
|
+
}, {
|
|
3727
|
+
key: "getOrCreateGradient",
|
|
3728
|
+
value: function getOrCreateGradient(params, context) {
|
|
3729
|
+
var key = this.generateGradientKey(params); // @ts-ignore
|
|
3730
|
+
|
|
3731
|
+
var type = params.type,
|
|
3732
|
+
steps = params.steps,
|
|
3733
|
+
width = params.width,
|
|
3734
|
+
height = params.height,
|
|
3735
|
+
angle = params.angle,
|
|
3736
|
+
cx = params.cx,
|
|
3737
|
+
cy = params.cy;
|
|
3738
|
+
|
|
3739
|
+
if (this.gradientCache[key]) {
|
|
3740
|
+
return this.gradientCache[key];
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
var gradient = null;
|
|
3744
|
+
|
|
3745
|
+
if (type === g.GradientType.LinearGradient) {
|
|
3746
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
3747
|
+
x1 = _computeLinearGradien.x1,
|
|
3748
|
+
y1 = _computeLinearGradien.y1,
|
|
3749
|
+
x2 = _computeLinearGradien.x2,
|
|
3750
|
+
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
3754
|
+
} else if (type === g.GradientType.RadialGradient) {
|
|
3755
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
3756
|
+
x = _computeRadialGradien.x,
|
|
3757
|
+
y = _computeRadialGradien.y,
|
|
3758
|
+
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
3759
|
+
|
|
3760
|
+
|
|
3761
|
+
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
if (gradient) {
|
|
3765
|
+
steps.forEach(function (_ref) {
|
|
3766
|
+
var _gradient;
|
|
3767
|
+
|
|
3768
|
+
var _ref2 = _slicedToArray$2(_ref, 2),
|
|
3769
|
+
offset = _ref2[0],
|
|
3770
|
+
color = _ref2[1];
|
|
3771
|
+
|
|
3772
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
3773
|
+
});
|
|
3774
|
+
this.gradientCache[key] = gradient;
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
return this.gradientCache[key];
|
|
3778
|
+
}
|
|
3779
|
+
}, {
|
|
3780
|
+
key: "generateGradientKey",
|
|
3781
|
+
value: function generateGradientKey(params) {
|
|
3782
|
+
// @ts-ignore
|
|
3783
|
+
var type = params.type,
|
|
3784
|
+
width = params.width,
|
|
3785
|
+
height = params.height,
|
|
3786
|
+
steps = params.steps,
|
|
3787
|
+
angle = params.angle,
|
|
3788
|
+
cx = params.cx,
|
|
3789
|
+
cy = params.cy;
|
|
3790
|
+
return "gradient-".concat(type, "-").concat(angle || 0, "-").concat(cx || 0, "-").concat(cy || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (step) {
|
|
3791
|
+
return step.join('');
|
|
3792
|
+
}).join('-'));
|
|
3793
|
+
}
|
|
3794
|
+
}, {
|
|
3795
|
+
key: "generatePatternKey",
|
|
3796
|
+
value: function generatePatternKey(pattern) {
|
|
3797
|
+
var image = pattern.image,
|
|
3798
|
+
repetition = pattern.repetition; // only generate cache for Image
|
|
3799
|
+
|
|
3800
|
+
if (g.isString(image)) {
|
|
3801
|
+
return "pattern-".concat(image, "-").concat(repetition);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
}]);
|
|
3805
|
+
|
|
3806
|
+
return ImagePool;
|
|
3807
|
+
}();
|
|
3808
|
+
|
|
3809
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
3810
|
+
|
|
3811
|
+
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
3812
|
+
|
|
3813
|
+
var _class$1;
|
|
3814
|
+
|
|
3815
|
+
var LoadImagePlugin_1;
|
|
3816
|
+
var LoadImagePlugin = LoadImagePlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
3817
|
+
function LoadImagePlugin() {
|
|
3818
|
+
_classCallCheck$3(this, LoadImagePlugin);
|
|
3819
|
+
|
|
3820
|
+
this.imagePool = void 0;
|
|
3821
|
+
this.renderingContext = void 0;
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
_createClass$3(LoadImagePlugin, [{
|
|
3825
|
+
key: "apply",
|
|
3826
|
+
value: function apply(renderingService) {
|
|
3827
|
+
var _this = this;
|
|
3828
|
+
|
|
3829
|
+
var handleMounted = function handleMounted(e) {
|
|
3830
|
+
var object = e.target;
|
|
3831
|
+
var nodeName = object.nodeName,
|
|
3832
|
+
attributes = object.attributes;
|
|
3316
3833
|
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3834
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
3835
|
+
var img = attributes.img;
|
|
3836
|
+
|
|
3837
|
+
if (g.isString(img)) {
|
|
3838
|
+
_this.imagePool.getImageSync(img, function () {
|
|
3321
3839
|
// set dirty rectangle flag
|
|
3322
3840
|
object.renderable.dirty = true;
|
|
3323
3841
|
renderingService.dirtify();
|
|
3324
3842
|
});
|
|
3325
3843
|
}
|
|
3326
3844
|
}
|
|
3327
|
-
}
|
|
3328
|
-
|
|
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
|
+
};
|
|
3329
3864
|
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
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);
|
|
3336
3871
|
|
|
3337
|
-
|
|
3872
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3338
3873
|
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3874
|
+
case 2:
|
|
3875
|
+
case "end":
|
|
3876
|
+
return _context.stop();
|
|
3877
|
+
}
|
|
3342
3878
|
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
_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);
|
|
3348
3883
|
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3884
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3887
|
+
}]);
|
|
3352
3888
|
|
|
3353
3889
|
return LoadImagePlugin;
|
|
3354
3890
|
}(), _class$1.tag = 'LoadImage', _class$1);
|
|
@@ -3367,22 +3903,58 @@
|
|
|
3367
3903
|
|
|
3368
3904
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
3369
3905
|
function Plugin() {
|
|
3906
|
+
_classCallCheck$3(this, Plugin);
|
|
3907
|
+
|
|
3370
3908
|
this.name = 'image-loader';
|
|
3371
3909
|
}
|
|
3372
3910
|
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
container
|
|
3381
|
-
|
|
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
|
+
}]);
|
|
3382
3922
|
|
|
3383
3923
|
return Plugin;
|
|
3384
3924
|
}();
|
|
3385
3925
|
|
|
3926
|
+
var index_esm$2 = /*#__PURE__*/Object.freeze({
|
|
3927
|
+
__proto__: null,
|
|
3928
|
+
get ImagePool () { return ImagePool; },
|
|
3929
|
+
Plugin: Plugin$2
|
|
3930
|
+
});
|
|
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
|
+
|
|
3386
3958
|
function _regeneratorRuntime$3() {
|
|
3387
3959
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3388
3960
|
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
@@ -3508,7 +4080,7 @@
|
|
|
3508
4080
|
if ("throw" !== record.type) {
|
|
3509
4081
|
var result = record.arg,
|
|
3510
4082
|
value = result.value;
|
|
3511
|
-
return value && "object" ==
|
|
4083
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3512
4084
|
invoke("next", value, resolve, reject);
|
|
3513
4085
|
}, function (err) {
|
|
3514
4086
|
invoke("throw", err, resolve, reject);
|
|
@@ -3769,39 +4341,205 @@
|
|
|
3769
4341
|
};
|
|
3770
4342
|
}
|
|
3771
4343
|
|
|
3772
|
-
function
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
4344
|
+
function _classCallCheck$4(instance, Constructor) {
|
|
4345
|
+
if (!(instance instanceof Constructor)) {
|
|
4346
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
3776
4349
|
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
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
|
+
}
|
|
3783
4359
|
|
|
3784
|
-
|
|
3785
|
-
|
|
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
|
+
}
|
|
3786
4380
|
|
|
3787
|
-
return
|
|
4381
|
+
return obj;
|
|
3788
4382
|
}
|
|
3789
4383
|
|
|
3790
|
-
function
|
|
3791
|
-
|
|
3792
|
-
|
|
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
|
+
}
|
|
3793
4401
|
|
|
3794
|
-
|
|
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);
|
|
3795
4407
|
}
|
|
3796
4408
|
|
|
3797
4409
|
function _setPrototypeOf$1(o, p) {
|
|
3798
|
-
_setPrototypeOf$1 = Object.setPrototypeOf
|
|
4410
|
+
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
3799
4411
|
o.__proto__ = p;
|
|
3800
4412
|
return o;
|
|
3801
4413
|
};
|
|
3802
|
-
|
|
3803
4414
|
return _setPrototypeOf$1(o, p);
|
|
3804
4415
|
}
|
|
4416
|
+
|
|
4417
|
+
function _isNativeReflectConstruct$1() {
|
|
4418
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
4419
|
+
if (Reflect.construct.sham) return false;
|
|
4420
|
+
if (typeof Proxy === "function") return true;
|
|
4421
|
+
|
|
4422
|
+
try {
|
|
4423
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4424
|
+
return true;
|
|
4425
|
+
} catch (e) {
|
|
4426
|
+
return false;
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
|
|
4430
|
+
function _assertThisInitialized$1(self) {
|
|
4431
|
+
if (self === void 0) {
|
|
4432
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4435
|
+
return self;
|
|
4436
|
+
}
|
|
4437
|
+
|
|
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
|
+
}
|
|
4444
|
+
|
|
4445
|
+
return _assertThisInitialized$1(self);
|
|
4446
|
+
}
|
|
4447
|
+
|
|
4448
|
+
function _createSuper$1(Derived) {
|
|
4449
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
4450
|
+
|
|
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);
|
|
4464
|
+
};
|
|
4465
|
+
}
|
|
4466
|
+
|
|
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
|
+
}
|
|
4474
|
+
|
|
4475
|
+
function _arrayWithoutHoles$2(arr) {
|
|
4476
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
|
|
4477
|
+
}
|
|
4478
|
+
|
|
4479
|
+
function _arrayWithHoles$3(arr) {
|
|
4480
|
+
if (Array.isArray(arr)) return arr;
|
|
4481
|
+
}
|
|
4482
|
+
|
|
4483
|
+
function _iterableToArray$2(iter) {
|
|
4484
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4487
|
+
function _iterableToArrayLimit$3(arr, i) {
|
|
4488
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
4489
|
+
|
|
4490
|
+
if (_i == null) return;
|
|
4491
|
+
var _arr = [];
|
|
4492
|
+
var _n = true;
|
|
4493
|
+
var _d = false;
|
|
4494
|
+
|
|
4495
|
+
var _s, _e;
|
|
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;
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
return _arr;
|
|
4515
|
+
}
|
|
4516
|
+
|
|
4517
|
+
function _unsupportedIterableToArray$3(o, minLen) {
|
|
4518
|
+
if (!o) return;
|
|
4519
|
+
if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
|
|
4520
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4521
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4522
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
4523
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
|
|
4524
|
+
}
|
|
4525
|
+
|
|
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
|
+
}
|
|
4532
|
+
|
|
4533
|
+
return arr2;
|
|
4534
|
+
}
|
|
4535
|
+
|
|
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
|
+
}
|
|
4539
|
+
|
|
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.");
|
|
4542
|
+
}
|
|
3805
4543
|
/**
|
|
3806
4544
|
* Common utilities
|
|
3807
4545
|
* @module glMatrix
|
|
@@ -4497,73 +5235,6 @@
|
|
|
4497
5235
|
};
|
|
4498
5236
|
}();
|
|
4499
5237
|
|
|
4500
|
-
var GradientPool = /*#__PURE__*/function () {
|
|
4501
|
-
function GradientPool() {
|
|
4502
|
-
this.gradientCache = {};
|
|
4503
|
-
}
|
|
4504
|
-
|
|
4505
|
-
var _proto = GradientPool.prototype;
|
|
4506
|
-
|
|
4507
|
-
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
4508
|
-
var key = this.generateCacheKey(params);
|
|
4509
|
-
var type = params.type,
|
|
4510
|
-
x0 = params.x0,
|
|
4511
|
-
y0 = params.y0,
|
|
4512
|
-
x1 = params.x1,
|
|
4513
|
-
y1 = params.y1,
|
|
4514
|
-
steps = params.steps,
|
|
4515
|
-
width = params.width,
|
|
4516
|
-
height = params.height;
|
|
4517
|
-
|
|
4518
|
-
if (this.gradientCache[key]) {
|
|
4519
|
-
return this.gradientCache[key];
|
|
4520
|
-
}
|
|
4521
|
-
|
|
4522
|
-
var gradient = null;
|
|
4523
|
-
|
|
4524
|
-
if (type === g.GradientPatternType.LinearGradient) {
|
|
4525
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
4526
|
-
gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
|
|
4527
|
-
} else if (type === g.GradientPatternType.RadialGradient) {
|
|
4528
|
-
var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
4529
|
-
|
|
4530
|
-
gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
|
-
if (gradient) {
|
|
4534
|
-
steps.forEach(function (_ref) {
|
|
4535
|
-
var _gradient;
|
|
4536
|
-
|
|
4537
|
-
var offset = _ref[0],
|
|
4538
|
-
color = _ref[1];
|
|
4539
|
-
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
|
|
4540
|
-
});
|
|
4541
|
-
this.gradientCache[key] = gradient;
|
|
4542
|
-
}
|
|
4543
|
-
|
|
4544
|
-
return this.gradientCache[key];
|
|
4545
|
-
};
|
|
4546
|
-
|
|
4547
|
-
_proto.generateCacheKey = function generateCacheKey(params) {
|
|
4548
|
-
// @ts-ignore
|
|
4549
|
-
var type = params.type,
|
|
4550
|
-
x0 = params.x0,
|
|
4551
|
-
y0 = params.y0,
|
|
4552
|
-
x1 = params.x1,
|
|
4553
|
-
y1 = params.y1,
|
|
4554
|
-
r1 = params.r1,
|
|
4555
|
-
steps = params.steps,
|
|
4556
|
-
width = params.width,
|
|
4557
|
-
height = params.height;
|
|
4558
|
-
return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
4559
|
-
return step.join('');
|
|
4560
|
-
}).join('-');
|
|
4561
|
-
};
|
|
4562
|
-
|
|
4563
|
-
return GradientPool;
|
|
4564
|
-
}();
|
|
4565
|
-
|
|
4566
|
-
GradientPool = __decorate([g.singleton()], GradientPool);
|
|
4567
5238
|
var StyleRendererFactory = g.Syringe.defineToken('StyleRendererFactory');
|
|
4568
5239
|
var CircleRendererContribution = g.Syringe.defineToken('CircleRenderer', {
|
|
4569
5240
|
multiple: false
|
|
@@ -4595,36 +5266,39 @@
|
|
|
4595
5266
|
|
|
4596
5267
|
var ImageRenderer = /*#__PURE__*/function () {
|
|
4597
5268
|
function ImageRenderer() {
|
|
5269
|
+
_classCallCheck$4(this, ImageRenderer);
|
|
5270
|
+
|
|
4598
5271
|
this.imagePool = void 0;
|
|
4599
5272
|
}
|
|
4600
5273
|
|
|
4601
|
-
|
|
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;
|
|
4602
5283
|
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
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
|
+
}
|
|
4610
5292
|
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
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
|
+
}
|
|
4618
5300
|
}
|
|
4619
|
-
|
|
4620
|
-
if (image) {
|
|
4621
|
-
// node-canvas will throw the following err:
|
|
4622
|
-
// Error: Image given has not completed loading
|
|
4623
|
-
try {
|
|
4624
|
-
context.drawImage(image, 0, 0, iw, ih);
|
|
4625
|
-
} catch (e) {}
|
|
4626
|
-
}
|
|
4627
|
-
};
|
|
5301
|
+
}]);
|
|
4628
5302
|
|
|
4629
5303
|
return ImageRenderer;
|
|
4630
5304
|
}();
|
|
@@ -4636,154 +5310,157 @@
|
|
|
4636
5310
|
})], ImageRenderer);
|
|
4637
5311
|
|
|
4638
5312
|
var TextRenderer = /*#__PURE__*/function () {
|
|
4639
|
-
function TextRenderer() {
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
4689
|
-
linePositionY += dy.value;
|
|
4690
|
-
} // draw lines line by line
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
for (var i = 0; i < lines.length; i++) {
|
|
4694
|
-
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
4695
|
-
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
4696
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
4697
|
-
|
|
4698
|
-
if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
|
|
4699
|
-
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
4700
|
-
}
|
|
4701
|
-
|
|
4702
|
-
if (!g.isNil(fill)) {
|
|
4703
|
-
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;
|
|
4704
5362
|
}
|
|
4705
|
-
}
|
|
4706
|
-
};
|
|
4707
|
-
|
|
4708
|
-
_proto.drawLetterSpacing = function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity, isStroke) {
|
|
4709
|
-
if (isStroke === void 0) {
|
|
4710
|
-
isStroke = false;
|
|
4711
|
-
} // letterSpacing of 0 means normal, render all texts directly
|
|
4712
5363
|
|
|
5364
|
+
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
5365
|
+
linePositionY += dy.value;
|
|
5366
|
+
} // draw lines line by line
|
|
4713
5367
|
|
|
4714
|
-
if (letterSpacing === 0) {
|
|
4715
|
-
if (isStroke) {
|
|
4716
|
-
this.strokeText(context, text, x, y, strokeOpacity);
|
|
4717
|
-
} else {
|
|
4718
|
-
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
4719
|
-
}
|
|
4720
5368
|
|
|
4721
|
-
|
|
4722
|
-
|
|
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
|
|
4723
5373
|
|
|
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
|
+
}
|
|
4724
5377
|
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
if (textAlign === 'center') {
|
|
4730
|
-
currentPosition = x - lineMetrics.width / 2;
|
|
4731
|
-
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
4732
|
-
currentPosition = x - lineMetrics.width;
|
|
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
|
+
}
|
|
4733
5382
|
}
|
|
5383
|
+
}, {
|
|
5384
|
+
key: "drawLetterSpacing",
|
|
5385
|
+
value: function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity) {
|
|
5386
|
+
var isStroke = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false; // letterSpacing of 0 means normal, render all texts directly
|
|
5387
|
+
|
|
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
|
+
}
|
|
4734
5394
|
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
var currentWidth = 0;
|
|
5395
|
+
return;
|
|
5396
|
+
} // draw text using left align
|
|
4738
5397
|
|
|
4739
|
-
for (var i = 0; i < stringArray.length; ++i) {
|
|
4740
|
-
var currentChar = stringArray[i];
|
|
4741
5398
|
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
4746
|
-
}
|
|
5399
|
+
var currentTextAlign = context.textAlign;
|
|
5400
|
+
context.textAlign = 'left';
|
|
5401
|
+
var currentPosition = x;
|
|
4747
5402
|
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
5403
|
+
if (textAlign === 'center') {
|
|
5404
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
5405
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
5406
|
+
currentPosition = x - lineMetrics.width;
|
|
5407
|
+
}
|
|
4752
5408
|
|
|
4753
|
-
|
|
4754
|
-
|
|
5409
|
+
var stringArray = Array.from(text);
|
|
5410
|
+
var previousWidth = context.measureText(text).width;
|
|
5411
|
+
var currentWidth = 0;
|
|
4755
5412
|
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
5413
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
5414
|
+
var currentChar = stringArray[i];
|
|
4759
5415
|
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
5416
|
+
if (isStroke) {
|
|
5417
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
5418
|
+
} else {
|
|
5419
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
5420
|
+
}
|
|
4764
5421
|
|
|
4765
|
-
|
|
5422
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
5423
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
5424
|
+
previousWidth = currentWidth;
|
|
5425
|
+
}
|
|
4766
5426
|
|
|
4767
|
-
|
|
4768
|
-
context.globalAlpha = currentGlobalAlpha;
|
|
5427
|
+
context.textAlign = currentTextAlign;
|
|
4769
5428
|
}
|
|
4770
|
-
}
|
|
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
|
+
}
|
|
4771
5439
|
|
|
4772
|
-
|
|
4773
|
-
var currentGlobalAlpha;
|
|
4774
|
-
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
5440
|
+
context.fillText(text, x, y);
|
|
4775
5441
|
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
5442
|
+
if (applyOpacity) {
|
|
5443
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5444
|
+
}
|
|
4779
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
|
+
}
|
|
4780
5456
|
|
|
4781
|
-
|
|
5457
|
+
context.strokeText(text, x, y);
|
|
4782
5458
|
|
|
4783
|
-
|
|
4784
|
-
|
|
5459
|
+
if (applyOpacity) {
|
|
5460
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
5461
|
+
}
|
|
4785
5462
|
}
|
|
4786
|
-
};
|
|
5463
|
+
}]);
|
|
4787
5464
|
|
|
4788
5465
|
return TextRenderer;
|
|
4789
5466
|
}();
|
|
@@ -4793,122 +5470,198 @@
|
|
|
4793
5470
|
})], TextRenderer);
|
|
4794
5471
|
|
|
4795
5472
|
var DefaultRenderer = /*#__PURE__*/function () {
|
|
4796
|
-
function DefaultRenderer() {
|
|
4797
|
-
|
|
4798
|
-
var _proto = DefaultRenderer.prototype;
|
|
4799
|
-
|
|
4800
|
-
_proto.render = function render(context, parsedStyle) {
|
|
4801
|
-
var fill = parsedStyle.fill,
|
|
4802
|
-
opacity = parsedStyle.opacity,
|
|
4803
|
-
fillOpacity = parsedStyle.fillOpacity,
|
|
4804
|
-
stroke = parsedStyle.stroke,
|
|
4805
|
-
strokeOpacity = parsedStyle.strokeOpacity,
|
|
4806
|
-
lineWidth = parsedStyle.lineWidth,
|
|
4807
|
-
lineCap = parsedStyle.lineCap,
|
|
4808
|
-
lineJoin = parsedStyle.lineJoin,
|
|
4809
|
-
shadowColor = parsedStyle.shadowColor,
|
|
4810
|
-
filter = parsedStyle.filter,
|
|
4811
|
-
miterLimit = parsedStyle.miterLimit;
|
|
4812
|
-
var hasFill = !g.isNil(fill) && !fill.isNone;
|
|
4813
|
-
var hasStroke = !g.isNil(stroke) && !stroke.isNone;
|
|
4814
|
-
var isFillTransparent = fill.alpha === 0;
|
|
5473
|
+
function DefaultRenderer() {
|
|
5474
|
+
_classCallCheck$4(this, DefaultRenderer);
|
|
4815
5475
|
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
5476
|
+
this.imagePool = void 0;
|
|
5477
|
+
}
|
|
5478
|
+
|
|
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
|
+
}
|
|
4823
5505
|
}
|
|
4824
|
-
}
|
|
4825
5506
|
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
5507
|
+
if (hasStroke) {
|
|
5508
|
+
if (lineWidth && lineWidth.value > 0) {
|
|
5509
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
4829
5510
|
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
5511
|
+
if (applyOpacity) {
|
|
5512
|
+
context.globalAlpha = strokeOpacity.value;
|
|
5513
|
+
}
|
|
4833
5514
|
|
|
4834
|
-
|
|
5515
|
+
context.lineWidth = lineWidth.value;
|
|
4835
5516
|
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
5517
|
+
if (!g.isNil(miterLimit)) {
|
|
5518
|
+
context.miterLimit = miterLimit;
|
|
5519
|
+
}
|
|
4839
5520
|
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
5521
|
+
if (!g.isNil(lineCap)) {
|
|
5522
|
+
context.lineCap = lineCap.value;
|
|
5523
|
+
}
|
|
4843
5524
|
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
5525
|
+
if (!g.isNil(lineJoin)) {
|
|
5526
|
+
context.lineJoin = lineJoin.value;
|
|
5527
|
+
}
|
|
4847
5528
|
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
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
|
+
}
|
|
4863
5545
|
}
|
|
4864
|
-
}
|
|
4865
5546
|
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5547
|
+
if (hasFilter) {
|
|
5548
|
+
// save drop-shadow filter
|
|
5549
|
+
oldFilter = context.filter;
|
|
4869
5550
|
|
|
4870
|
-
|
|
4871
|
-
|
|
5551
|
+
if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
5552
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
5553
|
+
}
|
|
4872
5554
|
}
|
|
4873
|
-
}
|
|
4874
5555
|
|
|
4875
|
-
|
|
5556
|
+
var drawStroke = hasFill && !isFillTransparent;
|
|
5557
|
+
|
|
5558
|
+
if (drawStroke) {
|
|
5559
|
+
this.stroke(context, object, stroke, renderingService);
|
|
5560
|
+
} // restore shadow blur
|
|
4876
5561
|
|
|
4877
|
-
if (drawStroke) {
|
|
4878
|
-
context.stroke();
|
|
4879
|
-
} // restore shadow blur
|
|
4880
5562
|
|
|
5563
|
+
if (hasShadowColor) {
|
|
5564
|
+
context.shadowColor = oldShadowColor;
|
|
5565
|
+
context.shadowBlur = oldShadowBlur;
|
|
5566
|
+
} // restore filters
|
|
4881
5567
|
|
|
4882
|
-
if (hasShadowColor) {
|
|
4883
|
-
context.shadowColor = oldShadowColor;
|
|
4884
|
-
context.shadowBlur = oldShadowBlur;
|
|
4885
|
-
} // restore filters
|
|
4886
5568
|
|
|
5569
|
+
if (hasFilter) {
|
|
5570
|
+
context.filter = oldFilter;
|
|
5571
|
+
}
|
|
4887
5572
|
|
|
4888
|
-
|
|
4889
|
-
|
|
5573
|
+
if (!drawStroke) {
|
|
5574
|
+
this.stroke(context, object, stroke, renderingService);
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
}, {
|
|
5580
|
+
key: "fill",
|
|
5581
|
+
value: function fill(context, object, _fill, renderingService) {
|
|
5582
|
+
var _this = this;
|
|
5583
|
+
|
|
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);
|
|
4890
5592
|
}
|
|
4891
5593
|
|
|
4892
|
-
|
|
5594
|
+
context.fill();
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
}, {
|
|
5598
|
+
key: "stroke",
|
|
5599
|
+
value: function stroke(context, object, _stroke, renderingService) {
|
|
5600
|
+
var _this2 = this;
|
|
5601
|
+
|
|
5602
|
+
if (Array.isArray(_stroke)) {
|
|
5603
|
+
_stroke.forEach(function (gradient) {
|
|
5604
|
+
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
4893
5605
|
context.stroke();
|
|
5606
|
+
});
|
|
5607
|
+
} else {
|
|
5608
|
+
if (g.isPattern(_stroke)) {
|
|
5609
|
+
context.strokeStyle = this.getPattern(_stroke, object, context, renderingService);
|
|
4894
5610
|
}
|
|
5611
|
+
|
|
5612
|
+
context.stroke();
|
|
4895
5613
|
}
|
|
4896
5614
|
}
|
|
4897
|
-
}
|
|
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
|
+
}
|
|
5641
|
+
|
|
5642
|
+
return color;
|
|
5643
|
+
}
|
|
5644
|
+
}]);
|
|
4898
5645
|
|
|
4899
5646
|
return DefaultRenderer;
|
|
4900
5647
|
}();
|
|
4901
5648
|
|
|
5649
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], DefaultRenderer.prototype, "imagePool", void 0);
|
|
5650
|
+
|
|
4902
5651
|
DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
|
|
4903
5652
|
|
|
4904
5653
|
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4905
|
-
|
|
5654
|
+
_inherits$1(RectRenderer, _DefaultRenderer);
|
|
5655
|
+
|
|
5656
|
+
var _super = _createSuper$1(RectRenderer);
|
|
4906
5657
|
|
|
4907
5658
|
function RectRenderer() {
|
|
4908
|
-
|
|
5659
|
+
_classCallCheck$4(this, RectRenderer);
|
|
5660
|
+
|
|
5661
|
+
return _super.apply(this, arguments);
|
|
4909
5662
|
}
|
|
4910
5663
|
|
|
4911
|
-
return RectRenderer;
|
|
5664
|
+
return _createClass$4(RectRenderer);
|
|
4912
5665
|
}(DefaultRenderer);
|
|
4913
5666
|
|
|
4914
5667
|
RectRenderer = __decorate([g.singleton({
|
|
@@ -4916,13 +5669,17 @@
|
|
|
4916
5669
|
})], RectRenderer);
|
|
4917
5670
|
|
|
4918
5671
|
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4919
|
-
|
|
5672
|
+
_inherits$1(CircleRenderer, _DefaultRenderer);
|
|
5673
|
+
|
|
5674
|
+
var _super = _createSuper$1(CircleRenderer);
|
|
4920
5675
|
|
|
4921
5676
|
function CircleRenderer() {
|
|
4922
|
-
|
|
5677
|
+
_classCallCheck$4(this, CircleRenderer);
|
|
5678
|
+
|
|
5679
|
+
return _super.apply(this, arguments);
|
|
4923
5680
|
}
|
|
4924
5681
|
|
|
4925
|
-
return CircleRenderer;
|
|
5682
|
+
return _createClass$4(CircleRenderer);
|
|
4926
5683
|
}(DefaultRenderer);
|
|
4927
5684
|
|
|
4928
5685
|
CircleRenderer = __decorate([g.singleton({
|
|
@@ -4930,13 +5687,17 @@
|
|
|
4930
5687
|
})], CircleRenderer);
|
|
4931
5688
|
|
|
4932
5689
|
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4933
|
-
|
|
5690
|
+
_inherits$1(EllipseRenderer, _DefaultRenderer);
|
|
5691
|
+
|
|
5692
|
+
var _super = _createSuper$1(EllipseRenderer);
|
|
4934
5693
|
|
|
4935
5694
|
function EllipseRenderer() {
|
|
4936
|
-
|
|
5695
|
+
_classCallCheck$4(this, EllipseRenderer);
|
|
5696
|
+
|
|
5697
|
+
return _super.apply(this, arguments);
|
|
4937
5698
|
}
|
|
4938
5699
|
|
|
4939
|
-
return EllipseRenderer;
|
|
5700
|
+
return _createClass$4(EllipseRenderer);
|
|
4940
5701
|
}(DefaultRenderer);
|
|
4941
5702
|
|
|
4942
5703
|
EllipseRenderer = __decorate([g.singleton({
|
|
@@ -4944,13 +5705,17 @@
|
|
|
4944
5705
|
})], EllipseRenderer);
|
|
4945
5706
|
|
|
4946
5707
|
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4947
|
-
|
|
5708
|
+
_inherits$1(LineRenderer, _DefaultRenderer);
|
|
5709
|
+
|
|
5710
|
+
var _super = _createSuper$1(LineRenderer);
|
|
4948
5711
|
|
|
4949
5712
|
function LineRenderer() {
|
|
4950
|
-
|
|
5713
|
+
_classCallCheck$4(this, LineRenderer);
|
|
5714
|
+
|
|
5715
|
+
return _super.apply(this, arguments);
|
|
4951
5716
|
}
|
|
4952
5717
|
|
|
4953
|
-
return LineRenderer;
|
|
5718
|
+
return _createClass$4(LineRenderer);
|
|
4954
5719
|
}(DefaultRenderer);
|
|
4955
5720
|
|
|
4956
5721
|
LineRenderer = __decorate([g.singleton({
|
|
@@ -4958,13 +5723,17 @@
|
|
|
4958
5723
|
})], LineRenderer);
|
|
4959
5724
|
|
|
4960
5725
|
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4961
|
-
|
|
5726
|
+
_inherits$1(PolylineRenderer, _DefaultRenderer);
|
|
5727
|
+
|
|
5728
|
+
var _super = _createSuper$1(PolylineRenderer);
|
|
4962
5729
|
|
|
4963
5730
|
function PolylineRenderer() {
|
|
4964
|
-
|
|
5731
|
+
_classCallCheck$4(this, PolylineRenderer);
|
|
5732
|
+
|
|
5733
|
+
return _super.apply(this, arguments);
|
|
4965
5734
|
}
|
|
4966
5735
|
|
|
4967
|
-
return PolylineRenderer;
|
|
5736
|
+
return _createClass$4(PolylineRenderer);
|
|
4968
5737
|
}(DefaultRenderer);
|
|
4969
5738
|
|
|
4970
5739
|
PolylineRenderer = __decorate([g.singleton({
|
|
@@ -4972,13 +5741,17 @@
|
|
|
4972
5741
|
})], PolylineRenderer);
|
|
4973
5742
|
|
|
4974
5743
|
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4975
|
-
|
|
5744
|
+
_inherits$1(PolygonRenderer, _DefaultRenderer);
|
|
5745
|
+
|
|
5746
|
+
var _super = _createSuper$1(PolygonRenderer);
|
|
4976
5747
|
|
|
4977
5748
|
function PolygonRenderer() {
|
|
4978
|
-
|
|
5749
|
+
_classCallCheck$4(this, PolygonRenderer);
|
|
5750
|
+
|
|
5751
|
+
return _super.apply(this, arguments);
|
|
4979
5752
|
}
|
|
4980
5753
|
|
|
4981
|
-
return PolygonRenderer;
|
|
5754
|
+
return _createClass$4(PolygonRenderer);
|
|
4982
5755
|
}(DefaultRenderer);
|
|
4983
5756
|
|
|
4984
5757
|
PolygonRenderer = __decorate([g.singleton({
|
|
@@ -4986,13 +5759,17 @@
|
|
|
4986
5759
|
})], PolygonRenderer);
|
|
4987
5760
|
|
|
4988
5761
|
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4989
|
-
|
|
5762
|
+
_inherits$1(PathRenderer, _DefaultRenderer);
|
|
5763
|
+
|
|
5764
|
+
var _super = _createSuper$1(PathRenderer);
|
|
4990
5765
|
|
|
4991
5766
|
function PathRenderer() {
|
|
4992
|
-
|
|
5767
|
+
_classCallCheck$4(this, PathRenderer);
|
|
5768
|
+
|
|
5769
|
+
return _super.apply(this, arguments);
|
|
4993
5770
|
}
|
|
4994
5771
|
|
|
4995
|
-
return PathRenderer;
|
|
5772
|
+
return _createClass$4(PathRenderer);
|
|
4996
5773
|
}(DefaultRenderer);
|
|
4997
5774
|
|
|
4998
5775
|
PathRenderer = __decorate([g.singleton({
|
|
@@ -5010,12 +5787,12 @@
|
|
|
5010
5787
|
|
|
5011
5788
|
var CanvasRendererPlugin = CanvasRendererPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
5012
5789
|
function CanvasRendererPlugin() {
|
|
5790
|
+
_classCallCheck$4(this, CanvasRendererPlugin);
|
|
5791
|
+
|
|
5013
5792
|
this.canvasConfig = void 0;
|
|
5014
5793
|
this.camera = void 0;
|
|
5015
5794
|
this.contextService = void 0;
|
|
5016
5795
|
this.renderingContext = void 0;
|
|
5017
|
-
this.imagePool = void 0;
|
|
5018
|
-
this.gradientPool = void 0;
|
|
5019
5796
|
this.pathGeneratorFactory = void 0;
|
|
5020
5797
|
this.pathGeneratorFactoryCache = {};
|
|
5021
5798
|
this.styleRendererFactory = void 0;
|
|
@@ -5030,516 +5807,476 @@
|
|
|
5030
5807
|
this.tmpMat4 = create$1$1();
|
|
5031
5808
|
}
|
|
5032
5809
|
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5810
|
+
_createClass$4(CanvasRendererPlugin, [{
|
|
5811
|
+
key: "apply",
|
|
5812
|
+
value: function apply(renderingService) {
|
|
5813
|
+
var _this = this;
|
|
5037
5814
|
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5815
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
5816
|
+
var object = e.target; // remove r-bush node
|
|
5817
|
+
// @ts-ignore
|
|
5041
5818
|
|
|
5042
|
-
|
|
5819
|
+
var rBushNode = object.rBushNode;
|
|
5043
5820
|
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5821
|
+
if (rBushNode.aabb) {
|
|
5822
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5823
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5824
|
+
}
|
|
5825
|
+
};
|
|
5049
5826
|
|
|
5050
|
-
|
|
5051
|
-
|
|
5827
|
+
var handleCulled = function handleCulled(e) {
|
|
5828
|
+
var object = e.target; // @ts-ignore
|
|
5052
5829
|
|
|
5053
|
-
|
|
5830
|
+
var rBushNode = object.rBushNode;
|
|
5054
5831
|
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5832
|
+
if (rBushNode.aabb) {
|
|
5833
|
+
// save removed aabbs for dirty-rectangle rendering later
|
|
5834
|
+
_this.removedRBushNodeAABBs.push(rBushNode.aabb);
|
|
5835
|
+
}
|
|
5836
|
+
};
|
|
5060
5837
|
|
|
5061
|
-
|
|
5062
|
-
|
|
5838
|
+
renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
5839
|
+
var _this$canvasConfig, width, height, context;
|
|
5063
5840
|
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
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);
|
|
5069
5846
|
|
|
5070
|
-
|
|
5847
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.CULLED, handleCulled); // clear fullscreen
|
|
5071
5848
|
|
|
5072
5849
|
|
|
5073
|
-
|
|
5074
|
-
|
|
5850
|
+
_this$canvasConfig = _this.canvasConfig, width = _this$canvasConfig.width, height = _this$canvasConfig.height;
|
|
5851
|
+
context = _this.contextService.getContext();
|
|
5075
5852
|
|
|
5076
|
-
|
|
5853
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5077
5854
|
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5855
|
+
case 5:
|
|
5856
|
+
case "end":
|
|
5857
|
+
return _context.stop();
|
|
5858
|
+
}
|
|
5081
5859
|
}
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5087
|
-
|
|
5088
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.CULLED, handleCulled);
|
|
5089
|
-
});
|
|
5090
|
-
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
5091
|
-
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);
|
|
5092
5864
|
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
// 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();
|
|
5098
5869
|
|
|
5099
|
-
|
|
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
|
|
5100
5875
|
|
|
5101
|
-
|
|
5102
|
-
context.save();
|
|
5876
|
+
_this.clearFullScreen = _this.shouldClearFullScreen();
|
|
5103
5877
|
|
|
5104
|
-
if (
|
|
5105
|
-
|
|
5106
|
-
} // account for camera's world matrix
|
|
5878
|
+
if (context) {
|
|
5879
|
+
context.save();
|
|
5107
5880
|
|
|
5881
|
+
if (_this.clearFullScreen) {
|
|
5882
|
+
_this.clearRect(context, 0, 0, width, height);
|
|
5883
|
+
} // account for camera's world matrix
|
|
5108
5884
|
|
|
5109
|
-
_this.applyTransform(context, _this.camera.getOrthoMatrix());
|
|
5110
|
-
}
|
|
5111
|
-
}); // render at the end of frame
|
|
5112
5885
|
|
|
5113
|
-
|
|
5114
|
-
|
|
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
|
|
5115
5947
|
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
// this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
|
|
5120
|
-
_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
5121
|
-
var minX = _ref2.minX,
|
|
5122
|
-
minY = _ref2.minY,
|
|
5123
|
-
maxX = _ref2.maxX,
|
|
5124
|
-
maxY = _ref2.maxY;
|
|
5125
|
-
var aabb = new g.AABB();
|
|
5126
|
-
aabb.setMinMax(fromValues$2(minX, minY, 0), fromValues$2(maxX, maxY, 0));
|
|
5127
|
-
return aabb;
|
|
5128
|
-
})));
|
|
5948
|
+
_this.renderQueue.forEach(function (object) {
|
|
5949
|
+
_this.saveDirtyAABB(object);
|
|
5950
|
+
}); // clear queue
|
|
5129
5951
|
|
|
5130
|
-
_this.removedRBushNodeAABBs = [];
|
|
5131
5952
|
|
|
5132
|
-
if (g.AABB.isEmpty(dirtyRenderBounds)) {
|
|
5133
5953
|
_this.renderQueue = [];
|
|
5134
|
-
|
|
5135
|
-
} // clear & clip dirty rectangle
|
|
5954
|
+
} // pop restore stack, eg. root -> parent -> child
|
|
5136
5955
|
|
|
5956
|
+
_this.restoreStack.forEach(function (s) {
|
|
5957
|
+
context.restore();
|
|
5958
|
+
}); // clear restore stack
|
|
5137
5959
|
|
|
5138
|
-
var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
|
|
5139
|
-
x = _this$convertAABB2Rec.x,
|
|
5140
|
-
y = _this$convertAABB2Rec.y,
|
|
5141
|
-
width = _this$convertAABB2Rec.width,
|
|
5142
|
-
height = _this$convertAABB2Rec.height;
|
|
5143
5960
|
|
|
5144
|
-
_this.
|
|
5145
|
-
|
|
5146
|
-
context.
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
// Math.random() * 255
|
|
5153
|
-
// }, 1)`;
|
|
5154
|
-
// context.strokeRect(x, y, width, height);
|
|
5155
|
-
// }
|
|
5156
|
-
// search objects intersect with dirty rectangle
|
|
5157
|
-
|
|
5158
|
-
var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds); // do rendering
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
dirtyObjects // sort by z-index
|
|
5162
|
-
.sort(function (a, b) {
|
|
5163
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
5164
|
-
}).forEach(function (object) {
|
|
5165
|
-
// culled object should not be rendered
|
|
5166
|
-
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
|
|
5167
5969
|
_this.renderDisplayObject(object, renderingService);
|
|
5168
5970
|
}
|
|
5169
|
-
}
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5971
|
+
} else {
|
|
5972
|
+
// render at the end of frame
|
|
5973
|
+
_this.renderQueue.push(object);
|
|
5974
|
+
}
|
|
5975
|
+
});
|
|
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;
|
|
5982
|
+
|
|
5983
|
+
if (background) {
|
|
5984
|
+
context.fillStyle = background;
|
|
5985
|
+
context.fillRect(x, y, width, height);
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
}, {
|
|
5989
|
+
key: "renderDisplayObject",
|
|
5990
|
+
value: function renderDisplayObject(object, renderingService) {
|
|
5991
|
+
var context = this.contextService.getContext(); // restore to its parent
|
|
5175
5992
|
|
|
5176
|
-
|
|
5177
|
-
} // pop restore stack, eg. root -> parent -> child
|
|
5993
|
+
var parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5178
5994
|
|
|
5179
|
-
|
|
5995
|
+
while (parent && object.parentNode !== parent) {
|
|
5180
5996
|
context.restore();
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
_this.restoreStack = [];
|
|
5185
|
-
_this.clearFullScreen = false;
|
|
5186
|
-
context.restore();
|
|
5187
|
-
});
|
|
5188
|
-
renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
|
|
5189
|
-
if (_this.clearFullScreen) {
|
|
5190
|
-
if (object.isVisible() && !object.isCulled()) {
|
|
5191
|
-
// render immediately
|
|
5192
|
-
_this.renderDisplayObject(object, renderingService);
|
|
5193
|
-
}
|
|
5194
|
-
} else {
|
|
5195
|
-
// render at the end of frame
|
|
5196
|
-
_this.renderQueue.push(object);
|
|
5997
|
+
this.restoreStack.pop();
|
|
5998
|
+
parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5197
5999
|
}
|
|
5198
|
-
});
|
|
5199
|
-
};
|
|
5200
6000
|
|
|
5201
|
-
|
|
5202
|
-
context.clearRect(x, y, width, height);
|
|
5203
|
-
var background = this.canvasConfig.background;
|
|
6001
|
+
var nodeName = object.nodeName;
|
|
5204
6002
|
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
}
|
|
5209
|
-
};
|
|
6003
|
+
if (this.styleRendererFactoryCache[nodeName] === undefined) {
|
|
6004
|
+
this.styleRendererFactoryCache[nodeName] = this.styleRendererFactory(nodeName);
|
|
6005
|
+
}
|
|
5210
6006
|
|
|
5211
|
-
|
|
5212
|
-
var context = this.contextService.getContext(); // restore to its parent
|
|
6007
|
+
var styleRenderer = this.styleRendererFactoryCache[nodeName]; // reset transformation
|
|
5213
6008
|
|
|
5214
|
-
|
|
6009
|
+
context.save(); // apply RTS transformation in world space
|
|
5215
6010
|
|
|
5216
|
-
|
|
5217
|
-
context.restore();
|
|
5218
|
-
this.restoreStack.pop();
|
|
5219
|
-
parent = this.restoreStack[this.restoreStack.length - 1];
|
|
5220
|
-
}
|
|
6011
|
+
this.applyTransform(context, object.getLocalTransform()); // clip path
|
|
5221
6012
|
|
|
5222
|
-
|
|
6013
|
+
var clipPathShape = object.style.clipPath;
|
|
5223
6014
|
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
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
|
|
5227
6020
|
|
|
5228
|
-
|
|
6021
|
+
this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
|
|
5229
6022
|
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
var _object$getLocalPosit = object.getLocalPosition(),
|
|
5234
|
-
tx = _object$getLocalPosit[0],
|
|
5235
|
-
ty = _object$getLocalPosit[1];
|
|
6023
|
+
if (this.pathGeneratorFactoryCache[clipPathShape.nodeName] === undefined) {
|
|
6024
|
+
this.pathGeneratorFactoryCache[clipPathShape.nodeName] = this.pathGeneratorFactory(clipPathShape.nodeName);
|
|
6025
|
+
}
|
|
5236
6026
|
|
|
5237
|
-
|
|
5238
|
-
sx = _object$getLocalScale[0],
|
|
5239
|
-
sy = _object$getLocalScale[1];
|
|
6027
|
+
var _generatePath = this.pathGeneratorFactoryCache[clipPathShape.nodeName];
|
|
5240
6028
|
|
|
5241
|
-
|
|
6029
|
+
if (_generatePath) {
|
|
6030
|
+
this.useAnchor(context, clipPathShape);
|
|
6031
|
+
context.beginPath();
|
|
5242
6032
|
|
|
5243
|
-
|
|
5244
|
-
eux = _getEuler[0],
|
|
5245
|
-
euy = _getEuler[1],
|
|
5246
|
-
euz = _getEuler[2]; // gimbal lock at 90 degrees
|
|
6033
|
+
_generatePath(context, clipPathShape.parsedStyle);
|
|
5247
6034
|
|
|
6035
|
+
context.closePath();
|
|
6036
|
+
}
|
|
5248
6037
|
|
|
5249
|
-
|
|
5250
|
-
|
|
6038
|
+
context.restore();
|
|
6039
|
+
context.clip();
|
|
6040
|
+
} // fill & stroke
|
|
5251
6041
|
|
|
5252
|
-
context.transform(sx * cos, sy * sin, -sx * sin, sy * cos, tx, ty); // clip path
|
|
5253
6042
|
|
|
5254
|
-
|
|
6043
|
+
context.save(); // apply attributes to context
|
|
5255
6044
|
|
|
5256
|
-
|
|
5257
|
-
context.save(); // const parentTransform =
|
|
5258
|
-
// (object.parentElement as DisplayObject)?.getWorldTransform() || mat4.identity(this.tmpMat4);
|
|
5259
|
-
// mat4.multiply(this.tmpMat4, parentTransform, clipPathShape.getLocalTransform());
|
|
5260
|
-
// apply clip shape's RTS
|
|
6045
|
+
this.applyAttributesToContext(context, object); // apply anchor in local space
|
|
5261
6046
|
|
|
5262
|
-
this.
|
|
6047
|
+
this.useAnchor(context, object); // generate path in local space
|
|
5263
6048
|
|
|
5264
|
-
if (this.pathGeneratorFactoryCache[
|
|
5265
|
-
this.pathGeneratorFactoryCache[
|
|
6049
|
+
if (this.pathGeneratorFactoryCache[object.nodeName] === undefined) {
|
|
6050
|
+
this.pathGeneratorFactoryCache[object.nodeName] = this.pathGeneratorFactory(object.nodeName);
|
|
5266
6051
|
}
|
|
5267
6052
|
|
|
5268
|
-
var
|
|
6053
|
+
var generatePath = this.pathGeneratorFactoryCache[object.nodeName];
|
|
5269
6054
|
|
|
5270
|
-
if (
|
|
5271
|
-
this.useAnchor(context, clipPathShape);
|
|
6055
|
+
if (generatePath) {
|
|
5272
6056
|
context.beginPath();
|
|
6057
|
+
generatePath(context, object.parsedStyle);
|
|
5273
6058
|
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
}
|
|
5278
|
-
|
|
5279
|
-
context.restore();
|
|
5280
|
-
context.clip();
|
|
5281
|
-
} // fill & stroke
|
|
6059
|
+
if (object.nodeName !== g.Shape.LINE && object.nodeName !== g.Shape.PATH && object.nodeName !== g.Shape.POLYLINE) {
|
|
6060
|
+
context.closePath();
|
|
6061
|
+
}
|
|
6062
|
+
} // fill & stroke
|
|
5282
6063
|
|
|
5283
6064
|
|
|
5284
|
-
|
|
6065
|
+
if (styleRenderer) {
|
|
6066
|
+
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
6067
|
+
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
5285
6068
|
|
|
5286
|
-
this.applyAttributesToContext(context, object, renderingService); // apply anchor in local space
|
|
5287
6069
|
|
|
5288
|
-
|
|
6070
|
+
context.restore(); // finish rendering, clear dirty flag
|
|
5289
6071
|
|
|
5290
|
-
|
|
5291
|
-
this.
|
|
6072
|
+
object.renderable.dirty = false;
|
|
6073
|
+
this.restoreStack.push(object);
|
|
5292
6074
|
}
|
|
6075
|
+
}, {
|
|
6076
|
+
key: "shouldClearFullScreen",
|
|
6077
|
+
value: function shouldClearFullScreen() {
|
|
6078
|
+
var renderer = this.canvasConfig.renderer;
|
|
5293
6079
|
|
|
5294
|
-
|
|
6080
|
+
var _renderer$getConfig = renderer.getConfig(),
|
|
6081
|
+
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
5295
6082
|
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
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
|
|
6091
|
+
|
|
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
|
|
6131
|
+
|
|
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];
|
|
6137
|
+
|
|
6138
|
+
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
6139
|
+
_dirtyRectangle$getMa2 = _slicedToArray$3(_dirtyRectangle$getMa, 2),
|
|
6140
|
+
maxX = _dirtyRectangle$getMa2[0],
|
|
6141
|
+
maxY = _dirtyRectangle$getMa2[1];
|
|
6142
|
+
|
|
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;
|
|
5299
6158
|
|
|
5300
|
-
if (
|
|
5301
|
-
|
|
6159
|
+
if (!renderable.dirtyRenderBounds) {
|
|
6160
|
+
renderable.dirtyRenderBounds = new g.AABB();
|
|
5302
6161
|
}
|
|
5303
|
-
} // fill & stroke
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
if (styleRenderer) {
|
|
5307
|
-
styleRenderer.render(context, object.parsedStyle, object);
|
|
5308
|
-
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
context.restore(); // finish rendering, clear dirty flag
|
|
5312
|
-
|
|
5313
|
-
object.renderable.dirty = false;
|
|
5314
|
-
this.restoreStack.push(object);
|
|
5315
|
-
};
|
|
5316
|
-
|
|
5317
|
-
_proto.shouldClearFullScreen = function shouldClearFullScreen() {
|
|
5318
|
-
var renderer = this.canvasConfig.renderer;
|
|
5319
|
-
|
|
5320
|
-
var _renderer$getConfig = renderer.getConfig(),
|
|
5321
|
-
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
5322
|
-
|
|
5323
|
-
return !enableDirtyRectangleRendering || this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
|
|
5324
|
-
};
|
|
5325
|
-
|
|
5326
|
-
_proto.convertAABB2Rect = function convertAABB2Rect(aabb) {
|
|
5327
|
-
var min = aabb.getMin();
|
|
5328
|
-
var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
|
|
5329
|
-
// @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
|
|
5330
|
-
|
|
5331
|
-
var minX = Math.floor(min[0]);
|
|
5332
|
-
var minY = Math.floor(min[1]);
|
|
5333
|
-
var maxX = Math.ceil(max[0]);
|
|
5334
|
-
var maxY = Math.ceil(max[1]);
|
|
5335
|
-
var width = maxX - minX;
|
|
5336
|
-
var height = maxY - minY;
|
|
5337
|
-
return {
|
|
5338
|
-
x: minX,
|
|
5339
|
-
y: minY,
|
|
5340
|
-
width: width,
|
|
5341
|
-
height: height
|
|
5342
|
-
};
|
|
5343
|
-
}
|
|
5344
|
-
/**
|
|
5345
|
-
* TODO: merge dirty rectangles with some strategies.
|
|
5346
|
-
* For now, we just simply merge all the rectangles into one.
|
|
5347
|
-
* @see https://idom.me/articles/841.html
|
|
5348
|
-
*/
|
|
5349
|
-
;
|
|
5350
6162
|
|
|
5351
|
-
_proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
|
|
5352
|
-
// merge into a big AABB
|
|
5353
|
-
var aabb = new g.AABB();
|
|
5354
|
-
dirtyObjects.forEach(function (object) {
|
|
5355
6163
|
var renderBounds = object.getRenderBounds();
|
|
5356
|
-
aabb.add(renderBounds);
|
|
5357
|
-
var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
|
|
5358
6164
|
|
|
5359
|
-
if (
|
|
5360
|
-
aabb
|
|
6165
|
+
if (renderBounds) {
|
|
6166
|
+
// save last dirty aabb
|
|
6167
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
5361
6168
|
}
|
|
5362
|
-
});
|
|
5363
|
-
return aabb;
|
|
5364
|
-
};
|
|
5365
|
-
|
|
5366
|
-
_proto.searchDirtyObjects = function searchDirtyObjects(dirtyRectangle) {
|
|
5367
|
-
var _this2 = this; // search in r-tree, get all affected nodes
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
|
|
5371
|
-
minX = _dirtyRectangle$getMi[0],
|
|
5372
|
-
minY = _dirtyRectangle$getMi[1];
|
|
5373
|
-
|
|
5374
|
-
var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
|
|
5375
|
-
maxX = _dirtyRectangle$getMa[0],
|
|
5376
|
-
maxY = _dirtyRectangle$getMa[1];
|
|
5377
|
-
|
|
5378
|
-
var rBushNodes = this.rBush.search({
|
|
5379
|
-
minX: minX,
|
|
5380
|
-
minY: minY,
|
|
5381
|
-
maxX: maxX,
|
|
5382
|
-
maxY: maxY
|
|
5383
|
-
});
|
|
5384
|
-
return rBushNodes.map(function (_ref3) {
|
|
5385
|
-
var id = _ref3.id;
|
|
5386
|
-
return _this2.displayObjectPool.getByEntity(id);
|
|
5387
|
-
});
|
|
5388
|
-
};
|
|
5389
|
-
|
|
5390
|
-
_proto.saveDirtyAABB = function saveDirtyAABB(object) {
|
|
5391
|
-
var renderable = object.renderable;
|
|
5392
|
-
|
|
5393
|
-
if (!renderable.dirtyRenderBounds) {
|
|
5394
|
-
renderable.dirtyRenderBounds = new g.AABB();
|
|
5395
|
-
}
|
|
5396
|
-
|
|
5397
|
-
var renderBounds = object.getRenderBounds();
|
|
5398
|
-
|
|
5399
|
-
if (renderBounds) {
|
|
5400
|
-
// save last dirty aabb
|
|
5401
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
5402
6169
|
}
|
|
5403
|
-
}
|
|
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];
|
|
5404
6177
|
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
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];
|
|
5409
6182
|
|
|
5410
|
-
|
|
5411
|
-
sx = _mat4$getScaling[0],
|
|
5412
|
-
sy = _mat4$getScaling[1];
|
|
6183
|
+
var rotation = getRotation(create$4$1(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5413
6184
|
|
|
5414
|
-
|
|
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
|
|
5415
6190
|
|
|
5416
|
-
var _getEuler2 = g.getEuler(create$2$1(), rotation),
|
|
5417
|
-
eux = _getEuler2[0],
|
|
5418
|
-
euy = _getEuler2[1],
|
|
5419
|
-
euz = _getEuler2[2]; // gimbal lock at 90 degrees
|
|
5420
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
|
|
5421
6193
|
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
|
|
5425
|
-
};
|
|
5426
|
-
|
|
5427
|
-
_proto.getColor = function getColor(parsedColor, name, object, context, renderingService) {
|
|
5428
|
-
var color;
|
|
5429
|
-
|
|
5430
|
-
if (parsedColor instanceof g.CSSGradientValue) {
|
|
5431
|
-
if (parsedColor.type === g.GradientPatternType.LinearGradient || parsedColor.type === g.GradientPatternType.RadialGradient) {
|
|
5432
|
-
var bounds = object.getGeometryBounds();
|
|
5433
|
-
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
5434
|
-
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
5435
|
-
color = this.gradientPool.getOrCreateGradient(_extends({
|
|
5436
|
-
type: parsedColor.type
|
|
5437
|
-
}, parsedColor.value, {
|
|
5438
|
-
width: width,
|
|
5439
|
-
height: height
|
|
5440
|
-
}), context);
|
|
5441
|
-
} else if (parsedColor.type === g.GradientPatternType.Pattern) {
|
|
5442
|
-
var pattern = this.imagePool.getPatternSync(parsedColor.value);
|
|
5443
|
-
|
|
5444
|
-
if (pattern) {
|
|
5445
|
-
color = pattern;
|
|
5446
|
-
} else {
|
|
5447
|
-
this.imagePool.createPattern(parsedColor.value, context).then(function () {
|
|
5448
|
-
// set dirty rectangle flag
|
|
5449
|
-
object.renderable.dirty = true;
|
|
5450
|
-
renderingService.dirtify();
|
|
5451
|
-
});
|
|
5452
|
-
}
|
|
5453
|
-
}
|
|
5454
|
-
} else {
|
|
5455
|
-
// use instead of buildCSSText
|
|
5456
|
-
// constant, eg. rgba(255,255,255,1)
|
|
5457
|
-
// color = parsedColor.toString();
|
|
5458
|
-
color = object.attributes[name];
|
|
6194
|
+
context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
|
|
5459
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
|
+
}
|
|
5460
6221
|
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
_proto.applyAttributesToContext = function applyAttributesToContext(context, object, renderingService) {
|
|
5465
|
-
var _object$parsedStyle = object.parsedStyle,
|
|
5466
|
-
stroke = _object$parsedStyle.stroke,
|
|
5467
|
-
fill = _object$parsedStyle.fill,
|
|
5468
|
-
opacity = _object$parsedStyle.opacity,
|
|
5469
|
-
lineDash = _object$parsedStyle.lineDash,
|
|
5470
|
-
lineDashOffset = _object$parsedStyle.lineDashOffset,
|
|
5471
|
-
filter = _object$parsedStyle.filter,
|
|
5472
|
-
shadowColor = _object$parsedStyle.shadowColor,
|
|
5473
|
-
shadowBlur = _object$parsedStyle.shadowBlur,
|
|
5474
|
-
shadowOffsetX = _object$parsedStyle.shadowOffsetX,
|
|
5475
|
-
shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
5476
|
-
|
|
5477
|
-
if (lineDash && Array.isArray(lineDash)) {
|
|
5478
|
-
context.setLineDash(lineDash.map(function (segment) {
|
|
5479
|
-
return segment.value;
|
|
5480
|
-
}));
|
|
5481
|
-
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
if (!g.isNil(lineDashOffset)) {
|
|
5485
|
-
context.lineDashOffset = lineDashOffset.value;
|
|
5486
|
-
}
|
|
6222
|
+
if (!g.isNil(opacity)) {
|
|
6223
|
+
context.globalAlpha *= opacity.value;
|
|
6224
|
+
}
|
|
5487
6225
|
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
6226
|
+
if (!g.isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
|
|
6227
|
+
context.strokeStyle = object.attributes.stroke;
|
|
6228
|
+
}
|
|
5491
6229
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
6230
|
+
if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
|
|
6231
|
+
context.fillStyle = object.attributes.fill;
|
|
6232
|
+
}
|
|
5495
6233
|
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
6234
|
+
if (!g.isNil(filter)) {
|
|
6235
|
+
// use raw filter string
|
|
6236
|
+
context.filter = object.style.filter;
|
|
6237
|
+
}
|
|
5499
6238
|
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
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
|
+
}
|
|
5503
6245
|
}
|
|
6246
|
+
}, {
|
|
6247
|
+
key: "useAnchor",
|
|
6248
|
+
value: function useAnchor(context, object) {
|
|
6249
|
+
var _ref4 = object.parsedStyle || {},
|
|
6250
|
+
anchor = _ref4.anchor;
|
|
6251
|
+
|
|
6252
|
+
if (!anchor || anchor[0].value === 0 && anchor[1].value === 0) {
|
|
6253
|
+
return;
|
|
6254
|
+
}
|
|
5504
6255
|
|
|
5505
|
-
|
|
5506
|
-
context.shadowColor = shadowColor.toString();
|
|
5507
|
-
context.shadowBlur = shadowBlur && shadowBlur.value || 0;
|
|
5508
|
-
context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
|
|
5509
|
-
context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
|
|
5510
|
-
}
|
|
5511
|
-
};
|
|
6256
|
+
var contentBounds = object.getGeometryBounds();
|
|
5512
6257
|
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
6258
|
+
if (contentBounds) {
|
|
6259
|
+
var halfExtents = contentBounds.halfExtents; // apply anchor, use true size, not include stroke,
|
|
6260
|
+
// eg. bounds = true size + half lineWidth
|
|
5516
6261
|
|
|
5517
|
-
|
|
5518
|
-
|
|
6262
|
+
context.translate(-anchor[0].value * halfExtents[0] * 2, -anchor[1].value * halfExtents[1] * 2);
|
|
6263
|
+
}
|
|
5519
6264
|
}
|
|
6265
|
+
}, {
|
|
6266
|
+
key: "safeMergeAABB",
|
|
6267
|
+
value: function safeMergeAABB() {
|
|
6268
|
+
var merged = new g.AABB();
|
|
5520
6269
|
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
var halfExtents = contentBounds.halfExtents; // apply anchor, use true size, not include stroke,
|
|
5525
|
-
// eg. bounds = true size + half lineWidth
|
|
5526
|
-
|
|
5527
|
-
context.translate(-anchor[0].value * halfExtents[0] * 2, -anchor[1].value * halfExtents[1] * 2);
|
|
5528
|
-
}
|
|
5529
|
-
};
|
|
5530
|
-
|
|
5531
|
-
_proto.safeMergeAABB = function safeMergeAABB() {
|
|
5532
|
-
var merged = new g.AABB();
|
|
6270
|
+
for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6271
|
+
aabbs[_key] = arguments[_key];
|
|
6272
|
+
}
|
|
5533
6273
|
|
|
5534
|
-
|
|
5535
|
-
|
|
6274
|
+
aabbs.forEach(function (aabb) {
|
|
6275
|
+
merged.add(aabb);
|
|
6276
|
+
});
|
|
6277
|
+
return merged;
|
|
5536
6278
|
}
|
|
5537
|
-
|
|
5538
|
-
aabbs.forEach(function (aabb) {
|
|
5539
|
-
merged.add(aabb);
|
|
5540
|
-
});
|
|
5541
|
-
return merged;
|
|
5542
|
-
};
|
|
6279
|
+
}]);
|
|
5543
6280
|
|
|
5544
6281
|
return CanvasRendererPlugin;
|
|
5545
6282
|
}(), _class$2.tag = 'CanvasRenderer', _class$2);
|
|
@@ -5552,17 +6289,13 @@
|
|
|
5552
6289
|
|
|
5553
6290
|
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "renderingContext", void 0);
|
|
5554
6291
|
|
|
5555
|
-
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], CanvasRendererPlugin.prototype, "imagePool", void 0);
|
|
5556
|
-
|
|
5557
|
-
__decorate([g.inject(GradientPool), __metadata("design:type", GradientPool)], CanvasRendererPlugin.prototype, "gradientPool", void 0);
|
|
5558
|
-
|
|
5559
6292
|
__decorate([g.inject(PathGeneratorFactory), __metadata("design:type", Function)], CanvasRendererPlugin.prototype, "pathGeneratorFactory", void 0);
|
|
5560
6293
|
|
|
5561
6294
|
__decorate([g.inject(StyleRendererFactory), __metadata("design:type", Function)], CanvasRendererPlugin.prototype, "styleRendererFactory", void 0);
|
|
5562
6295
|
|
|
5563
6296
|
__decorate([g.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], CanvasRendererPlugin.prototype, "displayObjectPool", void 0);
|
|
5564
6297
|
|
|
5565
|
-
__decorate([g.inject(g.RBushRoot), __metadata("design:type",
|
|
6298
|
+
__decorate([g.inject(g.RBushRoot), __metadata("design:type", g.RBush)], CanvasRendererPlugin.prototype, "rBush", void 0);
|
|
5566
6299
|
|
|
5567
6300
|
CanvasRendererPlugin = CanvasRendererPlugin_1 = __decorate([g.singleton({
|
|
5568
6301
|
contrib: g.RenderingPluginContribution
|
|
@@ -5579,7 +6312,7 @@
|
|
|
5579
6312
|
register(PolylineRenderer);
|
|
5580
6313
|
register(PolygonRenderer);
|
|
5581
6314
|
register(PathRenderer);
|
|
5582
|
-
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);
|
|
5583
6316
|
register({
|
|
5584
6317
|
token: StyleRendererFactory,
|
|
5585
6318
|
useFactory: function useFactory(ctx) {
|
|
@@ -5594,28 +6327,55 @@
|
|
|
5594
6327
|
};
|
|
5595
6328
|
}
|
|
5596
6329
|
});
|
|
5597
|
-
register(GradientPool);
|
|
5598
6330
|
register(CanvasRendererPlugin);
|
|
5599
6331
|
});
|
|
5600
6332
|
|
|
5601
6333
|
var Plugin$3 = /*#__PURE__*/function () {
|
|
5602
6334
|
function Plugin() {
|
|
6335
|
+
_classCallCheck$4(this, Plugin);
|
|
6336
|
+
|
|
5603
6337
|
this.name = 'canvas-renderer';
|
|
5604
6338
|
}
|
|
5605
6339
|
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
container
|
|
5614
|
-
|
|
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
|
+
}]);
|
|
5615
6351
|
|
|
5616
6352
|
return Plugin;
|
|
5617
6353
|
}();
|
|
5618
6354
|
|
|
6355
|
+
var index_esm$3 = /*#__PURE__*/Object.freeze({
|
|
6356
|
+
__proto__: null,
|
|
6357
|
+
get CircleRenderer () { return CircleRenderer; },
|
|
6358
|
+
CircleRendererContribution: CircleRendererContribution,
|
|
6359
|
+
get EllipseRenderer () { return EllipseRenderer; },
|
|
6360
|
+
EllipseRendererContribution: EllipseRendererContribution,
|
|
6361
|
+
get ImageRenderer () { return ImageRenderer; },
|
|
6362
|
+
ImageRendererContribution: ImageRendererContribution,
|
|
6363
|
+
get LineRenderer () { return LineRenderer; },
|
|
6364
|
+
LineRendererContribution: LineRendererContribution,
|
|
6365
|
+
get PathRenderer () { return PathRenderer; },
|
|
6366
|
+
PathRendererContribution: PathRendererContribution,
|
|
6367
|
+
Plugin: Plugin$3,
|
|
6368
|
+
get PolygonRenderer () { return PolygonRenderer; },
|
|
6369
|
+
PolygonRendererContribution: PolygonRendererContribution,
|
|
6370
|
+
get PolylineRenderer () { return PolylineRenderer; },
|
|
6371
|
+
PolylineRendererContribution: PolylineRendererContribution,
|
|
6372
|
+
get RectRenderer () { return RectRenderer; },
|
|
6373
|
+
RectRendererContribution: RectRendererContribution,
|
|
6374
|
+
StyleRendererFactory: StyleRendererFactory,
|
|
6375
|
+
get TextRenderer () { return TextRenderer; },
|
|
6376
|
+
TextRendererContribution: TextRendererContribution
|
|
6377
|
+
});
|
|
6378
|
+
|
|
5619
6379
|
function _regeneratorRuntime$4() {
|
|
5620
6380
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
5621
6381
|
_regeneratorRuntime$4 = function _regeneratorRuntime() {
|
|
@@ -5741,7 +6501,7 @@
|
|
|
5741
6501
|
if ("throw" !== record.type) {
|
|
5742
6502
|
var result = record.arg,
|
|
5743
6503
|
value = result.value;
|
|
5744
|
-
return value && "object" ==
|
|
6504
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
5745
6505
|
invoke("next", value, resolve, reject);
|
|
5746
6506
|
}, function (err) {
|
|
5747
6507
|
invoke("throw", err, resolve, reject);
|
|
@@ -6002,6 +6762,31 @@
|
|
|
6002
6762
|
};
|
|
6003
6763
|
}
|
|
6004
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
|
+
|
|
6005
6790
|
var _class$3;
|
|
6006
6791
|
|
|
6007
6792
|
var DOMInteractionPlugin_1;
|
|
@@ -6011,147 +6796,150 @@
|
|
|
6011
6796
|
|
|
6012
6797
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class$3 = /*#__PURE__*/function () {
|
|
6013
6798
|
function DOMInteractionPlugin() {
|
|
6799
|
+
_classCallCheck$5(this, DOMInteractionPlugin);
|
|
6800
|
+
|
|
6014
6801
|
this.contextService = void 0;
|
|
6015
6802
|
this.renderingContext = void 0;
|
|
6016
6803
|
}
|
|
6017
6804
|
|
|
6018
|
-
|
|
6805
|
+
_createClass$5(DOMInteractionPlugin, [{
|
|
6806
|
+
key: "apply",
|
|
6807
|
+
value: function apply(renderingService) {
|
|
6808
|
+
var _this = this;
|
|
6019
6809
|
|
|
6020
|
-
|
|
6021
|
-
var _this = this;
|
|
6810
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
6022
6811
|
|
|
6023
|
-
|
|
6812
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
6813
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
6814
|
+
};
|
|
6024
6815
|
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6816
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
6817
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
6818
|
+
};
|
|
6028
6819
|
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6820
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
6821
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
6822
|
+
};
|
|
6032
6823
|
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6824
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
6825
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
6826
|
+
};
|
|
6036
6827
|
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6828
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
6829
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
6830
|
+
};
|
|
6040
6831
|
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6832
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
6833
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
6834
|
+
};
|
|
6044
6835
|
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6836
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
6837
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
6838
|
+
};
|
|
6048
6839
|
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
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
|
+
};
|
|
6052
6847
|
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
};
|
|
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
|
+
};
|
|
6060
6854
|
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
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
|
+
};
|
|
6067
6862
|
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
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
|
+
};
|
|
6075
6870
|
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
6082
|
-
};
|
|
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
|
+
};
|
|
6083
6876
|
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
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
|
+
};
|
|
6089
6884
|
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
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
|
|
6097
6892
|
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
while (1) {
|
|
6102
|
-
switch (_context.prev = _context.next) {
|
|
6103
|
-
case 0:
|
|
6104
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
6105
|
-
|
|
6106
|
-
if (globalThis.navigator.msPointerEnabled) {
|
|
6107
|
-
// @ts-ignore
|
|
6108
|
-
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
6109
|
-
|
|
6110
|
-
$el.style.msTouchAction = 'none';
|
|
6111
|
-
} else if (canvas.supportsPointerEvents) {
|
|
6112
|
-
$el.style.touchAction = 'none';
|
|
6113
|
-
}
|
|
6893
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
6894
|
+
// @ts-ignore
|
|
6895
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
6114
6896
|
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
}
|
|
6897
|
+
$el.style.msTouchAction = 'none';
|
|
6898
|
+
} else if (canvas.supportsPointerEvents) {
|
|
6899
|
+
$el.style.touchAction = 'none';
|
|
6900
|
+
}
|
|
6120
6901
|
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6902
|
+
if (canvas.supportsPointerEvents) {
|
|
6903
|
+
addPointerEventListener($el);
|
|
6904
|
+
} else {
|
|
6905
|
+
addMouseEventListener($el);
|
|
6906
|
+
}
|
|
6125
6907
|
|
|
6908
|
+
if (canvas.supportsTouchEvents) {
|
|
6909
|
+
addTouchEventListener($el);
|
|
6910
|
+
} // use passive event listeners
|
|
6911
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
6126
6912
|
|
|
6127
|
-
$el.addEventListener('wheel', onPointerWheel, {
|
|
6128
|
-
passive: true,
|
|
6129
|
-
capture: true
|
|
6130
|
-
});
|
|
6131
6913
|
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6914
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
6915
|
+
passive: true,
|
|
6916
|
+
capture: true
|
|
6917
|
+
});
|
|
6918
|
+
|
|
6919
|
+
case 5:
|
|
6920
|
+
case "end":
|
|
6921
|
+
return _context.stop();
|
|
6922
|
+
}
|
|
6135
6923
|
}
|
|
6136
|
-
}
|
|
6137
|
-
}
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
var $el = _this.contextService.getDomElement();
|
|
6924
|
+
}, _callee);
|
|
6925
|
+
})));
|
|
6926
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
6927
|
+
var $el = _this.contextService.getDomElement();
|
|
6141
6928
|
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6929
|
+
if (canvas.supportsPointerEvents) {
|
|
6930
|
+
removePointerEventListener($el);
|
|
6931
|
+
} else {
|
|
6932
|
+
removeMouseEventListener($el);
|
|
6933
|
+
}
|
|
6147
6934
|
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6935
|
+
if (canvas.supportsTouchEvents) {
|
|
6936
|
+
removeTouchEventListener($el);
|
|
6937
|
+
}
|
|
6151
6938
|
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6939
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
6940
|
+
});
|
|
6941
|
+
}
|
|
6942
|
+
}]);
|
|
6155
6943
|
|
|
6156
6944
|
return DOMInteractionPlugin;
|
|
6157
6945
|
}(), _class$3.tag = 'DOMInteraction', _class$3);
|
|
@@ -6169,22 +6957,31 @@
|
|
|
6169
6957
|
|
|
6170
6958
|
var Plugin$4 = /*#__PURE__*/function () {
|
|
6171
6959
|
function Plugin() {
|
|
6960
|
+
_classCallCheck$5(this, Plugin);
|
|
6961
|
+
|
|
6172
6962
|
this.name = 'dom-interaction';
|
|
6173
6963
|
}
|
|
6174
6964
|
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
container
|
|
6183
|
-
|
|
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
|
+
}]);
|
|
6184
6976
|
|
|
6185
6977
|
return Plugin;
|
|
6186
6978
|
}();
|
|
6187
6979
|
|
|
6980
|
+
var index_esm$4 = /*#__PURE__*/Object.freeze({
|
|
6981
|
+
__proto__: null,
|
|
6982
|
+
Plugin: Plugin$4
|
|
6983
|
+
});
|
|
6984
|
+
|
|
6188
6985
|
function _regeneratorRuntime$5() {
|
|
6189
6986
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
6190
6987
|
_regeneratorRuntime$5 = function _regeneratorRuntime() {
|
|
@@ -6310,7 +7107,7 @@
|
|
|
6310
7107
|
if ("throw" !== record.type) {
|
|
6311
7108
|
var result = record.arg,
|
|
6312
7109
|
value = result.value;
|
|
6313
|
-
return value && "object" ==
|
|
7110
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
6314
7111
|
invoke("next", value, resolve, reject);
|
|
6315
7112
|
}, function (err) {
|
|
6316
7113
|
invoke("throw", err, resolve, reject);
|
|
@@ -6571,231 +7368,271 @@
|
|
|
6571
7368
|
};
|
|
6572
7369
|
}
|
|
6573
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
|
+
|
|
6574
7396
|
var _class$4;
|
|
6575
7397
|
|
|
6576
7398
|
var HTMLRenderingPlugin_1;
|
|
6577
7399
|
var HTML_PREFIX = 'g-html-';
|
|
6578
7400
|
var HTMLRenderingPlugin = HTMLRenderingPlugin_1 = (_class$4 = /*#__PURE__*/function () {
|
|
6579
7401
|
function HTMLRenderingPlugin() {
|
|
7402
|
+
_classCallCheck$6(this, HTMLRenderingPlugin);
|
|
7403
|
+
|
|
6580
7404
|
this.contextService = void 0;
|
|
6581
7405
|
this.renderingContext = void 0;
|
|
6582
7406
|
this.canvasConfig = void 0;
|
|
6583
7407
|
this.$camera = void 0;
|
|
6584
7408
|
}
|
|
6585
7409
|
|
|
6586
|
-
|
|
7410
|
+
_createClass$6(HTMLRenderingPlugin, [{
|
|
7411
|
+
key: "apply",
|
|
7412
|
+
value: function apply(renderingService) {
|
|
7413
|
+
var _this = this;
|
|
6587
7414
|
|
|
6588
|
-
|
|
6589
|
-
|
|
7415
|
+
var handleMounted = function handleMounted(e) {
|
|
7416
|
+
var object = e.target;
|
|
6590
7417
|
|
|
6591
|
-
|
|
6592
|
-
|
|
7418
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7419
|
+
var $el = _this.getOrCreateEl(object); // apply documentElement's style
|
|
6593
7420
|
|
|
6594
|
-
if (object.nodeName === g.Shape.HTML) {
|
|
6595
|
-
var $el = _this.getOrCreateEl(object); // apply documentElement's style
|
|
6596
7421
|
|
|
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
|
+
};
|
|
6597
7431
|
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
$el.style[name] = attributes[name];
|
|
6601
|
-
});
|
|
6602
|
-
Object.keys(object.attributes).forEach(function (name) {
|
|
6603
|
-
_this.updateAttribute(name, object);
|
|
6604
|
-
});
|
|
6605
|
-
}
|
|
6606
|
-
};
|
|
6607
|
-
|
|
6608
|
-
var handleUnmounted = function handleUnmounted(e) {
|
|
6609
|
-
var object = e.target;
|
|
7432
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
7433
|
+
var object = e.target;
|
|
6610
7434
|
|
|
6611
|
-
|
|
6612
|
-
|
|
7435
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7436
|
+
var existedId = _this.getId(object);
|
|
6613
7437
|
|
|
6614
|
-
|
|
7438
|
+
var $container = _this.contextService.getDomElement().parentNode;
|
|
6615
7439
|
|
|
6616
|
-
|
|
6617
|
-
|
|
7440
|
+
if ($container) {
|
|
7441
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
6618
7442
|
|
|
6619
|
-
|
|
6620
|
-
|
|
7443
|
+
if ($existedElement) {
|
|
7444
|
+
$container.removeChild($existedElement);
|
|
7445
|
+
}
|
|
6621
7446
|
}
|
|
6622
7447
|
}
|
|
6623
|
-
}
|
|
6624
|
-
};
|
|
7448
|
+
};
|
|
6625
7449
|
|
|
6626
|
-
|
|
6627
|
-
|
|
7450
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
7451
|
+
var object = e.target;
|
|
6628
7452
|
|
|
6629
|
-
|
|
6630
|
-
|
|
7453
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
7454
|
+
var attrName = e.attrName;
|
|
6631
7455
|
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
7456
|
+
_this.updateAttribute(attrName, object);
|
|
7457
|
+
}
|
|
7458
|
+
};
|
|
6635
7459
|
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
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);
|
|
6642
7466
|
|
|
6643
|
-
|
|
7467
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
6644
7468
|
|
|
6645
|
-
|
|
7469
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6646
7470
|
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
7471
|
+
case 3:
|
|
7472
|
+
case "end":
|
|
7473
|
+
return _context.stop();
|
|
7474
|
+
}
|
|
6650
7475
|
}
|
|
6651
|
-
}
|
|
6652
|
-
}
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
6656
|
-
|
|
6657
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
6658
|
-
|
|
6659
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6660
|
-
});
|
|
6661
|
-
};
|
|
6662
|
-
|
|
6663
|
-
_proto.getId = function getId(object) {
|
|
6664
|
-
return object.id || HTML_PREFIX + object.entity;
|
|
6665
|
-
};
|
|
7476
|
+
}, _callee);
|
|
7477
|
+
})));
|
|
7478
|
+
renderingService.hooks.destroy.tap(HTMLRenderingPlugin_1.tag, function () {
|
|
7479
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
6666
7480
|
|
|
6667
|
-
|
|
6668
|
-
var doc = this.canvasConfig.document;
|
|
6669
|
-
var existedId = this.getId(object);
|
|
6670
|
-
var $container = this.contextService.getDomElement().parentNode;
|
|
7481
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
6671
7482
|
|
|
6672
|
-
|
|
6673
|
-
|
|
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;
|
|
7497
|
+
|
|
7498
|
+
if ($container) {
|
|
7499
|
+
var $existedElement = $container.querySelector('#' + existedId);
|
|
7500
|
+
|
|
7501
|
+
if (!$existedElement) {
|
|
7502
|
+
$existedElement = (doc || document).createElement('div');
|
|
7503
|
+
object.parsedStyle.$el = $existedElement;
|
|
7504
|
+
$existedElement.id = existedId;
|
|
7505
|
+
|
|
7506
|
+
if (object.name) {
|
|
7507
|
+
$existedElement.setAttribute('name', object.name);
|
|
7508
|
+
}
|
|
6674
7509
|
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
$existedElement.id = existedId;
|
|
7510
|
+
if (object.className) {
|
|
7511
|
+
$existedElement.className = object.className;
|
|
7512
|
+
}
|
|
6679
7513
|
|
|
6680
|
-
|
|
6681
|
-
$existedElement.setAttribute('name', object.name);
|
|
6682
|
-
}
|
|
7514
|
+
$container.appendChild($existedElement); // use absolute position
|
|
6683
7515
|
|
|
6684
|
-
|
|
6685
|
-
$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(','), ")");
|
|
6686
7522
|
}
|
|
6687
7523
|
|
|
6688
|
-
$
|
|
6689
|
-
|
|
6690
|
-
$existedElement.style.position = 'absolute';
|
|
6691
|
-
$existedElement.style.left = '0';
|
|
6692
|
-
$existedElement.style.top = '0';
|
|
6693
|
-
$existedElement.style['will-change'] = 'transform';
|
|
6694
|
-
var worldTransform = object.getWorldTransform();
|
|
6695
|
-
$existedElement.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
7524
|
+
return $existedElement;
|
|
6696
7525
|
}
|
|
6697
7526
|
|
|
6698
|
-
return
|
|
7527
|
+
return null;
|
|
6699
7528
|
}
|
|
7529
|
+
}, {
|
|
7530
|
+
key: "updateAttribute",
|
|
7531
|
+
value: function updateAttribute(name, object) {
|
|
7532
|
+
var $el = this.getOrCreateEl(object);
|
|
6700
7533
|
|
|
6701
|
-
|
|
6702
|
-
|
|
7534
|
+
switch (name) {
|
|
7535
|
+
case 'innerHTML':
|
|
7536
|
+
var innerHTML = object.parsedStyle.innerHTML;
|
|
6703
7537
|
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
7538
|
+
if (g.isString(innerHTML)) {
|
|
7539
|
+
$el.innerHTML = innerHTML;
|
|
7540
|
+
} else {
|
|
7541
|
+
$el.innerHTML = '';
|
|
7542
|
+
$el.appendChild(innerHTML);
|
|
7543
|
+
}
|
|
6710
7544
|
|
|
6711
|
-
|
|
6712
|
-
$el.innerHTML = innerHTML;
|
|
6713
|
-
} else {
|
|
6714
|
-
$el.innerHTML = '';
|
|
6715
|
-
$el.appendChild(innerHTML);
|
|
6716
|
-
}
|
|
7545
|
+
break;
|
|
6717
7546
|
|
|
6718
|
-
|
|
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;
|
|
6719
7554
|
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
var worldTransform = object.getWorldTransform();
|
|
6725
|
-
$el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
6726
|
-
break;
|
|
7555
|
+
case 'width':
|
|
7556
|
+
var width = object.computedStyleMap().get('width');
|
|
7557
|
+
$el.style.width = width.toString();
|
|
7558
|
+
break;
|
|
6727
7559
|
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
7560
|
+
case 'height':
|
|
7561
|
+
var height = object.computedStyleMap().get('height');
|
|
7562
|
+
$el.style.height = height.toString();
|
|
7563
|
+
break;
|
|
6732
7564
|
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
7565
|
+
case 'zIndex':
|
|
7566
|
+
var zIndex = object.parsedStyle.zIndex;
|
|
7567
|
+
$el.style['z-index'] = "".concat(zIndex.value);
|
|
7568
|
+
break;
|
|
6737
7569
|
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
7570
|
+
case 'visibility':
|
|
7571
|
+
var visibility = object.parsedStyle.visibility;
|
|
7572
|
+
$el.style.visibility = visibility.value;
|
|
7573
|
+
break;
|
|
6742
7574
|
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
7575
|
+
case 'pointerEvents':
|
|
7576
|
+
var pointerEvents = object.parsedStyle.pointerEvents;
|
|
7577
|
+
$el.style.pointerEvents = pointerEvents.value;
|
|
7578
|
+
break;
|
|
6747
7579
|
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
7580
|
+
case 'opacity':
|
|
7581
|
+
var opacity = object.parsedStyle.opacity;
|
|
7582
|
+
$el.style.opacity = "".concat(opacity.value);
|
|
7583
|
+
break;
|
|
6752
7584
|
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
break;
|
|
7585
|
+
case 'fill':
|
|
7586
|
+
var fill = object.parsedStyle.fill;
|
|
7587
|
+
var color = '';
|
|
6757
7588
|
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
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)) {
|
|
7596
|
+
color = object.getAttribute('fill');
|
|
7597
|
+
} else if (g.isPattern(fill)) ;
|
|
6761
7598
|
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
} else if (fill instanceof g.CSSGradientValue) {
|
|
6765
|
-
if (fill.type === g.GradientPatternType.LinearGradient) {
|
|
6766
|
-
var steps = fill.value.steps.map(function (cur) {
|
|
6767
|
-
// ['0', '#ffffff'],
|
|
6768
|
-
return cur[1] + " " + Number(cur[0]) * 100 + "%";
|
|
6769
|
-
}).join(','); // @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient()
|
|
7599
|
+
$el.style.background = color;
|
|
7600
|
+
break;
|
|
6770
7601
|
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
7602
|
+
case 'stroke':
|
|
7603
|
+
var stroke = object.parsedStyle.stroke;
|
|
7604
|
+
var borderColor = '';
|
|
6774
7605
|
|
|
6775
|
-
|
|
6776
|
-
|
|
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)) {
|
|
7613
|
+
borderColor = object.getAttribute('stroke');
|
|
7614
|
+
} else if (g.isPattern(stroke)) ;
|
|
6777
7615
|
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
$el.style['border-style'] = 'solid';
|
|
6782
|
-
break;
|
|
7616
|
+
$el.style['border-color'] = borderColor;
|
|
7617
|
+
$el.style['border-style'] = 'solid';
|
|
7618
|
+
break;
|
|
6783
7619
|
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
7620
|
+
case 'lineWidth':
|
|
7621
|
+
var lineWidth = object.parsedStyle.lineWidth;
|
|
7622
|
+
$el.style['border-width'] = "".concat(lineWidth.value || 0, "px");
|
|
7623
|
+
break;
|
|
6788
7624
|
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
7625
|
+
case 'lineDash':
|
|
7626
|
+
$el.style['border-style'] = 'dashed';
|
|
7627
|
+
break;
|
|
6792
7628
|
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
7629
|
+
case 'filter':
|
|
7630
|
+
var filter = object.parsedStyle.filter;
|
|
7631
|
+
$el.style.filter = filter;
|
|
7632
|
+
break;
|
|
7633
|
+
}
|
|
6797
7634
|
}
|
|
6798
|
-
};
|
|
7635
|
+
}]);
|
|
6799
7636
|
|
|
6800
7637
|
return HTMLRenderingPlugin;
|
|
6801
7638
|
}(), _class$4.tag = 'HTMLRendering', _class$4);
|
|
@@ -6815,24 +7652,35 @@
|
|
|
6815
7652
|
|
|
6816
7653
|
var Plugin$5 = /*#__PURE__*/function () {
|
|
6817
7654
|
function Plugin() {
|
|
7655
|
+
_classCallCheck$6(this, Plugin);
|
|
7656
|
+
|
|
6818
7657
|
this.name = 'html-renderer';
|
|
6819
7658
|
}
|
|
6820
7659
|
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
container
|
|
6829
|
-
|
|
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
|
+
}]);
|
|
6830
7671
|
|
|
6831
7672
|
return Plugin;
|
|
6832
7673
|
}();
|
|
6833
7674
|
|
|
7675
|
+
var index_esm$5 = /*#__PURE__*/Object.freeze({
|
|
7676
|
+
__proto__: null,
|
|
7677
|
+
Plugin: Plugin$5
|
|
7678
|
+
});
|
|
7679
|
+
|
|
6834
7680
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
6835
7681
|
function Canvas2DContextService() {
|
|
7682
|
+
_classCallCheck(this, Canvas2DContextService);
|
|
7683
|
+
|
|
6836
7684
|
this.$container = void 0;
|
|
6837
7685
|
this.$canvas = void 0;
|
|
6838
7686
|
this.dpr = void 0;
|
|
@@ -6840,112 +7688,120 @@
|
|
|
6840
7688
|
this.canvasConfig = void 0;
|
|
6841
7689
|
}
|
|
6842
7690
|
|
|
6843
|
-
|
|
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;
|
|
6844
7696
|
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
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;
|
|
6848
7702
|
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
switch (_context.prev = _context.next) {
|
|
6852
|
-
case 0:
|
|
6853
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
7703
|
+
if (canvas) {
|
|
7704
|
+
this.$canvas = canvas;
|
|
6854
7705
|
|
|
6855
|
-
|
|
6856
|
-
|
|
7706
|
+
if (container && canvas.parentElement !== container) {
|
|
7707
|
+
container.appendChild(canvas);
|
|
7708
|
+
}
|
|
6857
7709
|
|
|
6858
|
-
|
|
6859
|
-
container
|
|
6860
|
-
}
|
|
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;
|
|
6861
7715
|
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
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);
|
|
6867
7720
|
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
this.$container.appendChild($canvas);
|
|
7721
|
+
if (!this.$container.style.position) {
|
|
7722
|
+
this.$container.style.position = 'relative';
|
|
7723
|
+
}
|
|
6872
7724
|
|
|
6873
|
-
|
|
6874
|
-
this.$container.style.position = 'relative';
|
|
7725
|
+
this.$canvas = $canvas;
|
|
6875
7726
|
}
|
|
6876
|
-
|
|
6877
|
-
this.$canvas = $canvas;
|
|
6878
7727
|
}
|
|
6879
|
-
}
|
|
6880
7728
|
|
|
6881
|
-
|
|
7729
|
+
this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
|
|
6882
7730
|
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
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);
|
|
6887
7735
|
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
7736
|
+
case 7:
|
|
7737
|
+
case "end":
|
|
7738
|
+
return _context.stop();
|
|
7739
|
+
}
|
|
6891
7740
|
}
|
|
6892
|
-
}
|
|
6893
|
-
}
|
|
6894
|
-
}));
|
|
6895
|
-
|
|
6896
|
-
function init() {
|
|
6897
|
-
return _init.apply(this, arguments);
|
|
6898
|
-
}
|
|
6899
|
-
|
|
6900
|
-
return init;
|
|
6901
|
-
}();
|
|
6902
|
-
|
|
6903
|
-
_proto.getContext = function getContext() {
|
|
6904
|
-
return this.context;
|
|
6905
|
-
};
|
|
6906
|
-
|
|
6907
|
-
_proto.getDomElement = function getDomElement() {
|
|
6908
|
-
return this.$canvas;
|
|
6909
|
-
};
|
|
7741
|
+
}, _callee, this);
|
|
7742
|
+
}));
|
|
6910
7743
|
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
7744
|
+
function init() {
|
|
7745
|
+
return _init.apply(this, arguments);
|
|
7746
|
+
}
|
|
6914
7747
|
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
7748
|
+
return init;
|
|
7749
|
+
}()
|
|
7750
|
+
}, {
|
|
7751
|
+
key: "getContext",
|
|
7752
|
+
value: function getContext() {
|
|
7753
|
+
return this.context;
|
|
6918
7754
|
}
|
|
6919
|
-
}
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
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
|
+
}
|
|
7771
|
+
}
|
|
7772
|
+
}, {
|
|
7773
|
+
key: "destroy",
|
|
7774
|
+
value: function destroy() {
|
|
6925
7775
|
// @ts-ignore
|
|
6926
|
-
this.$container
|
|
7776
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
7777
|
+
// destroy context
|
|
7778
|
+
// @ts-ignore
|
|
7779
|
+
this.$container.removeChild(this.$canvas);
|
|
7780
|
+
}
|
|
6927
7781
|
}
|
|
6928
|
-
}
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
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
|
|
7789
|
+
|
|
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/
|
|
7793
|
+
|
|
7794
|
+
this.context.scale(dpr, dpr);
|
|
7795
|
+
}
|
|
6941
7796
|
}
|
|
6942
|
-
}
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
7797
|
+
}, {
|
|
7798
|
+
key: "applyCursorStyle",
|
|
7799
|
+
value: function applyCursorStyle(cursor) {
|
|
7800
|
+
if (this.$container && this.$container.style) {
|
|
7801
|
+
this.$container.style.cursor = cursor;
|
|
7802
|
+
}
|
|
6947
7803
|
}
|
|
6948
|
-
};
|
|
7804
|
+
}]);
|
|
6949
7805
|
|
|
6950
7806
|
return Canvas2DContextService;
|
|
6951
7807
|
}();
|
|
@@ -6964,29 +7820,37 @@
|
|
|
6964
7820
|
});
|
|
6965
7821
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
6966
7822
|
function ContextRegisterPlugin() {
|
|
7823
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
7824
|
+
|
|
6967
7825
|
this.name = 'canvas-context-register';
|
|
6968
7826
|
}
|
|
6969
7827
|
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
container
|
|
6978
|
-
|
|
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
|
+
}]);
|
|
6979
7839
|
|
|
6980
7840
|
return ContextRegisterPlugin;
|
|
6981
7841
|
}();
|
|
6982
7842
|
|
|
6983
7843
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
6984
|
-
|
|
7844
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
7845
|
+
|
|
7846
|
+
var _super = _createSuper(Renderer);
|
|
6985
7847
|
|
|
6986
7848
|
function Renderer(config) {
|
|
6987
7849
|
var _this;
|
|
6988
7850
|
|
|
6989
|
-
|
|
7851
|
+
_classCallCheck(this, Renderer);
|
|
7852
|
+
|
|
7853
|
+
_this = _super.call(this, config); // register Canvas2DContext
|
|
6990
7854
|
|
|
6991
7855
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
6992
7856
|
|
|
@@ -7008,9 +7872,15 @@
|
|
|
7008
7872
|
return _this;
|
|
7009
7873
|
}
|
|
7010
7874
|
|
|
7011
|
-
return Renderer;
|
|
7875
|
+
return _createClass(Renderer);
|
|
7012
7876
|
}(g.AbstractRenderer);
|
|
7013
7877
|
|
|
7878
|
+
exports.CanvasPathGenerator = index_esm;
|
|
7879
|
+
exports.CanvasPicker = index_esm$1;
|
|
7880
|
+
exports.CanvasRenderer = index_esm$3;
|
|
7881
|
+
exports.DomInteraction = index_esm$4;
|
|
7882
|
+
exports.HTMLRenderer = index_esm$5;
|
|
7883
|
+
exports.ImageLoader = index_esm$2;
|
|
7014
7884
|
exports.Renderer = Renderer;
|
|
7015
7885
|
|
|
7016
7886
|
Object.defineProperty(exports, '__esModule', { value: true });
|