@antv/g-canvas 1.1.8-alpha.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Canvas2DContextService.d.ts.map +1 -1
- package/dist/ContextRegisterPlugin.d.ts +1 -2
- package/dist/ContextRegisterPlugin.d.ts.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +13 -2
- package/dist/index.js +36 -4
- package/dist/index.umd.js +400 -316
- package/dist/index.umd.min.js +7 -7
- package/package.json +9 -10
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@antv/g'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Canvas2D = {}), global.window.G
|
|
5
|
-
}(this, (function (exports, g
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@antv/g'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Canvas2D = {}), global.window.G));
|
|
5
|
+
}(this, (function (exports, g) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _regeneratorRuntime() {
|
|
8
8
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -401,8 +401,8 @@
|
|
|
401
401
|
return _setPrototypeOf(o, p);
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
var PathGeneratorFactory =
|
|
405
|
-
var PathGenerator =
|
|
404
|
+
var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
|
|
405
|
+
var PathGenerator = g.Syringe.defineToken('PathGenerator');
|
|
406
406
|
|
|
407
407
|
function generatePath(context, parsedStyle) {
|
|
408
408
|
var r = parsedStyle.r;
|
|
@@ -528,44 +528,49 @@
|
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
if (!hasRadius) {
|
|
531
|
+
// Canvas support negative width/height of rect
|
|
531
532
|
context.rect(0, 0, w, h);
|
|
532
533
|
} else {
|
|
534
|
+
var signX = width.value > 0 ? 1 : -1;
|
|
535
|
+
var signY = height.value > 0 ? 1 : -1;
|
|
536
|
+
var sweepFlag = signX + signY === 0;
|
|
537
|
+
|
|
533
538
|
var _radius$map = radius.map(function (r) {
|
|
534
|
-
return r.value;
|
|
539
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
|
|
535
540
|
}),
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
541
|
+
tlr = _radius$map[0],
|
|
542
|
+
trr = _radius$map[1],
|
|
543
|
+
brr = _radius$map[2],
|
|
544
|
+
blr = _radius$map[3];
|
|
540
545
|
|
|
541
|
-
context.moveTo(
|
|
542
|
-
context.lineTo(w -
|
|
546
|
+
context.moveTo(signX * tlr, 0);
|
|
547
|
+
context.lineTo(w - signX * trr, 0);
|
|
543
548
|
|
|
544
|
-
if (
|
|
545
|
-
context.arc(w -
|
|
549
|
+
if (trr !== 0) {
|
|
550
|
+
context.arc(w - signX * trr, signY * trr, trr, -signY * Math.PI / 2, signX > 0 ? 0 : Math.PI, sweepFlag);
|
|
546
551
|
}
|
|
547
552
|
|
|
548
|
-
context.lineTo(w, h -
|
|
553
|
+
context.lineTo(w, h - signY * brr);
|
|
549
554
|
|
|
550
|
-
if (
|
|
551
|
-
context.arc(w -
|
|
555
|
+
if (brr !== 0) {
|
|
556
|
+
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
557
|
}
|
|
553
558
|
|
|
554
|
-
context.lineTo(
|
|
559
|
+
context.lineTo(signX * blr, h);
|
|
555
560
|
|
|
556
|
-
if (
|
|
557
|
-
context.arc(
|
|
561
|
+
if (blr !== 0) {
|
|
562
|
+
context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag);
|
|
558
563
|
}
|
|
559
564
|
|
|
560
|
-
context.lineTo(0,
|
|
565
|
+
context.lineTo(0, signY * tlr);
|
|
561
566
|
|
|
562
|
-
if (
|
|
563
|
-
context.arc(
|
|
567
|
+
if (tlr !== 0) {
|
|
568
|
+
context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag);
|
|
564
569
|
}
|
|
565
570
|
}
|
|
566
571
|
}
|
|
567
572
|
|
|
568
|
-
var containerModule =
|
|
573
|
+
var containerModule = g.Module(function (register) {
|
|
569
574
|
/**
|
|
570
575
|
* register shape renderers
|
|
571
576
|
*/
|
|
@@ -650,6 +655,13 @@
|
|
|
650
655
|
return Plugin;
|
|
651
656
|
}();
|
|
652
657
|
|
|
658
|
+
var index_esm = /*#__PURE__*/Object.freeze({
|
|
659
|
+
__proto__: null,
|
|
660
|
+
PathGenerator: PathGenerator,
|
|
661
|
+
PathGeneratorFactory: PathGeneratorFactory,
|
|
662
|
+
Plugin: Plugin
|
|
663
|
+
});
|
|
664
|
+
|
|
653
665
|
/******************************************************************************
|
|
654
666
|
Copyright (c) Microsoft Corporation.
|
|
655
667
|
|
|
@@ -1643,7 +1655,7 @@
|
|
|
1643
1655
|
var _class;
|
|
1644
1656
|
|
|
1645
1657
|
var CanvasPickerPlugin_1;
|
|
1646
|
-
var PointInPathPickerFactory =
|
|
1658
|
+
var PointInPathPickerFactory = g.Syringe.defineToken('PointInPathPicker');
|
|
1647
1659
|
/**
|
|
1648
1660
|
* pick shape(s) with Mouse/Touch event
|
|
1649
1661
|
*
|
|
@@ -1811,19 +1823,19 @@
|
|
|
1811
1823
|
return CanvasPickerPlugin;
|
|
1812
1824
|
}(), _class.tag = 'CanvasPicker', _class);
|
|
1813
1825
|
|
|
1814
|
-
__decorate([
|
|
1826
|
+
__decorate([g.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], CanvasPickerPlugin.prototype, "displayObjectPool", void 0);
|
|
1815
1827
|
|
|
1816
|
-
__decorate([
|
|
1828
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], CanvasPickerPlugin.prototype, "canvasConfig", void 0);
|
|
1817
1829
|
|
|
1818
|
-
__decorate([
|
|
1830
|
+
__decorate([g.inject(g.OffscreenCanvasCreator), __metadata("design:type", g.OffscreenCanvasCreator)], CanvasPickerPlugin.prototype, "offscreenCanvas", void 0);
|
|
1819
1831
|
|
|
1820
|
-
__decorate([
|
|
1832
|
+
__decorate([g.inject(g.RBushRoot), __metadata("design:type", g.RBush)], CanvasPickerPlugin.prototype, "rBush", void 0);
|
|
1821
1833
|
|
|
1822
|
-
__decorate([
|
|
1834
|
+
__decorate([g.inject(PathGeneratorFactory), __metadata("design:type", Function)], CanvasPickerPlugin.prototype, "pathGeneratorFactory", void 0);
|
|
1823
1835
|
|
|
1824
|
-
__decorate([
|
|
1836
|
+
__decorate([g.inject(PointInPathPickerFactory), __metadata("design:type", Function)], CanvasPickerPlugin.prototype, "pointInPathPickerFactory", void 0);
|
|
1825
1837
|
|
|
1826
|
-
CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([
|
|
1838
|
+
CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([g.singleton({
|
|
1827
1839
|
contrib: g.RenderingPluginContribution
|
|
1828
1840
|
})], CanvasPickerPlugin);
|
|
1829
1841
|
/**
|
|
@@ -2517,27 +2529,6 @@
|
|
|
2517
2529
|
return inLine(x1.value, y1.value, x2.value, y2.value, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y);
|
|
2518
2530
|
}
|
|
2519
2531
|
|
|
2520
|
-
function isPointInPath$3(displayObject, position) {
|
|
2521
|
-
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2522
|
-
stroke = _displayObject$parsed.stroke,
|
|
2523
|
-
lineWidth = _displayObject$parsed.lineWidth,
|
|
2524
|
-
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
2525
|
-
points = _displayObject$parsed.points,
|
|
2526
|
-
_displayObject$parsed2 = _displayObject$parsed.defX,
|
|
2527
|
-
x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
|
|
2528
|
-
_displayObject$parsed3 = _displayObject$parsed.defY,
|
|
2529
|
-
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3,
|
|
2530
|
-
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
2531
|
-
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
2532
|
-
var hasStroke = stroke && !stroke.isNone;
|
|
2533
|
-
|
|
2534
|
-
if (!hasStroke && !isClipPath || !lineWidth) {
|
|
2535
|
-
return false;
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
return inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, false);
|
|
2539
|
-
}
|
|
2540
|
-
|
|
2541
2532
|
function isPointInStroke(segments, lineWidth, px, py, length, x, y) {
|
|
2542
2533
|
var isHit = false;
|
|
2543
2534
|
var halfWidth = lineWidth / 2;
|
|
@@ -2611,7 +2602,7 @@
|
|
|
2611
2602
|
return isHit;
|
|
2612
2603
|
}
|
|
2613
2604
|
|
|
2614
|
-
function isPointInPath$
|
|
2605
|
+
function isPointInPath$3(displayObject, position, isPointInPath) {
|
|
2615
2606
|
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2616
2607
|
lineWidth = _displayObject$parsed.lineWidth,
|
|
2617
2608
|
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
@@ -2650,7 +2641,56 @@
|
|
|
2650
2641
|
return isHit;
|
|
2651
2642
|
}
|
|
2652
2643
|
|
|
2653
|
-
function isPointInPath$
|
|
2644
|
+
function isPointInPath$4(displayObject, position) {
|
|
2645
|
+
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2646
|
+
stroke = _displayObject$parsed.stroke,
|
|
2647
|
+
fill = _displayObject$parsed.fill,
|
|
2648
|
+
lineWidth = _displayObject$parsed.lineWidth,
|
|
2649
|
+
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
2650
|
+
points = _displayObject$parsed.points,
|
|
2651
|
+
_displayObject$parsed2 = _displayObject$parsed.defX,
|
|
2652
|
+
x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
|
|
2653
|
+
_displayObject$parsed3 = _displayObject$parsed.defY,
|
|
2654
|
+
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3,
|
|
2655
|
+
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
2656
|
+
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
2657
|
+
var hasFill = fill && !fill.isNone;
|
|
2658
|
+
var hasStroke = stroke && !stroke.isNone;
|
|
2659
|
+
var isHit = false;
|
|
2660
|
+
|
|
2661
|
+
if (hasStroke || isClipPath) {
|
|
2662
|
+
isHit = inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, true);
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
if (!isHit && (hasFill || isClipPath)) {
|
|
2666
|
+
isHit = inPolygon(points.points, position.x + x, position.y + y);
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
return isHit;
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
function isPointInPath$5(displayObject, position) {
|
|
2673
|
+
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2674
|
+
stroke = _displayObject$parsed.stroke,
|
|
2675
|
+
lineWidth = _displayObject$parsed.lineWidth,
|
|
2676
|
+
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
2677
|
+
points = _displayObject$parsed.points,
|
|
2678
|
+
_displayObject$parsed2 = _displayObject$parsed.defX,
|
|
2679
|
+
x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
|
|
2680
|
+
_displayObject$parsed3 = _displayObject$parsed.defY,
|
|
2681
|
+
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3,
|
|
2682
|
+
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
2683
|
+
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
2684
|
+
var hasStroke = stroke && !stroke.isNone;
|
|
2685
|
+
|
|
2686
|
+
if (!hasStroke && !isClipPath || !lineWidth) {
|
|
2687
|
+
return false;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
return inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, false);
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
function isPointInPath$6(displayObject, position, isPointInPath) {
|
|
2654
2694
|
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2655
2695
|
radius = _displayObject$parsed.radius,
|
|
2656
2696
|
fill = _displayObject$parsed.fill,
|
|
@@ -2703,7 +2743,7 @@
|
|
|
2703
2743
|
|
|
2704
2744
|
if (hasStroke || isClipPath) {
|
|
2705
2745
|
isHit = inRectWithRadius(0, 0, width, height, radius.map(function (r) {
|
|
2706
|
-
return r.value;
|
|
2746
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
|
|
2707
2747
|
}), lineWidthForHitTesting, position.x, position.y);
|
|
2708
2748
|
} // 仅填充时带有圆角的矩形直接通过图形拾取
|
|
2709
2749
|
// 以后可以改成纯数学的近似拾取,将圆弧切割成多边形
|
|
@@ -2727,35 +2767,7 @@
|
|
|
2727
2767
|
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);
|
|
2728
2768
|
}
|
|
2729
2769
|
|
|
2730
|
-
|
|
2731
|
-
var _displayObject$parsed = displayObject.parsedStyle,
|
|
2732
|
-
stroke = _displayObject$parsed.stroke,
|
|
2733
|
-
fill = _displayObject$parsed.fill,
|
|
2734
|
-
lineWidth = _displayObject$parsed.lineWidth,
|
|
2735
|
-
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
2736
|
-
points = _displayObject$parsed.points,
|
|
2737
|
-
_displayObject$parsed2 = _displayObject$parsed.defX,
|
|
2738
|
-
x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
|
|
2739
|
-
_displayObject$parsed3 = _displayObject$parsed.defY,
|
|
2740
|
-
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3,
|
|
2741
|
-
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
2742
|
-
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
2743
|
-
var hasFill = fill && !fill.isNone;
|
|
2744
|
-
var hasStroke = stroke && !stroke.isNone;
|
|
2745
|
-
var isHit = false;
|
|
2746
|
-
|
|
2747
|
-
if (hasStroke || isClipPath) {
|
|
2748
|
-
isHit = inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, true);
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
if (!isHit && (hasFill || isClipPath)) {
|
|
2752
|
-
isHit = inPolygon(points.points, position.x + x, position.y + y);
|
|
2753
|
-
}
|
|
2754
|
-
|
|
2755
|
-
return isHit;
|
|
2756
|
-
}
|
|
2757
|
-
|
|
2758
|
-
var containerModule$1 = manaSyringe.Module(function (register) {
|
|
2770
|
+
var containerModule$1 = g.Module(function (register) {
|
|
2759
2771
|
register({
|
|
2760
2772
|
token: PointInPathPickerFactory,
|
|
2761
2773
|
useFactory: function useFactory(context) {
|
|
@@ -2765,15 +2777,15 @@
|
|
|
2765
2777
|
} else if (tagName === g.Shape.ELLIPSE) {
|
|
2766
2778
|
return isPointInPath$1;
|
|
2767
2779
|
} else if (tagName === g.Shape.RECT) {
|
|
2768
|
-
return isPointInPath$
|
|
2780
|
+
return isPointInPath$6;
|
|
2769
2781
|
} else if (tagName === g.Shape.LINE) {
|
|
2770
2782
|
return isPointInPath$2;
|
|
2771
2783
|
} else if (tagName === g.Shape.POLYLINE) {
|
|
2772
|
-
return isPointInPath$
|
|
2784
|
+
return isPointInPath$5;
|
|
2773
2785
|
} else if (tagName === g.Shape.POLYGON) {
|
|
2774
|
-
return isPointInPath$6;
|
|
2775
|
-
} else if (tagName === g.Shape.PATH) {
|
|
2776
2786
|
return isPointInPath$4;
|
|
2787
|
+
} else if (tagName === g.Shape.PATH) {
|
|
2788
|
+
return isPointInPath$3;
|
|
2777
2789
|
} else if (tagName === g.Shape.IMAGE || tagName === g.Shape.TEXT // tagName === Shape.GROUP
|
|
2778
2790
|
) {
|
|
2779
2791
|
return function () {
|
|
@@ -2806,16 +2818,30 @@
|
|
|
2806
2818
|
return Plugin;
|
|
2807
2819
|
}();
|
|
2808
2820
|
|
|
2821
|
+
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
2822
|
+
__proto__: null,
|
|
2823
|
+
Plugin: Plugin$1
|
|
2824
|
+
});
|
|
2825
|
+
|
|
2809
2826
|
var ImagePool = /*#__PURE__*/function () {
|
|
2810
2827
|
function ImagePool() {
|
|
2811
2828
|
this.imageCache = {};
|
|
2829
|
+
this.gradientCache = {};
|
|
2812
2830
|
this.patternCache = {};
|
|
2813
2831
|
this.canvasConfig = void 0;
|
|
2814
2832
|
}
|
|
2815
2833
|
|
|
2816
2834
|
var _proto = ImagePool.prototype;
|
|
2817
2835
|
|
|
2818
|
-
_proto.getImageSync = function getImageSync(src) {
|
|
2836
|
+
_proto.getImageSync = function getImageSync(src, callback) {
|
|
2837
|
+
if (!this.imageCache[src]) {
|
|
2838
|
+
this.getOrCreateImage(src).then(function () {
|
|
2839
|
+
if (callback) {
|
|
2840
|
+
callback();
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2819
2845
|
return this.imageCache[src];
|
|
2820
2846
|
};
|
|
2821
2847
|
|
|
@@ -2853,43 +2879,112 @@
|
|
|
2853
2879
|
});
|
|
2854
2880
|
};
|
|
2855
2881
|
|
|
2856
|
-
_proto.
|
|
2882
|
+
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
|
|
2857
2883
|
var patternKey = this.generatePatternKey(pattern);
|
|
2858
2884
|
|
|
2859
|
-
if (this.patternCache[patternKey]) {
|
|
2885
|
+
if (patternKey && this.patternCache[patternKey]) {
|
|
2860
2886
|
return this.patternCache[patternKey];
|
|
2861
2887
|
}
|
|
2888
|
+
|
|
2889
|
+
var image = pattern.image,
|
|
2890
|
+
repetition = pattern.repetition;
|
|
2891
|
+
var src; // Image URL
|
|
2892
|
+
|
|
2893
|
+
if (g.isString(image)) {
|
|
2894
|
+
src = this.getImageSync(image, callback);
|
|
2895
|
+
} else {
|
|
2896
|
+
src = image;
|
|
2897
|
+
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2898
|
+
|
|
2899
|
+
|
|
2900
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
2901
|
+
|
|
2902
|
+
if (patternKey && canvasPattern) {
|
|
2903
|
+
this.patternCache[patternKey] = canvasPattern;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
return canvasPattern;
|
|
2862
2907
|
};
|
|
2863
2908
|
|
|
2864
|
-
_proto.
|
|
2865
|
-
var
|
|
2909
|
+
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
2910
|
+
var key = this.generateGradientKey(params); // @ts-ignore
|
|
2866
2911
|
|
|
2867
|
-
|
|
2868
|
-
|
|
2912
|
+
var type = params.type,
|
|
2913
|
+
steps = params.steps,
|
|
2914
|
+
width = params.width,
|
|
2915
|
+
height = params.height,
|
|
2916
|
+
angle = params.angle,
|
|
2917
|
+
cx = params.cx,
|
|
2918
|
+
cy = params.cy;
|
|
2869
2919
|
|
|
2920
|
+
if (this.gradientCache[key]) {
|
|
2921
|
+
return this.gradientCache[key];
|
|
2922
|
+
}
|
|
2870
2923
|
|
|
2871
|
-
|
|
2924
|
+
var gradient = null;
|
|
2872
2925
|
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2926
|
+
if (type === g.GradientType.LinearGradient) {
|
|
2927
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
2928
|
+
x1 = _computeLinearGradien.x1,
|
|
2929
|
+
y1 = _computeLinearGradien.y1,
|
|
2930
|
+
x2 = _computeLinearGradien.x2,
|
|
2931
|
+
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
2876
2932
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2933
|
+
|
|
2934
|
+
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
2935
|
+
} else if (type === g.GradientType.RadialGradient) {
|
|
2936
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
2937
|
+
x = _computeRadialGradien.x,
|
|
2938
|
+
y = _computeRadialGradien.y,
|
|
2939
|
+
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2940
|
+
|
|
2941
|
+
|
|
2942
|
+
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
if (gradient) {
|
|
2946
|
+
steps.forEach(function (_ref) {
|
|
2947
|
+
var _gradient;
|
|
2948
|
+
|
|
2949
|
+
var offset = _ref[0],
|
|
2950
|
+
color = _ref[1];
|
|
2951
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
2952
|
+
});
|
|
2953
|
+
this.gradientCache[key] = gradient;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
return this.gradientCache[key];
|
|
2957
|
+
};
|
|
2958
|
+
|
|
2959
|
+
_proto.generateGradientKey = function generateGradientKey(params) {
|
|
2960
|
+
// @ts-ignore
|
|
2961
|
+
var type = params.type,
|
|
2962
|
+
width = params.width,
|
|
2963
|
+
height = params.height,
|
|
2964
|
+
steps = params.steps,
|
|
2965
|
+
angle = params.angle,
|
|
2966
|
+
cx = params.cx,
|
|
2967
|
+
cy = params.cy;
|
|
2968
|
+
return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
2969
|
+
return step.join('');
|
|
2970
|
+
}).join('-');
|
|
2879
2971
|
};
|
|
2880
2972
|
|
|
2881
2973
|
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2882
|
-
var
|
|
2883
|
-
repetition = pattern.repetition;
|
|
2884
|
-
|
|
2974
|
+
var image = pattern.image,
|
|
2975
|
+
repetition = pattern.repetition; // only generate cache for Image
|
|
2976
|
+
|
|
2977
|
+
if (g.isString(image)) {
|
|
2978
|
+
return "pattern-" + image + "-" + repetition;
|
|
2979
|
+
}
|
|
2885
2980
|
};
|
|
2886
2981
|
|
|
2887
2982
|
return ImagePool;
|
|
2888
2983
|
}();
|
|
2889
2984
|
|
|
2890
|
-
__decorate([
|
|
2985
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
2891
2986
|
|
|
2892
|
-
ImagePool = __decorate([
|
|
2987
|
+
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
2893
2988
|
|
|
2894
2989
|
function _regeneratorRuntime$2() {
|
|
2895
2990
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -3300,7 +3395,7 @@
|
|
|
3300
3395
|
var img = attributes.img;
|
|
3301
3396
|
|
|
3302
3397
|
if (g.isString(img)) {
|
|
3303
|
-
_this.imagePool.
|
|
3398
|
+
_this.imagePool.getImageSync(img, function () {
|
|
3304
3399
|
// set dirty rectangle flag
|
|
3305
3400
|
object.renderable.dirty = true;
|
|
3306
3401
|
renderingService.dirtify();
|
|
@@ -3353,14 +3448,14 @@
|
|
|
3353
3448
|
return LoadImagePlugin;
|
|
3354
3449
|
}(), _class$1.tag = 'LoadImage', _class$1);
|
|
3355
3450
|
|
|
3356
|
-
__decorate([
|
|
3451
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], LoadImagePlugin.prototype, "imagePool", void 0);
|
|
3357
3452
|
|
|
3358
|
-
__decorate([
|
|
3453
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], LoadImagePlugin.prototype, "renderingContext", void 0);
|
|
3359
3454
|
|
|
3360
|
-
LoadImagePlugin = LoadImagePlugin_1 = __decorate([
|
|
3455
|
+
LoadImagePlugin = LoadImagePlugin_1 = __decorate([g.singleton({
|
|
3361
3456
|
contrib: g.RenderingPluginContribution
|
|
3362
3457
|
})], LoadImagePlugin);
|
|
3363
|
-
var containerModule$2 =
|
|
3458
|
+
var containerModule$2 = g.Module(function (register) {
|
|
3364
3459
|
register(ImagePool);
|
|
3365
3460
|
register(LoadImagePlugin);
|
|
3366
3461
|
});
|
|
@@ -3383,6 +3478,12 @@
|
|
|
3383
3478
|
return Plugin;
|
|
3384
3479
|
}();
|
|
3385
3480
|
|
|
3481
|
+
var index_esm$2 = /*#__PURE__*/Object.freeze({
|
|
3482
|
+
__proto__: null,
|
|
3483
|
+
get ImagePool () { return ImagePool; },
|
|
3484
|
+
Plugin: Plugin$2
|
|
3485
|
+
});
|
|
3486
|
+
|
|
3386
3487
|
function _regeneratorRuntime$3() {
|
|
3387
3488
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3388
3489
|
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
@@ -4497,99 +4598,32 @@
|
|
|
4497
4598
|
};
|
|
4498
4599
|
}();
|
|
4499
4600
|
|
|
4500
|
-
var
|
|
4501
|
-
|
|
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([manaSyringe.singleton()], GradientPool);
|
|
4567
|
-
var StyleRendererFactory = manaSyringe.Syringe.defineToken('StyleRendererFactory');
|
|
4568
|
-
var CircleRendererContribution = manaSyringe.Syringe.defineToken('CircleRenderer', {
|
|
4601
|
+
var StyleRendererFactory = g.Syringe.defineToken('StyleRendererFactory');
|
|
4602
|
+
var CircleRendererContribution = g.Syringe.defineToken('CircleRenderer', {
|
|
4569
4603
|
multiple: false
|
|
4570
4604
|
});
|
|
4571
|
-
var EllipseRendererContribution =
|
|
4605
|
+
var EllipseRendererContribution = g.Syringe.defineToken('EllipseRenderer', {
|
|
4572
4606
|
multiple: false
|
|
4573
4607
|
});
|
|
4574
|
-
var RectRendererContribution =
|
|
4608
|
+
var RectRendererContribution = g.Syringe.defineToken('RectRenderer', {
|
|
4575
4609
|
multiple: false
|
|
4576
4610
|
});
|
|
4577
|
-
var LineRendererContribution =
|
|
4611
|
+
var LineRendererContribution = g.Syringe.defineToken('LineRenderer', {
|
|
4578
4612
|
multiple: false
|
|
4579
4613
|
});
|
|
4580
|
-
var PolylineRendererContribution =
|
|
4614
|
+
var PolylineRendererContribution = g.Syringe.defineToken('PolylineRenderer', {
|
|
4581
4615
|
multiple: false
|
|
4582
4616
|
});
|
|
4583
|
-
var PolygonRendererContribution =
|
|
4617
|
+
var PolygonRendererContribution = g.Syringe.defineToken('PolygonRenderer', {
|
|
4584
4618
|
multiple: false
|
|
4585
4619
|
});
|
|
4586
|
-
var PathRendererContribution =
|
|
4620
|
+
var PathRendererContribution = g.Syringe.defineToken('PathRenderer', {
|
|
4587
4621
|
multiple: false
|
|
4588
4622
|
});
|
|
4589
|
-
var TextRendererContribution =
|
|
4623
|
+
var TextRendererContribution = g.Syringe.defineToken('TextRenderer', {
|
|
4590
4624
|
multiple: false
|
|
4591
4625
|
});
|
|
4592
|
-
var ImageRendererContribution =
|
|
4626
|
+
var ImageRendererContribution = g.Syringe.defineToken('ImageRenderer', {
|
|
4593
4627
|
multiple: false
|
|
4594
4628
|
});
|
|
4595
4629
|
|
|
@@ -4629,9 +4663,9 @@
|
|
|
4629
4663
|
return ImageRenderer;
|
|
4630
4664
|
}();
|
|
4631
4665
|
|
|
4632
|
-
__decorate([
|
|
4666
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], ImageRenderer.prototype, "imagePool", void 0);
|
|
4633
4667
|
|
|
4634
|
-
ImageRenderer = __decorate([
|
|
4668
|
+
ImageRenderer = __decorate([g.singleton({
|
|
4635
4669
|
token: ImageRendererContribution
|
|
4636
4670
|
})], ImageRenderer);
|
|
4637
4671
|
|
|
@@ -4788,16 +4822,18 @@
|
|
|
4788
4822
|
return TextRenderer;
|
|
4789
4823
|
}();
|
|
4790
4824
|
|
|
4791
|
-
TextRenderer = __decorate([
|
|
4825
|
+
TextRenderer = __decorate([g.singleton({
|
|
4792
4826
|
token: TextRendererContribution
|
|
4793
4827
|
})], TextRenderer);
|
|
4794
4828
|
|
|
4795
4829
|
var DefaultRenderer = /*#__PURE__*/function () {
|
|
4796
|
-
function DefaultRenderer() {
|
|
4830
|
+
function DefaultRenderer() {
|
|
4831
|
+
this.imagePool = void 0;
|
|
4832
|
+
}
|
|
4797
4833
|
|
|
4798
4834
|
var _proto = DefaultRenderer.prototype;
|
|
4799
4835
|
|
|
4800
|
-
_proto.render = function render(context, parsedStyle) {
|
|
4836
|
+
_proto.render = function render(context, parsedStyle, object, renderingService) {
|
|
4801
4837
|
var fill = parsedStyle.fill,
|
|
4802
4838
|
opacity = parsedStyle.opacity,
|
|
4803
4839
|
fillOpacity = parsedStyle.fillOpacity,
|
|
@@ -4816,10 +4852,10 @@
|
|
|
4816
4852
|
if (hasFill) {
|
|
4817
4853
|
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
4818
4854
|
context.globalAlpha = fillOpacity.value;
|
|
4819
|
-
|
|
4855
|
+
this.fill(context, object, fill, renderingService);
|
|
4820
4856
|
context.globalAlpha = opacity.value;
|
|
4821
4857
|
} else {
|
|
4822
|
-
|
|
4858
|
+
this.fill(context, object, fill, renderingService);
|
|
4823
4859
|
}
|
|
4824
4860
|
}
|
|
4825
4861
|
|
|
@@ -4875,7 +4911,7 @@
|
|
|
4875
4911
|
var drawStroke = hasFill && !isFillTransparent;
|
|
4876
4912
|
|
|
4877
4913
|
if (drawStroke) {
|
|
4878
|
-
|
|
4914
|
+
this.stroke(context, object, stroke, renderingService);
|
|
4879
4915
|
} // restore shadow blur
|
|
4880
4916
|
|
|
4881
4917
|
|
|
@@ -4890,16 +4926,79 @@
|
|
|
4890
4926
|
}
|
|
4891
4927
|
|
|
4892
4928
|
if (!drawStroke) {
|
|
4893
|
-
|
|
4929
|
+
this.stroke(context, object, stroke, renderingService);
|
|
4894
4930
|
}
|
|
4895
4931
|
}
|
|
4896
4932
|
}
|
|
4897
4933
|
};
|
|
4898
4934
|
|
|
4935
|
+
_proto.fill = function fill(context, object, _fill, renderingService) {
|
|
4936
|
+
var _this = this;
|
|
4937
|
+
|
|
4938
|
+
if (Array.isArray(_fill)) {
|
|
4939
|
+
_fill.forEach(function (gradient) {
|
|
4940
|
+
context.fillStyle = _this.getColor(gradient, object, context);
|
|
4941
|
+
context.fill();
|
|
4942
|
+
});
|
|
4943
|
+
} else {
|
|
4944
|
+
if (g.isPattern(_fill)) {
|
|
4945
|
+
context.fillStyle = this.getPattern(_fill, object, context, renderingService);
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
context.fill();
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4951
|
+
|
|
4952
|
+
_proto.stroke = function stroke(context, object, _stroke, renderingService) {
|
|
4953
|
+
var _this2 = this;
|
|
4954
|
+
|
|
4955
|
+
if (Array.isArray(_stroke)) {
|
|
4956
|
+
_stroke.forEach(function (gradient) {
|
|
4957
|
+
context.strokeStyle = _this2.getColor(gradient, object, context);
|
|
4958
|
+
context.stroke();
|
|
4959
|
+
});
|
|
4960
|
+
} else {
|
|
4961
|
+
if (g.isPattern(_stroke)) {
|
|
4962
|
+
context.strokeStyle = this.getPattern(_stroke, object, context, renderingService);
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
context.stroke();
|
|
4966
|
+
}
|
|
4967
|
+
};
|
|
4968
|
+
|
|
4969
|
+
_proto.getPattern = function getPattern(pattern, object, context, renderingService) {
|
|
4970
|
+
var canvasPattern = this.imagePool.getOrCreatePatternSync(pattern, context, function () {
|
|
4971
|
+
// set dirty rectangle flag
|
|
4972
|
+
object.renderable.dirty = true;
|
|
4973
|
+
renderingService.dirtify();
|
|
4974
|
+
});
|
|
4975
|
+
return canvasPattern;
|
|
4976
|
+
};
|
|
4977
|
+
|
|
4978
|
+
_proto.getColor = function getColor(parsedColor, object, context) {
|
|
4979
|
+
var color;
|
|
4980
|
+
|
|
4981
|
+
if (parsedColor.type === g.GradientType.LinearGradient || parsedColor.type === g.GradientType.RadialGradient) {
|
|
4982
|
+
var bounds = object.getGeometryBounds();
|
|
4983
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 1;
|
|
4984
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 1;
|
|
4985
|
+
color = this.imagePool.getOrCreateGradient(_extends({
|
|
4986
|
+
type: parsedColor.type
|
|
4987
|
+
}, parsedColor.value, {
|
|
4988
|
+
width: width,
|
|
4989
|
+
height: height
|
|
4990
|
+
}), context);
|
|
4991
|
+
}
|
|
4992
|
+
|
|
4993
|
+
return color;
|
|
4994
|
+
};
|
|
4995
|
+
|
|
4899
4996
|
return DefaultRenderer;
|
|
4900
4997
|
}();
|
|
4901
4998
|
|
|
4902
|
-
|
|
4999
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], DefaultRenderer.prototype, "imagePool", void 0);
|
|
5000
|
+
|
|
5001
|
+
DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
|
|
4903
5002
|
|
|
4904
5003
|
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
4905
5004
|
_inheritsLoose$1(RectRenderer, _DefaultRenderer);
|
|
@@ -4911,7 +5010,7 @@
|
|
|
4911
5010
|
return RectRenderer;
|
|
4912
5011
|
}(DefaultRenderer);
|
|
4913
5012
|
|
|
4914
|
-
RectRenderer = __decorate([
|
|
5013
|
+
RectRenderer = __decorate([g.singleton({
|
|
4915
5014
|
token: RectRendererContribution
|
|
4916
5015
|
})], RectRenderer);
|
|
4917
5016
|
|
|
@@ -4925,7 +5024,7 @@
|
|
|
4925
5024
|
return CircleRenderer;
|
|
4926
5025
|
}(DefaultRenderer);
|
|
4927
5026
|
|
|
4928
|
-
CircleRenderer = __decorate([
|
|
5027
|
+
CircleRenderer = __decorate([g.singleton({
|
|
4929
5028
|
token: CircleRendererContribution
|
|
4930
5029
|
})], CircleRenderer);
|
|
4931
5030
|
|
|
@@ -4939,7 +5038,7 @@
|
|
|
4939
5038
|
return EllipseRenderer;
|
|
4940
5039
|
}(DefaultRenderer);
|
|
4941
5040
|
|
|
4942
|
-
EllipseRenderer = __decorate([
|
|
5041
|
+
EllipseRenderer = __decorate([g.singleton({
|
|
4943
5042
|
token: EllipseRendererContribution
|
|
4944
5043
|
})], EllipseRenderer);
|
|
4945
5044
|
|
|
@@ -4953,7 +5052,7 @@
|
|
|
4953
5052
|
return LineRenderer;
|
|
4954
5053
|
}(DefaultRenderer);
|
|
4955
5054
|
|
|
4956
|
-
LineRenderer = __decorate([
|
|
5055
|
+
LineRenderer = __decorate([g.singleton({
|
|
4957
5056
|
token: LineRendererContribution
|
|
4958
5057
|
})], LineRenderer);
|
|
4959
5058
|
|
|
@@ -4967,7 +5066,7 @@
|
|
|
4967
5066
|
return PolylineRenderer;
|
|
4968
5067
|
}(DefaultRenderer);
|
|
4969
5068
|
|
|
4970
|
-
PolylineRenderer = __decorate([
|
|
5069
|
+
PolylineRenderer = __decorate([g.singleton({
|
|
4971
5070
|
token: PolylineRendererContribution
|
|
4972
5071
|
})], PolylineRenderer);
|
|
4973
5072
|
|
|
@@ -4981,7 +5080,7 @@
|
|
|
4981
5080
|
return PolygonRenderer;
|
|
4982
5081
|
}(DefaultRenderer);
|
|
4983
5082
|
|
|
4984
|
-
PolygonRenderer = __decorate([
|
|
5083
|
+
PolygonRenderer = __decorate([g.singleton({
|
|
4985
5084
|
token: PolygonRendererContribution
|
|
4986
5085
|
})], PolygonRenderer);
|
|
4987
5086
|
|
|
@@ -4995,7 +5094,7 @@
|
|
|
4995
5094
|
return PathRenderer;
|
|
4996
5095
|
}(DefaultRenderer);
|
|
4997
5096
|
|
|
4998
|
-
PathRenderer = __decorate([
|
|
5097
|
+
PathRenderer = __decorate([g.singleton({
|
|
4999
5098
|
token: PathRendererContribution
|
|
5000
5099
|
})], PathRenderer);
|
|
5001
5100
|
|
|
@@ -5014,8 +5113,6 @@
|
|
|
5014
5113
|
this.camera = void 0;
|
|
5015
5114
|
this.contextService = void 0;
|
|
5016
5115
|
this.renderingContext = void 0;
|
|
5017
|
-
this.imagePool = void 0;
|
|
5018
|
-
this.gradientPool = void 0;
|
|
5019
5116
|
this.pathGeneratorFactory = void 0;
|
|
5020
5117
|
this.pathGeneratorFactoryCache = {};
|
|
5021
5118
|
this.styleRendererFactory = void 0;
|
|
@@ -5228,28 +5325,8 @@
|
|
|
5228
5325
|
var styleRenderer = this.styleRendererFactoryCache[nodeName]; // reset transformation
|
|
5229
5326
|
|
|
5230
5327
|
context.save(); // apply RTS transformation in world space
|
|
5231
|
-
// this.applyTransform(context, object.getWorldTransform());
|
|
5232
|
-
|
|
5233
|
-
var _object$getLocalPosit = object.getLocalPosition(),
|
|
5234
|
-
tx = _object$getLocalPosit[0],
|
|
5235
|
-
ty = _object$getLocalPosit[1];
|
|
5236
|
-
|
|
5237
|
-
var _object$getLocalScale = object.getLocalScale(),
|
|
5238
|
-
sx = _object$getLocalScale[0],
|
|
5239
|
-
sy = _object$getLocalScale[1];
|
|
5240
|
-
|
|
5241
|
-
var rotation = object.getLocalRotation(); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5242
|
-
|
|
5243
|
-
var _getEuler = g.getEuler(this.tmpVec3, rotation),
|
|
5244
|
-
eux = _getEuler[0],
|
|
5245
|
-
euy = _getEuler[1],
|
|
5246
|
-
euz = _getEuler[2]; // gimbal lock at 90 degrees
|
|
5247
5328
|
|
|
5248
|
-
|
|
5249
|
-
var cos = Math.cos(eux || euz);
|
|
5250
|
-
var sin = Math.sin(eux || euz); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
5251
|
-
|
|
5252
|
-
context.transform(sx * cos, sy * sin, -sx * sin, sy * cos, tx, ty); // clip path
|
|
5329
|
+
this.applyTransform(context, object.getLocalTransform()); // clip path
|
|
5253
5330
|
|
|
5254
5331
|
var clipPathShape = object.style.clipPath;
|
|
5255
5332
|
|
|
@@ -5283,7 +5360,7 @@
|
|
|
5283
5360
|
|
|
5284
5361
|
context.save(); // apply attributes to context
|
|
5285
5362
|
|
|
5286
|
-
this.applyAttributesToContext(context, object
|
|
5363
|
+
this.applyAttributesToContext(context, object); // apply anchor in local space
|
|
5287
5364
|
|
|
5288
5365
|
this.useAnchor(context, object); // generate path in local space
|
|
5289
5366
|
|
|
@@ -5304,7 +5381,7 @@
|
|
|
5304
5381
|
|
|
5305
5382
|
|
|
5306
5383
|
if (styleRenderer) {
|
|
5307
|
-
styleRenderer.render(context, object.parsedStyle, object);
|
|
5384
|
+
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
5308
5385
|
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
5309
5386
|
|
|
5310
5387
|
|
|
@@ -5413,10 +5490,10 @@
|
|
|
5413
5490
|
|
|
5414
5491
|
var rotation = getRotation(create$4$1(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5415
5492
|
|
|
5416
|
-
var
|
|
5417
|
-
eux =
|
|
5418
|
-
euy =
|
|
5419
|
-
euz =
|
|
5493
|
+
var _getEuler = g.getEuler(create$2$1(), rotation),
|
|
5494
|
+
eux = _getEuler[0],
|
|
5495
|
+
euy = _getEuler[1],
|
|
5496
|
+
euz = _getEuler[2]; // gimbal lock at 90 degrees
|
|
5420
5497
|
|
|
5421
5498
|
|
|
5422
5499
|
var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
@@ -5424,44 +5501,7 @@
|
|
|
5424
5501
|
context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
|
|
5425
5502
|
};
|
|
5426
5503
|
|
|
5427
|
-
_proto.
|
|
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];
|
|
5459
|
-
}
|
|
5460
|
-
|
|
5461
|
-
return color;
|
|
5462
|
-
};
|
|
5463
|
-
|
|
5464
|
-
_proto.applyAttributesToContext = function applyAttributesToContext(context, object, renderingService) {
|
|
5504
|
+
_proto.applyAttributesToContext = function applyAttributesToContext(context, object) {
|
|
5465
5505
|
var _object$parsedStyle = object.parsedStyle,
|
|
5466
5506
|
stroke = _object$parsedStyle.stroke,
|
|
5467
5507
|
fill = _object$parsedStyle.fill,
|
|
@@ -5489,12 +5529,12 @@
|
|
|
5489
5529
|
context.globalAlpha *= opacity.value;
|
|
5490
5530
|
}
|
|
5491
5531
|
|
|
5492
|
-
if (!g.isNil(stroke) && !stroke.isNone) {
|
|
5493
|
-
context.strokeStyle =
|
|
5532
|
+
if (!g.isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
|
|
5533
|
+
context.strokeStyle = object.attributes.stroke;
|
|
5494
5534
|
}
|
|
5495
5535
|
|
|
5496
|
-
if (!g.isNil(fill) && !fill.isNone) {
|
|
5497
|
-
context.fillStyle =
|
|
5536
|
+
if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
|
|
5537
|
+
context.fillStyle = object.attributes.fill;
|
|
5498
5538
|
}
|
|
5499
5539
|
|
|
5500
5540
|
if (!g.isNil(filter)) {
|
|
@@ -5544,30 +5584,26 @@
|
|
|
5544
5584
|
return CanvasRendererPlugin;
|
|
5545
5585
|
}(), _class$2.tag = 'CanvasRenderer', _class$2);
|
|
5546
5586
|
|
|
5547
|
-
__decorate([
|
|
5548
|
-
|
|
5549
|
-
__decorate([manaSyringe.inject(g.DefaultCamera), __metadata("design:type", g.Camera)], CanvasRendererPlugin.prototype, "camera", void 0);
|
|
5550
|
-
|
|
5551
|
-
__decorate([manaSyringe.inject(g.ContextService), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "contextService", void 0);
|
|
5587
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "canvasConfig", void 0);
|
|
5552
5588
|
|
|
5553
|
-
__decorate([
|
|
5589
|
+
__decorate([g.inject(g.DefaultCamera), __metadata("design:type", g.Camera)], CanvasRendererPlugin.prototype, "camera", void 0);
|
|
5554
5590
|
|
|
5555
|
-
__decorate([
|
|
5591
|
+
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "contextService", void 0);
|
|
5556
5592
|
|
|
5557
|
-
__decorate([
|
|
5593
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "renderingContext", void 0);
|
|
5558
5594
|
|
|
5559
|
-
__decorate([
|
|
5595
|
+
__decorate([g.inject(PathGeneratorFactory), __metadata("design:type", Function)], CanvasRendererPlugin.prototype, "pathGeneratorFactory", void 0);
|
|
5560
5596
|
|
|
5561
|
-
__decorate([
|
|
5597
|
+
__decorate([g.inject(StyleRendererFactory), __metadata("design:type", Function)], CanvasRendererPlugin.prototype, "styleRendererFactory", void 0);
|
|
5562
5598
|
|
|
5563
|
-
__decorate([
|
|
5599
|
+
__decorate([g.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], CanvasRendererPlugin.prototype, "displayObjectPool", void 0);
|
|
5564
5600
|
|
|
5565
|
-
__decorate([
|
|
5601
|
+
__decorate([g.inject(g.RBushRoot), __metadata("design:type", g.RBush)], CanvasRendererPlugin.prototype, "rBush", void 0);
|
|
5566
5602
|
|
|
5567
|
-
CanvasRendererPlugin = CanvasRendererPlugin_1 = __decorate([
|
|
5603
|
+
CanvasRendererPlugin = CanvasRendererPlugin_1 = __decorate([g.singleton({
|
|
5568
5604
|
contrib: g.RenderingPluginContribution
|
|
5569
5605
|
})], CanvasRendererPlugin);
|
|
5570
|
-
var containerModule$3 =
|
|
5606
|
+
var containerModule$3 = g.Module(function (register) {
|
|
5571
5607
|
var _shape2Token;
|
|
5572
5608
|
|
|
5573
5609
|
register(CircleRenderer);
|
|
@@ -5594,7 +5630,6 @@
|
|
|
5594
5630
|
};
|
|
5595
5631
|
}
|
|
5596
5632
|
});
|
|
5597
|
-
register(GradientPool);
|
|
5598
5633
|
register(CanvasRendererPlugin);
|
|
5599
5634
|
});
|
|
5600
5635
|
|
|
@@ -5616,6 +5651,30 @@
|
|
|
5616
5651
|
return Plugin;
|
|
5617
5652
|
}();
|
|
5618
5653
|
|
|
5654
|
+
var index_esm$3 = /*#__PURE__*/Object.freeze({
|
|
5655
|
+
__proto__: null,
|
|
5656
|
+
get CircleRenderer () { return CircleRenderer; },
|
|
5657
|
+
CircleRendererContribution: CircleRendererContribution,
|
|
5658
|
+
get EllipseRenderer () { return EllipseRenderer; },
|
|
5659
|
+
EllipseRendererContribution: EllipseRendererContribution,
|
|
5660
|
+
get ImageRenderer () { return ImageRenderer; },
|
|
5661
|
+
ImageRendererContribution: ImageRendererContribution,
|
|
5662
|
+
get LineRenderer () { return LineRenderer; },
|
|
5663
|
+
LineRendererContribution: LineRendererContribution,
|
|
5664
|
+
get PathRenderer () { return PathRenderer; },
|
|
5665
|
+
PathRendererContribution: PathRendererContribution,
|
|
5666
|
+
Plugin: Plugin$3,
|
|
5667
|
+
get PolygonRenderer () { return PolygonRenderer; },
|
|
5668
|
+
PolygonRendererContribution: PolygonRendererContribution,
|
|
5669
|
+
get PolylineRenderer () { return PolylineRenderer; },
|
|
5670
|
+
PolylineRendererContribution: PolylineRendererContribution,
|
|
5671
|
+
get RectRenderer () { return RectRenderer; },
|
|
5672
|
+
RectRendererContribution: RectRendererContribution,
|
|
5673
|
+
StyleRendererFactory: StyleRendererFactory,
|
|
5674
|
+
get TextRenderer () { return TextRenderer; },
|
|
5675
|
+
TextRendererContribution: TextRendererContribution
|
|
5676
|
+
});
|
|
5677
|
+
|
|
5619
5678
|
function _regeneratorRuntime$4() {
|
|
5620
5679
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
5621
5680
|
_regeneratorRuntime$4 = function _regeneratorRuntime() {
|
|
@@ -6156,14 +6215,14 @@
|
|
|
6156
6215
|
return DOMInteractionPlugin;
|
|
6157
6216
|
}(), _class$3.tag = 'DOMInteraction', _class$3);
|
|
6158
6217
|
|
|
6159
|
-
__decorate([
|
|
6218
|
+
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], DOMInteractionPlugin.prototype, "contextService", void 0);
|
|
6160
6219
|
|
|
6161
|
-
__decorate([
|
|
6220
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], DOMInteractionPlugin.prototype, "renderingContext", void 0);
|
|
6162
6221
|
|
|
6163
|
-
DOMInteractionPlugin = DOMInteractionPlugin_1 = __decorate([
|
|
6222
|
+
DOMInteractionPlugin = DOMInteractionPlugin_1 = __decorate([g.singleton({
|
|
6164
6223
|
contrib: g.RenderingPluginContribution
|
|
6165
6224
|
})], DOMInteractionPlugin);
|
|
6166
|
-
var containerModule$4 =
|
|
6225
|
+
var containerModule$4 = g.Module(function (register) {
|
|
6167
6226
|
register(DOMInteractionPlugin);
|
|
6168
6227
|
});
|
|
6169
6228
|
|
|
@@ -6185,6 +6244,11 @@
|
|
|
6185
6244
|
return Plugin;
|
|
6186
6245
|
}();
|
|
6187
6246
|
|
|
6247
|
+
var index_esm$4 = /*#__PURE__*/Object.freeze({
|
|
6248
|
+
__proto__: null,
|
|
6249
|
+
Plugin: Plugin$4
|
|
6250
|
+
});
|
|
6251
|
+
|
|
6188
6252
|
function _regeneratorRuntime$5() {
|
|
6189
6253
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
6190
6254
|
_regeneratorRuntime$5 = function _regeneratorRuntime() {
|
|
@@ -6760,24 +6824,33 @@
|
|
|
6760
6824
|
var color = '';
|
|
6761
6825
|
|
|
6762
6826
|
if (fill instanceof g.CSSRGB) {
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
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()
|
|
6770
|
-
|
|
6771
|
-
color = "linear-gradient(to right, " + steps + ");";
|
|
6827
|
+
if (fill.isNone) {
|
|
6828
|
+
color = 'transparent';
|
|
6829
|
+
} else {
|
|
6830
|
+
color = object.getAttribute('fill');
|
|
6772
6831
|
}
|
|
6773
|
-
}
|
|
6832
|
+
} else if (Array.isArray(fill)) {
|
|
6833
|
+
color = object.getAttribute('fill');
|
|
6834
|
+
} else if (g.isPattern(fill)) ;
|
|
6774
6835
|
|
|
6775
6836
|
$el.style.background = color;
|
|
6776
6837
|
break;
|
|
6777
6838
|
|
|
6778
6839
|
case 'stroke':
|
|
6779
6840
|
var stroke = object.parsedStyle.stroke;
|
|
6780
|
-
|
|
6841
|
+
var borderColor = '';
|
|
6842
|
+
|
|
6843
|
+
if (stroke instanceof g.CSSRGB) {
|
|
6844
|
+
if (stroke.isNone) {
|
|
6845
|
+
borderColor = 'transparent';
|
|
6846
|
+
} else {
|
|
6847
|
+
borderColor = object.getAttribute('stroke');
|
|
6848
|
+
}
|
|
6849
|
+
} else if (Array.isArray(stroke)) {
|
|
6850
|
+
borderColor = object.getAttribute('stroke');
|
|
6851
|
+
} else if (g.isPattern(stroke)) ;
|
|
6852
|
+
|
|
6853
|
+
$el.style['border-color'] = borderColor;
|
|
6781
6854
|
$el.style['border-style'] = 'solid';
|
|
6782
6855
|
break;
|
|
6783
6856
|
|
|
@@ -6800,16 +6873,16 @@
|
|
|
6800
6873
|
return HTMLRenderingPlugin;
|
|
6801
6874
|
}(), _class$4.tag = 'HTMLRendering', _class$4);
|
|
6802
6875
|
|
|
6803
|
-
__decorate([
|
|
6876
|
+
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "contextService", void 0);
|
|
6804
6877
|
|
|
6805
|
-
__decorate([
|
|
6878
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "renderingContext", void 0);
|
|
6806
6879
|
|
|
6807
|
-
__decorate([
|
|
6880
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "canvasConfig", void 0);
|
|
6808
6881
|
|
|
6809
|
-
HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([
|
|
6882
|
+
HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([g.singleton({
|
|
6810
6883
|
contrib: g.RenderingPluginContribution
|
|
6811
6884
|
})], HTMLRenderingPlugin);
|
|
6812
|
-
var containerModule$5 =
|
|
6885
|
+
var containerModule$5 = g.Module(function (register) {
|
|
6813
6886
|
register(HTMLRenderingPlugin);
|
|
6814
6887
|
});
|
|
6815
6888
|
|
|
@@ -6831,6 +6904,11 @@
|
|
|
6831
6904
|
return Plugin;
|
|
6832
6905
|
}();
|
|
6833
6906
|
|
|
6907
|
+
var index_esm$5 = /*#__PURE__*/Object.freeze({
|
|
6908
|
+
__proto__: null,
|
|
6909
|
+
Plugin: Plugin$5
|
|
6910
|
+
});
|
|
6911
|
+
|
|
6834
6912
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
6835
6913
|
function Canvas2DContextService() {
|
|
6836
6914
|
this.$container = void 0;
|
|
@@ -6950,13 +7028,13 @@
|
|
|
6950
7028
|
return Canvas2DContextService;
|
|
6951
7029
|
}();
|
|
6952
7030
|
|
|
6953
|
-
__decorate([
|
|
7031
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], Canvas2DContextService.prototype, "canvasConfig", void 0);
|
|
6954
7032
|
|
|
6955
|
-
Canvas2DContextService = __decorate([
|
|
7033
|
+
Canvas2DContextService = __decorate([g.singleton({
|
|
6956
7034
|
token: g.ContextService
|
|
6957
7035
|
})], Canvas2DContextService);
|
|
6958
7036
|
|
|
6959
|
-
var containerModule$6 =
|
|
7037
|
+
var containerModule$6 = g.Module(function (register) {
|
|
6960
7038
|
/**
|
|
6961
7039
|
* implements ContextService
|
|
6962
7040
|
*/
|
|
@@ -7011,6 +7089,12 @@
|
|
|
7011
7089
|
return Renderer;
|
|
7012
7090
|
}(g.AbstractRenderer);
|
|
7013
7091
|
|
|
7092
|
+
exports.CanvasPathGenerator = index_esm;
|
|
7093
|
+
exports.CanvasPicker = index_esm$1;
|
|
7094
|
+
exports.CanvasRenderer = index_esm$3;
|
|
7095
|
+
exports.DomInteraction = index_esm$4;
|
|
7096
|
+
exports.HTMLRenderer = index_esm$5;
|
|
7097
|
+
exports.ImageLoader = index_esm$2;
|
|
7014
7098
|
exports.Renderer = Renderer;
|
|
7015
7099
|
|
|
7016
7100
|
Object.defineProperty(exports, '__esModule', { value: true });
|