@antv/g2 4.2.8 → 4.2.10

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.
Files changed (183) hide show
  1. package/dist/g2.min.js +2 -2
  2. package/dist/g2.min.js.map +1 -1
  3. package/esm/animate/animation/sector-path-update.js +2 -1
  4. package/esm/animate/animation/sector-path-update.js.map +1 -1
  5. package/esm/animate/animation/wave-in.js +2 -0
  6. package/esm/animate/animation/wave-in.js.map +1 -1
  7. package/esm/animate/animation/zoom.js +2 -1
  8. package/esm/animate/animation/zoom.js.map +1 -1
  9. package/esm/animate/index.js.map +1 -1
  10. package/esm/chart/controller/axis.js +2 -1
  11. package/esm/chart/controller/axis.js.map +1 -1
  12. package/esm/core.d.ts +1 -1
  13. package/esm/core.js +3 -1
  14. package/esm/core.js.map +1 -1
  15. package/esm/geometry/shape/area/index.js.map +1 -1
  16. package/esm/geometry/shape/area/line.js.map +1 -1
  17. package/esm/geometry/shape/area/smooth-line.js.map +1 -1
  18. package/esm/geometry/shape/area/smooth.js.map +1 -1
  19. package/esm/geometry/shape/base.js.map +1 -1
  20. package/esm/geometry/shape/edge/arc.js.map +1 -1
  21. package/esm/geometry/shape/edge/index.js.map +1 -1
  22. package/esm/geometry/shape/edge/smooth.js.map +1 -1
  23. package/esm/geometry/shape/edge/vhv.js.map +1 -1
  24. package/esm/geometry/shape/interval/funnel.js.map +1 -1
  25. package/esm/geometry/shape/interval/hollow-rect.js +1 -0
  26. package/esm/geometry/shape/interval/hollow-rect.js.map +1 -1
  27. package/esm/geometry/shape/interval/index.js +1 -0
  28. package/esm/geometry/shape/interval/index.js.map +1 -1
  29. package/esm/geometry/shape/interval/line.js.map +1 -1
  30. package/esm/geometry/shape/interval/pyramid.js.map +1 -1
  31. package/esm/geometry/shape/interval/tick.js.map +1 -1
  32. package/esm/geometry/shape/line/index.js.map +1 -1
  33. package/esm/geometry/shape/line/step.js.map +1 -1
  34. package/esm/geometry/shape/point/hollow.js.map +1 -1
  35. package/esm/geometry/shape/point/image.js.map +1 -1
  36. package/esm/geometry/shape/point/index.js.map +1 -1
  37. package/esm/geometry/shape/point/solid.js.map +1 -1
  38. package/esm/geometry/shape/polygon/index.js.map +1 -1
  39. package/esm/geometry/shape/polygon/square.js.map +1 -1
  40. package/esm/geometry/shape/schema/box.js.map +1 -1
  41. package/esm/geometry/shape/schema/candle.js.map +1 -1
  42. package/esm/geometry/shape/violin/hollow.js.map +1 -1
  43. package/esm/geometry/shape/violin/index.js.map +1 -1
  44. package/esm/geometry/shape/violin/smooth.js.map +1 -1
  45. package/esm/index.js +69 -2
  46. package/esm/index.js.map +1 -1
  47. package/esm/interaction/action/mask/circle.d.ts +5 -0
  48. package/esm/interaction/action/mask/circle.js +18 -16
  49. package/esm/interaction/action/mask/circle.js.map +1 -1
  50. package/esm/interaction/action/mask/dim-rect.d.ts +1 -0
  51. package/esm/interaction/action/mask/dim-rect.js +38 -37
  52. package/esm/interaction/action/mask/dim-rect.js.map +1 -1
  53. package/esm/interaction/action/mask/multiple/base.d.ts +125 -0
  54. package/esm/interaction/action/mask/multiple/base.js +286 -0
  55. package/esm/interaction/action/mask/multiple/base.js.map +1 -0
  56. package/esm/interaction/action/mask/multiple/circle.d.ts +11 -0
  57. package/esm/interaction/action/mask/multiple/circle.js +19 -0
  58. package/esm/interaction/action/mask/multiple/circle.js.map +1 -0
  59. package/esm/interaction/action/mask/multiple/dim-rect.d.ts +10 -0
  60. package/esm/interaction/action/mask/multiple/dim-rect.js +22 -0
  61. package/esm/interaction/action/mask/multiple/dim-rect.js.map +1 -0
  62. package/esm/interaction/action/mask/multiple/path.d.ts +12 -0
  63. package/esm/interaction/action/mask/multiple/path.js +22 -0
  64. package/esm/interaction/action/mask/multiple/path.js.map +1 -0
  65. package/esm/interaction/action/mask/multiple/rect.d.ts +16 -0
  66. package/esm/interaction/action/mask/multiple/rect.js +25 -0
  67. package/esm/interaction/action/mask/multiple/rect.js.map +1 -0
  68. package/esm/interaction/action/mask/multiple/smooth-path.d.ts +11 -0
  69. package/esm/interaction/action/mask/multiple/smooth-path.js +19 -0
  70. package/esm/interaction/action/mask/multiple/smooth-path.js.map +1 -0
  71. package/esm/interaction/action/mask/path.d.ts +9 -0
  72. package/esm/interaction/action/mask/path.js +27 -18
  73. package/esm/interaction/action/mask/path.js.map +1 -1
  74. package/esm/interaction/action/mask/rect.d.ts +12 -0
  75. package/esm/interaction/action/mask/rect.js +25 -16
  76. package/esm/interaction/action/mask/rect.js.map +1 -1
  77. package/esm/interaction/action/mask/smooth-path.d.ts +12 -0
  78. package/esm/interaction/action/mask/smooth-path.js +17 -3
  79. package/esm/interaction/action/mask/smooth-path.js.map +1 -1
  80. package/esm/interaction/action/util.d.ts +6 -0
  81. package/esm/interaction/action/util.js +112 -12
  82. package/esm/interaction/action/util.js.map +1 -1
  83. package/lib/animate/animation/sector-path-update.js +1 -0
  84. package/lib/animate/animation/sector-path-update.js.map +1 -1
  85. package/lib/animate/animation/wave-in.js +2 -0
  86. package/lib/animate/animation/wave-in.js.map +1 -1
  87. package/lib/animate/animation/zoom.js +1 -0
  88. package/lib/animate/animation/zoom.js.map +1 -1
  89. package/lib/animate/index.js.map +1 -1
  90. package/lib/chart/controller/axis.js +2 -1
  91. package/lib/chart/controller/axis.js.map +1 -1
  92. package/lib/core.d.ts +1 -1
  93. package/lib/core.js +9 -9
  94. package/lib/core.js.map +1 -1
  95. package/lib/geometry/shape/area/index.js.map +1 -1
  96. package/lib/geometry/shape/area/line.js.map +1 -1
  97. package/lib/geometry/shape/area/smooth-line.js.map +1 -1
  98. package/lib/geometry/shape/area/smooth.js.map +1 -1
  99. package/lib/geometry/shape/base.js.map +1 -1
  100. package/lib/geometry/shape/edge/arc.js.map +1 -1
  101. package/lib/geometry/shape/edge/index.js.map +1 -1
  102. package/lib/geometry/shape/edge/smooth.js.map +1 -1
  103. package/lib/geometry/shape/edge/vhv.js.map +1 -1
  104. package/lib/geometry/shape/interval/funnel.js.map +1 -1
  105. package/lib/geometry/shape/interval/hollow-rect.js +1 -0
  106. package/lib/geometry/shape/interval/hollow-rect.js.map +1 -1
  107. package/lib/geometry/shape/interval/index.js +1 -0
  108. package/lib/geometry/shape/interval/index.js.map +1 -1
  109. package/lib/geometry/shape/interval/line.js.map +1 -1
  110. package/lib/geometry/shape/interval/pyramid.js.map +1 -1
  111. package/lib/geometry/shape/interval/tick.js.map +1 -1
  112. package/lib/geometry/shape/line/index.js.map +1 -1
  113. package/lib/geometry/shape/line/step.js.map +1 -1
  114. package/lib/geometry/shape/point/hollow.js.map +1 -1
  115. package/lib/geometry/shape/point/image.js.map +1 -1
  116. package/lib/geometry/shape/point/index.js.map +1 -1
  117. package/lib/geometry/shape/point/solid.js.map +1 -1
  118. package/lib/geometry/shape/polygon/index.js.map +1 -1
  119. package/lib/geometry/shape/polygon/square.js.map +1 -1
  120. package/lib/geometry/shape/schema/box.js.map +1 -1
  121. package/lib/geometry/shape/schema/candle.js.map +1 -1
  122. package/lib/geometry/shape/violin/hollow.js.map +1 -1
  123. package/lib/geometry/shape/violin/index.js.map +1 -1
  124. package/lib/geometry/shape/violin/smooth.js.map +1 -1
  125. package/lib/index.js +69 -2
  126. package/lib/index.js.map +1 -1
  127. package/lib/interaction/action/mask/circle.d.ts +5 -0
  128. package/lib/interaction/action/mask/circle.js +20 -16
  129. package/lib/interaction/action/mask/circle.js.map +1 -1
  130. package/lib/interaction/action/mask/dim-rect.d.ts +1 -0
  131. package/lib/interaction/action/mask/dim-rect.js +40 -37
  132. package/lib/interaction/action/mask/dim-rect.js.map +1 -1
  133. package/lib/interaction/action/mask/multiple/base.d.ts +125 -0
  134. package/lib/interaction/action/mask/multiple/base.js +288 -0
  135. package/lib/interaction/action/mask/multiple/base.js.map +1 -0
  136. package/lib/interaction/action/mask/multiple/circle.d.ts +11 -0
  137. package/lib/interaction/action/mask/multiple/circle.js +21 -0
  138. package/lib/interaction/action/mask/multiple/circle.js.map +1 -0
  139. package/lib/interaction/action/mask/multiple/dim-rect.d.ts +10 -0
  140. package/lib/interaction/action/mask/multiple/dim-rect.js +24 -0
  141. package/lib/interaction/action/mask/multiple/dim-rect.js.map +1 -0
  142. package/lib/interaction/action/mask/multiple/path.d.ts +12 -0
  143. package/lib/interaction/action/mask/multiple/path.js +24 -0
  144. package/lib/interaction/action/mask/multiple/path.js.map +1 -0
  145. package/lib/interaction/action/mask/multiple/rect.d.ts +16 -0
  146. package/lib/interaction/action/mask/multiple/rect.js +27 -0
  147. package/lib/interaction/action/mask/multiple/rect.js.map +1 -0
  148. package/lib/interaction/action/mask/multiple/smooth-path.d.ts +11 -0
  149. package/lib/interaction/action/mask/multiple/smooth-path.js +21 -0
  150. package/lib/interaction/action/mask/multiple/smooth-path.js.map +1 -0
  151. package/lib/interaction/action/mask/path.d.ts +9 -0
  152. package/lib/interaction/action/mask/path.js +30 -18
  153. package/lib/interaction/action/mask/path.js.map +1 -1
  154. package/lib/interaction/action/mask/rect.d.ts +12 -0
  155. package/lib/interaction/action/mask/rect.js +28 -16
  156. package/lib/interaction/action/mask/rect.js.map +1 -1
  157. package/lib/interaction/action/mask/smooth-path.d.ts +12 -0
  158. package/lib/interaction/action/mask/smooth-path.js +20 -3
  159. package/lib/interaction/action/mask/smooth-path.js.map +1 -1
  160. package/lib/interaction/action/util.d.ts +6 -0
  161. package/lib/interaction/action/util.js +115 -14
  162. package/lib/interaction/action/util.js.map +1 -1
  163. package/package.json +2 -21
  164. package/src/animate/animation/sector-path-update.ts +2 -1
  165. package/src/animate/animation/wave-in.ts +2 -0
  166. package/src/animate/animation/zoom.ts +2 -1
  167. package/src/chart/controller/axis.ts +1 -1
  168. package/src/core.ts +1 -1
  169. package/src/geometry/shape/interval/hollow-rect.ts +1 -0
  170. package/src/geometry/shape/interval/index.ts +1 -0
  171. package/src/index.ts +72 -2
  172. package/src/interaction/action/mask/circle.ts +19 -16
  173. package/src/interaction/action/mask/dim-rect.ts +39 -37
  174. package/src/interaction/action/mask/multiple/base.ts +314 -0
  175. package/src/interaction/action/mask/multiple/circle.ts +13 -0
  176. package/src/interaction/action/mask/multiple/dim-rect.ts +16 -0
  177. package/src/interaction/action/mask/multiple/path.ts +16 -0
  178. package/src/interaction/action/mask/multiple/rect.ts +19 -0
  179. package/src/interaction/action/mask/multiple/smooth-path.ts +13 -0
  180. package/src/interaction/action/mask/path.ts +28 -18
  181. package/src/interaction/action/mask/rect.ts +28 -17
  182. package/src/interaction/action/mask/smooth-path.ts +19 -3
  183. package/src/interaction/action/util.ts +123 -12
@@ -0,0 +1,125 @@
1
+ import Action from '../../base';
2
+ import { LooseObject } from '../../../../interface';
3
+ /**
4
+ * @ignore
5
+ * 辅助框 Action 的基类
6
+ */
7
+ declare abstract class MultipleMaskBase extends Action {
8
+ protected maskShapes: any[];
9
+ protected starting: boolean;
10
+ protected moving: boolean;
11
+ protected recordPoints: any;
12
+ protected preMovePoint: any;
13
+ protected shapeType: string;
14
+ protected maskType: string;
15
+ /**
16
+ * 获取当前的位置
17
+ */
18
+ protected getCurrentPoint(): {
19
+ x: any;
20
+ y: any;
21
+ };
22
+ /**
23
+ * 触发 mask 的事件
24
+ * @param type
25
+ */
26
+ protected emitEvent(type: any): void;
27
+ /**
28
+ * 创建 mask
29
+ * @param index
30
+ */
31
+ private createMask;
32
+ /**
33
+ * 获取 mask shape attributes
34
+ * @param points
35
+ */
36
+ protected abstract getMaskAttrs(points: number[]): LooseObject;
37
+ /**
38
+ * 生成 mask 的路径
39
+ */
40
+ protected getMaskPath(points: any): any[];
41
+ /**
42
+ * 显示
43
+ */
44
+ show(): void;
45
+ /**
46
+ * 开始
47
+ */
48
+ start(arg?: {
49
+ maskStyle: LooseObject;
50
+ }): void;
51
+ /**
52
+ * 开始移动
53
+ */
54
+ moveStart(): void;
55
+ /**
56
+ * 移动 mask
57
+ */
58
+ move(): void;
59
+ /**
60
+ * 更新
61
+ * @param maskStyle
62
+ */
63
+ protected updateMask(maskStyle?: LooseObject): void;
64
+ /**
65
+ * 大小变化
66
+ */
67
+ resize(): void;
68
+ /**
69
+ * 结束移动
70
+ */
71
+ moveEnd(): void;
72
+ /**
73
+ * 结束
74
+ */
75
+ end(): void;
76
+ /**
77
+ * 隐藏
78
+ */
79
+ hide(): void;
80
+ /**
81
+ * 清除某个 mask
82
+ */
83
+ remove(): void;
84
+ /**
85
+ * 清除全部 mask
86
+ */
87
+ clearAll(): void;
88
+ /**
89
+ * 清除
90
+ */
91
+ clear(): void;
92
+ /**
93
+ * 销毁
94
+ */
95
+ destroy(): void;
96
+ /**
97
+ * 获取 mask 节点记录
98
+ */
99
+ protected getRecordPoints(): any[];
100
+ /**
101
+ * 创建 mask 节点记录
102
+ */
103
+ protected recordPointStart(): void;
104
+ /**
105
+ * 持续记录 mask 节点
106
+ */
107
+ protected recordPointContinue(): void;
108
+ /**
109
+ * 清除 mask 节点 记录
110
+ */
111
+ protected recordPointClear(): void;
112
+ /**
113
+ * 设置 capture
114
+ * false: 避免创建、resize 时触发事件
115
+ * true: 正常触发其它事件
116
+ * @param isCapture
117
+ */
118
+ protected updateShapesCapture(isCapture: boolean): void;
119
+ /**
120
+ *
121
+ * @returns 获取当前 event (x, y) 所在 maskShape 的 index
122
+ */
123
+ protected getCurMaskShapeIndex(): number;
124
+ }
125
+ export default MultipleMaskBase;
@@ -0,0 +1,286 @@
1
+ import { __assign, __extends, __read, __spreadArray } from "tslib";
2
+ import { deepMix } from '@antv/util';
3
+ import Action from '../../base';
4
+ /**
5
+ * @ignore
6
+ * 辅助框 Action 的基类
7
+ */
8
+ var MultipleMaskBase = /** @class */ (function (_super) {
9
+ __extends(MultipleMaskBase, _super);
10
+ function MultipleMaskBase() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ // mask 图形
13
+ _this.maskShapes = [];
14
+ // 开始 mask 的标记
15
+ _this.starting = false;
16
+ // 开始移动的标记
17
+ _this.moving = false;
18
+ // 记录 mask 节点
19
+ _this.recordPoints = null;
20
+ _this.preMovePoint = null;
21
+ _this.shapeType = 'path';
22
+ _this.maskType = 'multi-mask';
23
+ return _this;
24
+ }
25
+ /**
26
+ * 获取当前的位置
27
+ */
28
+ MultipleMaskBase.prototype.getCurrentPoint = function () {
29
+ var event = this.context.event;
30
+ return {
31
+ x: event.x,
32
+ y: event.y,
33
+ };
34
+ };
35
+ /**
36
+ * 触发 mask 的事件
37
+ * @param type
38
+ */
39
+ MultipleMaskBase.prototype.emitEvent = function (type) {
40
+ var eventName = "".concat(this.maskType, ":").concat(type);
41
+ var view = this.context.view;
42
+ var event = this.context.event;
43
+ var target = {
44
+ type: this.shapeType,
45
+ name: this.maskType,
46
+ get: function (key) { return (target.hasOwnProperty(key) ? target[key] : undefined); },
47
+ };
48
+ view.emit(eventName, {
49
+ target: target,
50
+ maskShapes: this.maskShapes,
51
+ multiPoints: this.recordPoints,
52
+ x: event.x,
53
+ y: event.y,
54
+ });
55
+ };
56
+ /**
57
+ * 创建 mask
58
+ * @param index
59
+ */
60
+ MultipleMaskBase.prototype.createMask = function (index) {
61
+ var view = this.context.view;
62
+ var points = this.recordPoints[index];
63
+ var maskAttrs = this.getMaskAttrs(points);
64
+ var maskShape = view.foregroundGroup.addShape({
65
+ type: this.shapeType,
66
+ name: 'mask',
67
+ draggable: true,
68
+ attrs: __assign({ fill: '#C5D4EB', opacity: 0.3 }, maskAttrs),
69
+ });
70
+ this.maskShapes.push(maskShape);
71
+ };
72
+ /**
73
+ * 生成 mask 的路径
74
+ */
75
+ MultipleMaskBase.prototype.getMaskPath = function (points) {
76
+ return [];
77
+ };
78
+ /**
79
+ * 显示
80
+ */
81
+ MultipleMaskBase.prototype.show = function () {
82
+ if (this.maskShapes.length > 0) {
83
+ this.maskShapes.forEach(function (maskShape) { return maskShape.show(); });
84
+ this.emitEvent('show');
85
+ }
86
+ };
87
+ /**
88
+ * 开始
89
+ */
90
+ MultipleMaskBase.prototype.start = function (arg) {
91
+ this.recordPointStart();
92
+ this.starting = true;
93
+ // 开始时,保证移动结束
94
+ this.moving = false;
95
+ // 开始第 index 个 mask
96
+ var index = this.recordPoints.length - 1;
97
+ this.createMask(index);
98
+ // 开始时设置 capture: false,可以避免创建、resize 时触发事件
99
+ this.updateShapesCapture(false);
100
+ this.updateMask(arg === null || arg === void 0 ? void 0 : arg.maskStyle);
101
+ this.emitEvent('start');
102
+ };
103
+ /**
104
+ * 开始移动
105
+ */
106
+ MultipleMaskBase.prototype.moveStart = function () {
107
+ this.moving = true;
108
+ this.preMovePoint = this.getCurrentPoint();
109
+ this.updateShapesCapture(false);
110
+ };
111
+ /**
112
+ * 移动 mask
113
+ */
114
+ MultipleMaskBase.prototype.move = function () {
115
+ if (!this.moving || this.maskShapes.length === 0) {
116
+ return;
117
+ }
118
+ var currentPoint = this.getCurrentPoint();
119
+ var preMovePoint = this.preMovePoint;
120
+ var dx = currentPoint.x - preMovePoint.x;
121
+ var dy = currentPoint.y - preMovePoint.y;
122
+ // 只移动当前 event (x, y) 所在的某个 mask
123
+ var index = this.getCurMaskShapeIndex();
124
+ if (index > -1) {
125
+ this.recordPoints[index].forEach(function (point) {
126
+ point.x += dx;
127
+ point.y += dy;
128
+ });
129
+ this.updateMask();
130
+ this.emitEvent('change');
131
+ this.preMovePoint = currentPoint;
132
+ }
133
+ };
134
+ /**
135
+ * 更新
136
+ * @param maskStyle
137
+ */
138
+ MultipleMaskBase.prototype.updateMask = function (maskStyle) {
139
+ var _this = this;
140
+ this.recordPoints.forEach(function (points, index) {
141
+ var attrs = deepMix({}, _this.getMaskAttrs(points), maskStyle);
142
+ _this.maskShapes[index].attr(attrs);
143
+ });
144
+ };
145
+ /**
146
+ * 大小变化
147
+ */
148
+ MultipleMaskBase.prototype.resize = function () {
149
+ if (this.starting && this.maskShapes.length > 0) {
150
+ this.recordPointContinue();
151
+ this.updateMask();
152
+ this.emitEvent('change');
153
+ }
154
+ };
155
+ /**
156
+ * 结束移动
157
+ */
158
+ MultipleMaskBase.prototype.moveEnd = function () {
159
+ this.moving = false;
160
+ this.preMovePoint = null;
161
+ this.updateShapesCapture(true);
162
+ };
163
+ /**
164
+ * 结束
165
+ */
166
+ MultipleMaskBase.prototype.end = function () {
167
+ this.starting = false;
168
+ this.emitEvent('end');
169
+ this.updateShapesCapture(true);
170
+ };
171
+ /**
172
+ * 隐藏
173
+ */
174
+ MultipleMaskBase.prototype.hide = function () {
175
+ if (this.maskShapes.length > 0) {
176
+ this.maskShapes.forEach(function (maskShape) { return maskShape.hide(); });
177
+ this.emitEvent('hide');
178
+ }
179
+ };
180
+ /**
181
+ * 清除某个 mask
182
+ */
183
+ MultipleMaskBase.prototype.remove = function () {
184
+ var index = this.getCurMaskShapeIndex();
185
+ if (index > -1) {
186
+ // event (x, y) 在的某个 mask 区域内时,清除该 mask
187
+ this.recordPoints.splice(index, 1);
188
+ this.maskShapes[index].remove();
189
+ this.maskShapes.splice(index, 1);
190
+ this.preMovePoint = null;
191
+ this.updateShapesCapture(true);
192
+ this.emitEvent('change');
193
+ }
194
+ };
195
+ /**
196
+ * 清除全部 mask
197
+ */
198
+ MultipleMaskBase.prototype.clearAll = function () {
199
+ this.recordPointClear();
200
+ this.maskShapes.forEach(function (maskShape) { return maskShape.remove(); });
201
+ this.maskShapes = [];
202
+ this.preMovePoint = null;
203
+ };
204
+ /**
205
+ * 清除
206
+ */
207
+ MultipleMaskBase.prototype.clear = function () {
208
+ var index = this.getCurMaskShapeIndex();
209
+ if (index === -1) {
210
+ this.recordPointClear();
211
+ this.maskShapes.forEach(function (maskShape) { return maskShape.remove(); });
212
+ this.maskShapes = [];
213
+ this.emitEvent('clearAll');
214
+ }
215
+ else {
216
+ this.recordPoints.splice(index, 1);
217
+ this.maskShapes[index].remove();
218
+ this.maskShapes.splice(index, 1);
219
+ this.preMovePoint = null;
220
+ this.emitEvent('clearSingle');
221
+ }
222
+ this.preMovePoint = null;
223
+ };
224
+ /**
225
+ * 销毁
226
+ */
227
+ MultipleMaskBase.prototype.destroy = function () {
228
+ this.clear();
229
+ _super.prototype.destroy.call(this);
230
+ };
231
+ /**
232
+ * 获取 mask 节点记录
233
+ */
234
+ MultipleMaskBase.prototype.getRecordPoints = function () {
235
+ var _a;
236
+ return __spreadArray([], __read(((_a = this.recordPoints) !== null && _a !== void 0 ? _a : [])), false);
237
+ };
238
+ /**
239
+ * 创建 mask 节点记录
240
+ */
241
+ MultipleMaskBase.prototype.recordPointStart = function () {
242
+ var recordPoints = this.getRecordPoints();
243
+ var currentPoint = this.getCurrentPoint();
244
+ this.recordPoints = __spreadArray(__spreadArray([], __read(recordPoints), false), [[currentPoint]], false);
245
+ };
246
+ /**
247
+ * 持续记录 mask 节点
248
+ */
249
+ MultipleMaskBase.prototype.recordPointContinue = function () {
250
+ var recordPoints = this.getRecordPoints();
251
+ var currentPoint = this.getCurrentPoint();
252
+ var lastPoints = recordPoints.splice(-1, 1)[0] || [];
253
+ lastPoints.push(currentPoint);
254
+ this.recordPoints = __spreadArray(__spreadArray([], __read(recordPoints), false), [lastPoints], false);
255
+ };
256
+ /**
257
+ * 清除 mask 节点 记录
258
+ */
259
+ MultipleMaskBase.prototype.recordPointClear = function () {
260
+ this.recordPoints = [];
261
+ };
262
+ /**
263
+ * 设置 capture
264
+ * false: 避免创建、resize 时触发事件
265
+ * true: 正常触发其它事件
266
+ * @param isCapture
267
+ */
268
+ MultipleMaskBase.prototype.updateShapesCapture = function (isCapture) {
269
+ this.maskShapes.forEach(function (maskShape) { return maskShape.set('capture', isCapture); });
270
+ };
271
+ /**
272
+ *
273
+ * @returns 获取当前 event (x, y) 所在 maskShape 的 index
274
+ */
275
+ MultipleMaskBase.prototype.getCurMaskShapeIndex = function () {
276
+ var currentPoint = this.getCurrentPoint();
277
+ return this.maskShapes.findIndex(function (maskShape) {
278
+ var _a = maskShape.attrs, width = _a.width, height = _a.height, r = _a.r;
279
+ var isEmpty = width === 0 || height === 0 || r === 0;
280
+ return !isEmpty && maskShape.isHit(currentPoint.x, currentPoint.y);
281
+ });
282
+ };
283
+ return MultipleMaskBase;
284
+ }(Action));
285
+ export default MultipleMaskBase;
286
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,MAAM,MAAM,YAAY,CAAC;AAGhC;;;GAGG;AACH;IAAwC,oCAAM;IAA9C;QAAA,qEA+SC;QA9SC,UAAU;QACA,gBAAU,GAAG,EAAE,CAAC;QAC1B,cAAc;QACJ,cAAQ,GAAG,KAAK,CAAC;QAC3B,UAAU;QACA,YAAM,GAAG,KAAK,CAAC;QACzB,aAAa;QACH,kBAAY,GAAG,IAAI,CAAC;QACpB,kBAAY,GAAG,IAAI,CAAC;QACpB,eAAS,GAAG,MAAM,CAAC;QACnB,cAAQ,GAAG,YAAY,CAAC;;IAoSpC,CAAC;IAlSC;;OAEG;IACO,0CAAe,GAAzB;QACE,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACjC,OAAO;YACL,CAAC,EAAE,KAAK,CAAC,CAAC;YACV,CAAC,EAAE,KAAK,CAAC,CAAC;SACX,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,oCAAS,GAAnB,UAAoB,IAAI;QACtB,IAAM,SAAS,GAAG,UAAG,IAAI,CAAC,QAAQ,cAAI,IAAI,CAAE,CAAC;QAC7C,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC/B,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACjC,IAAM,MAAM,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,GAAG,EAAE,UAAC,GAAW,IAAK,OAAA,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,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,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvD,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,0CAAO,YAAY,YAAE,UAAU,SAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACO,2CAAgB,GAA1B;QACE,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACO,8CAAmB,GAA7B,UAA8B,SAAkB;QAC9C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS,IAAK,OAAA,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,EAAnC,CAAmC,CAAC,CAAC;IAC9E,CAAC;IAED;;;OAGG;IACO,+CAAoB,GAA9B;QACE,IAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAC,SAAS;YACnC,IAAA,KAAuB,SAAS,CAAC,KAAK,EAApC,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,CAAC,OAAoB,CAAC;YAC7C,IAAM,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvD,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC;IACH,uBAAC;AAAD,CAAC,AA/SD,CAAwC,MAAM,GA+S7C;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import { deepMix } from '@antv/util';\nimport Action from '../../base';\nimport { LooseObject } from '../../../../interface';\n\n/**\n * @ignore\n * 辅助框 Action 的基类\n */\nabstract class MultipleMaskBase extends Action {\n // mask 图形\n protected maskShapes = [];\n // 开始 mask 的标记\n protected starting = false;\n // 开始移动的标记\n protected moving = false;\n // 记录 mask 节点\n protected recordPoints = null;\n protected preMovePoint = null;\n protected shapeType = 'path';\n protected maskType = 'multi-mask';\n\n /**\n * 获取当前的位置\n */\n protected getCurrentPoint() {\n const event = this.context.event;\n return {\n x: event.x,\n y: event.y,\n };\n }\n\n /**\n * 触发 mask 的事件\n * @param type\n */\n protected emitEvent(type) {\n const eventName = `${this.maskType}:${type}`;\n const view = this.context.view;\n const event = this.context.event;\n const target = {\n type: this.shapeType,\n name: this.maskType,\n get: (key: string) => (target.hasOwnProperty(key) ? target[key] : undefined),\n };\n view.emit(eventName, {\n target,\n maskShapes: this.maskShapes,\n multiPoints: this.recordPoints,\n x: event.x,\n y: event.y,\n });\n }\n\n /**\n * 创建 mask\n * @param index\n */\n private createMask(index: number) {\n const view = this.context.view;\n const points = this.recordPoints[index];\n const maskAttrs = this.getMaskAttrs(points);\n const maskShape = view.foregroundGroup.addShape({\n type: this.shapeType,\n name: 'mask',\n draggable: true,\n attrs: {\n fill: '#C5D4EB',\n opacity: 0.3,\n ...maskAttrs,\n },\n });\n this.maskShapes.push(maskShape);\n }\n\n /**\n * 获取 mask shape attributes\n * @param points\n */\n protected abstract getMaskAttrs(points: number[]): LooseObject;\n\n /**\n * 生成 mask 的路径\n */\n protected getMaskPath(points) {\n return [];\n }\n\n /**\n * 显示\n */\n public show() {\n if (this.maskShapes.length > 0) {\n this.maskShapes.forEach((maskShape) => maskShape.show());\n this.emitEvent('show');\n }\n }\n\n /**\n * 开始\n */\n public start(arg?: { maskStyle: LooseObject }) {\n this.recordPointStart();\n\n this.starting = true;\n // 开始时,保证移动结束\n this.moving = false;\n // 开始第 index 个 mask\n const index = this.recordPoints.length - 1;\n this.createMask(index);\n // 开始时设置 capture: false,可以避免创建、resize 时触发事件\n this.updateShapesCapture(false);\n this.updateMask(arg?.maskStyle);\n this.emitEvent('start');\n }\n\n /**\n * 开始移动\n */\n public moveStart() {\n this.moving = true;\n this.preMovePoint = this.getCurrentPoint();\n this.updateShapesCapture(false);\n }\n\n /**\n * 移动 mask\n */\n public move() {\n if (!this.moving || this.maskShapes.length === 0) {\n return;\n }\n const currentPoint = this.getCurrentPoint();\n const preMovePoint = this.preMovePoint;\n const dx = currentPoint.x - preMovePoint.x;\n const dy = currentPoint.y - preMovePoint.y;\n\n // 只移动当前 event (x, y) 所在的某个 mask\n const index = this.getCurMaskShapeIndex();\n if (index > -1) {\n this.recordPoints[index].forEach((point) => {\n point.x += dx;\n point.y += dy;\n });\n this.updateMask();\n this.emitEvent('change');\n this.preMovePoint = currentPoint;\n }\n }\n\n /**\n * 更新\n * @param maskStyle\n */\n protected updateMask(maskStyle?: LooseObject) {\n this.recordPoints.forEach((points, index) => {\n const attrs = deepMix({}, this.getMaskAttrs(points), maskStyle);\n this.maskShapes[index].attr(attrs);\n });\n }\n\n /**\n * 大小变化\n */\n public resize() {\n if (this.starting && this.maskShapes.length > 0) {\n this.recordPointContinue();\n\n this.updateMask();\n this.emitEvent('change');\n }\n }\n\n /**\n * 结束移动\n */\n public moveEnd() {\n this.moving = false;\n this.preMovePoint = null;\n this.updateShapesCapture(true);\n }\n\n /**\n * 结束\n */\n public end() {\n this.starting = false;\n this.emitEvent('end');\n this.updateShapesCapture(true);\n }\n\n /**\n * 隐藏\n */\n public hide() {\n if (this.maskShapes.length > 0) {\n this.maskShapes.forEach((maskShape) => maskShape.hide());\n this.emitEvent('hide');\n }\n }\n\n /**\n * 清除某个 mask\n */\n public remove() {\n const index = this.getCurMaskShapeIndex();\n if (index > -1) {\n // event (x, y) 在的某个 mask 区域内时,清除该 mask\n this.recordPoints.splice(index, 1);\n this.maskShapes[index].remove();\n this.maskShapes.splice(index, 1);\n this.preMovePoint = null;\n this.updateShapesCapture(true);\n this.emitEvent('change');\n }\n }\n\n /**\n * 清除全部 mask\n */\n public clearAll() {\n this.recordPointClear();\n this.maskShapes.forEach((maskShape) => maskShape.remove());\n this.maskShapes = [];\n this.preMovePoint = null;\n }\n\n /**\n * 清除\n */\n public clear() {\n const index = this.getCurMaskShapeIndex();\n if (index === -1) {\n this.recordPointClear();\n this.maskShapes.forEach((maskShape) => maskShape.remove());\n this.maskShapes = [];\n this.emitEvent('clearAll');\n } else {\n this.recordPoints.splice(index, 1);\n this.maskShapes[index].remove();\n this.maskShapes.splice(index, 1);\n this.preMovePoint = null;\n this.emitEvent('clearSingle');\n }\n this.preMovePoint = null;\n }\n\n /**\n * 销毁\n */\n public destroy() {\n this.clear();\n super.destroy();\n }\n\n /**\n * 获取 mask 节点记录\n */\n protected getRecordPoints() {\n return [...(this.recordPoints ?? [])];\n }\n\n /**\n * 创建 mask 节点记录\n */\n protected recordPointStart() {\n const recordPoints = this.getRecordPoints();\n const currentPoint = this.getCurrentPoint();\n this.recordPoints = [...recordPoints, [currentPoint]];\n }\n\n /**\n * 持续记录 mask 节点\n */\n protected recordPointContinue() {\n const recordPoints = this.getRecordPoints();\n const currentPoint = this.getCurrentPoint();\n const lastPoints = recordPoints.splice(-1, 1)[0] || [];\n lastPoints.push(currentPoint);\n this.recordPoints = [...recordPoints, lastPoints];\n }\n\n /**\n * 清除 mask 节点 记录\n */\n protected recordPointClear() {\n this.recordPoints = [];\n }\n\n /**\n * 设置 capture\n * false: 避免创建、resize 时触发事件\n * true: 正常触发其它事件\n * @param isCapture\n */\n protected updateShapesCapture(isCapture: boolean) {\n this.maskShapes.forEach((maskShape) => maskShape.set('capture', isCapture));\n }\n\n /**\n *\n * @returns 获取当前 event (x, y) 所在 maskShape 的 index\n */\n protected getCurMaskShapeIndex() {\n const currentPoint = this.getCurrentPoint();\n return this.maskShapes.findIndex((maskShape) => {\n const { width, height, r } = maskShape.attrs;\n const isEmpty = width === 0 || height === 0 || r === 0;\n return !isEmpty && maskShape.isHit(currentPoint.x, currentPoint.y);\n });\n }\n}\n\nexport default MultipleMaskBase;\n"]}
@@ -0,0 +1,11 @@
1
+ import MultipleMaskBase from './base';
2
+ import { getMaskAttrs } from '../circle';
3
+ /**
4
+ * @ignore
5
+ * 圆形辅助框 Action
6
+ */
7
+ declare class CircleMultiMask extends MultipleMaskBase {
8
+ protected shapeType: string;
9
+ protected getMaskAttrs: typeof getMaskAttrs;
10
+ }
11
+ export default CircleMultiMask;
@@ -0,0 +1,19 @@
1
+ import { __extends } from "tslib";
2
+ import MultipleMaskBase from './base';
3
+ import { getMaskAttrs } from '../circle';
4
+ /**
5
+ * @ignore
6
+ * 圆形辅助框 Action
7
+ */
8
+ var CircleMultiMask = /** @class */ (function (_super) {
9
+ __extends(CircleMultiMask, _super);
10
+ function CircleMultiMask() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.shapeType = 'circle';
13
+ _this.getMaskAttrs = getMaskAttrs;
14
+ return _this;
15
+ }
16
+ return CircleMultiMask;
17
+ }(MultipleMaskBase));
18
+ export default CircleMultiMask;
19
+ //# sourceMappingURL=circle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circle.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/circle.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH;IAA8B,mCAAgB;IAA9C;QAAA,qEAGC;QAFW,eAAS,GAAG,QAAQ,CAAC;QACrB,kBAAY,GAAG,YAAY,CAAC;;IACxC,CAAC;IAAD,sBAAC;AAAD,CAAC,AAHD,CAA8B,gBAAgB,GAG7C;AAED,eAAe,eAAe,CAAC","sourcesContent":["import MultipleMaskBase from './base';\nimport { getMaskAttrs } from '../circle';\n\n/**\n * @ignore\n * 圆形辅助框 Action\n */\nclass CircleMultiMask extends MultipleMaskBase {\n protected shapeType = 'circle';\n protected getMaskAttrs = getMaskAttrs;\n}\n\nexport default CircleMultiMask;\n"]}
@@ -0,0 +1,10 @@
1
+ import MultipleRectMask from './rect';
2
+ /**
3
+ * @ignore
4
+ */
5
+ declare class DimRectMultiMask extends MultipleRectMask {
6
+ protected dim: string;
7
+ protected inPlot: boolean;
8
+ protected getRegion(points: any): import("../../../../interface").Region;
9
+ }
10
+ export default DimRectMultiMask;
@@ -0,0 +1,22 @@
1
+ import { __extends } from "tslib";
2
+ import MultipleRectMask from './rect';
3
+ import { getRegion } from '../dim-rect';
4
+ /**
5
+ * @ignore
6
+ */
7
+ var DimRectMultiMask = /** @class */ (function (_super) {
8
+ __extends(DimRectMultiMask, _super);
9
+ function DimRectMultiMask() {
10
+ var _this = _super !== null && _super.apply(this, arguments) || this;
11
+ _this.dim = 'x';
12
+ _this.inPlot = true;
13
+ return _this;
14
+ }
15
+ DimRectMultiMask.prototype.getRegion = function (points) {
16
+ var coord = this.context.view.getCoordinate();
17
+ return getRegion(points, this.dim, this.inPlot, coord);
18
+ };
19
+ return DimRectMultiMask;
20
+ }(MultipleRectMask));
21
+ export default DimRectMultiMask;
22
+ //# sourceMappingURL=dim-rect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dim-rect.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/dim-rect.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH;IAA+B,oCAAgB;IAA/C;QAAA,qEAOC;QANW,SAAG,GAAG,GAAG,CAAC;QACV,YAAM,GAAG,IAAI,CAAC;;IAK1B,CAAC;IAJW,oCAAS,GAAnB,UAAoB,MAAM;QACxB,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IACH,uBAAC;AAAD,CAAC,AAPD,CAA+B,gBAAgB,GAO9C;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import MultipleRectMask from './rect';\nimport { getRegion } from '../dim-rect';\n\n/**\n * @ignore\n */\nclass DimRectMultiMask extends MultipleRectMask {\n protected dim = 'x';\n protected inPlot = true;\n protected getRegion(points) {\n const coord = this.context.view.getCoordinate();\n return getRegion(points, this.dim, this.inPlot, coord);\n }\n}\n\nexport default DimRectMultiMask;\n"]}
@@ -0,0 +1,12 @@
1
+ import MultipleMaskBase from './base';
2
+ import { getMaskAttrs, getMaskPath } from '../path';
3
+ /**
4
+ * @ignore
5
+ * 多个点构成的 Path 辅助框 Action
6
+ */
7
+ declare class PathMultiMask extends MultipleMaskBase {
8
+ protected getMaskPath: typeof getMaskPath;
9
+ protected getMaskAttrs: typeof getMaskAttrs;
10
+ addPoint(): void;
11
+ }
12
+ export default PathMultiMask;
@@ -0,0 +1,22 @@
1
+ import { __extends } from "tslib";
2
+ import MultipleMaskBase from './base';
3
+ import { getMaskAttrs, getMaskPath } from '../path';
4
+ /**
5
+ * @ignore
6
+ * 多个点构成的 Path 辅助框 Action
7
+ */
8
+ var PathMultiMask = /** @class */ (function (_super) {
9
+ __extends(PathMultiMask, _super);
10
+ function PathMultiMask() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.getMaskPath = getMaskPath;
13
+ _this.getMaskAttrs = getMaskAttrs;
14
+ return _this;
15
+ }
16
+ PathMultiMask.prototype.addPoint = function () {
17
+ this.resize();
18
+ };
19
+ return PathMultiMask;
20
+ }(MultipleMaskBase));
21
+ export default PathMultiMask;
22
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/path.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEpD;;;GAGG;AACH;IAA4B,iCAAgB;IAA5C;QAAA,qEAMC;QALW,iBAAW,GAAG,WAAW,CAAC;QAC1B,kBAAY,GAAG,YAAY,CAAC;;IAIxC,CAAC;IAHQ,gCAAQ,GAAf;QACE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IACH,oBAAC;AAAD,CAAC,AAND,CAA4B,gBAAgB,GAM3C;AAED,eAAe,aAAa,CAAC","sourcesContent":["import MultipleMaskBase from './base';\nimport { getMaskAttrs, getMaskPath } from '../path';\n\n/**\n * @ignore\n * 多个点构成的 Path 辅助框 Action\n */\nclass PathMultiMask extends MultipleMaskBase {\n protected getMaskPath = getMaskPath;\n protected getMaskAttrs = getMaskAttrs;\n public addPoint() {\n this.resize();\n }\n}\n\nexport default PathMultiMask;\n"]}
@@ -0,0 +1,16 @@
1
+ import MultipleMaskBase from './base';
2
+ /**
3
+ * @ignore
4
+ * 矩形的辅助框 Action
5
+ */
6
+ declare class RectMultiMask extends MultipleMaskBase {
7
+ protected shapeType: string;
8
+ protected getRegion(points: any): import("../../../../interface").Region;
9
+ protected getMaskAttrs(points: any): {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ };
15
+ }
16
+ export default RectMultiMask;
@@ -0,0 +1,25 @@
1
+ import { __extends } from "tslib";
2
+ import MultipleMaskBase from './base';
3
+ import { getRegion, getMaskAttrs } from '../rect';
4
+ /**
5
+ * @ignore
6
+ * 矩形的辅助框 Action
7
+ */
8
+ var RectMultiMask = /** @class */ (function (_super) {
9
+ __extends(RectMultiMask, _super);
10
+ function RectMultiMask() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.shapeType = 'rect';
13
+ return _this;
14
+ }
15
+ RectMultiMask.prototype.getRegion = function (points) {
16
+ return getRegion(points);
17
+ };
18
+ RectMultiMask.prototype.getMaskAttrs = function (points) {
19
+ var _a = this.getRegion(points), start = _a.start, end = _a.end;
20
+ return getMaskAttrs(start, end);
21
+ };
22
+ return RectMultiMask;
23
+ }(MultipleMaskBase));
24
+ export default RectMultiMask;
25
+ //# sourceMappingURL=rect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rect.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/rect.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH;IAA4B,iCAAgB;IAA5C;QAAA,qEASC;QARW,eAAS,GAAG,MAAM,CAAC;;IAQ/B,CAAC;IAPW,iCAAS,GAAnB,UAAoB,MAAM;QACxB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACS,oCAAY,GAAtB,UAAuB,MAAM;QACrB,IAAA,KAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAArC,KAAK,WAAA,EAAE,GAAG,SAA2B,CAAC;QAC9C,OAAO,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACH,oBAAC;AAAD,CAAC,AATD,CAA4B,gBAAgB,GAS3C;AAED,eAAe,aAAa,CAAC","sourcesContent":["import MultipleMaskBase from './base';\nimport { getRegion, getMaskAttrs } from '../rect';\n\n/**\n * @ignore\n * 矩形的辅助框 Action\n */\nclass RectMultiMask extends MultipleMaskBase {\n protected shapeType = 'rect';\n protected getRegion(points) {\n return getRegion(points);\n }\n protected getMaskAttrs(points) {\n const { start, end } = this.getRegion(points);\n return getMaskAttrs(start, end);\n }\n}\n\nexport default RectMultiMask;\n"]}
@@ -0,0 +1,11 @@
1
+ import MultiplePathMask from './path';
2
+ import { getMaskPath, getMaskAttrs } from '../smooth-path';
3
+ /**
4
+ * Smooth path mask
5
+ * @ignore
6
+ */
7
+ declare class SmoothPathMultiMask extends MultiplePathMask {
8
+ protected getMaskPath: typeof getMaskPath;
9
+ protected getMaskAttrs: typeof getMaskAttrs;
10
+ }
11
+ export default SmoothPathMultiMask;
@@ -0,0 +1,19 @@
1
+ import { __extends } from "tslib";
2
+ import MultiplePathMask from './path';
3
+ import { getMaskPath, getMaskAttrs } from '../smooth-path';
4
+ /**
5
+ * Smooth path mask
6
+ * @ignore
7
+ */
8
+ var SmoothPathMultiMask = /** @class */ (function (_super) {
9
+ __extends(SmoothPathMultiMask, _super);
10
+ function SmoothPathMultiMask() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.getMaskPath = getMaskPath;
13
+ _this.getMaskAttrs = getMaskAttrs;
14
+ return _this;
15
+ }
16
+ return SmoothPathMultiMask;
17
+ }(MultiplePathMask));
18
+ export default SmoothPathMultiMask;
19
+ //# sourceMappingURL=smooth-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smooth-path.js","sourceRoot":"","sources":["../../../../../src/interaction/action/mask/multiple/smooth-path.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;GAGG;AACH;IAAkC,uCAAgB;IAAlD;QAAA,qEAGC;QAFW,iBAAW,GAAG,WAAW,CAAC;QAC1B,kBAAY,GAAG,YAAY,CAAC;;IACxC,CAAC;IAAD,0BAAC;AAAD,CAAC,AAHD,CAAkC,gBAAgB,GAGjD;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import MultiplePathMask from './path';\nimport { getMaskPath, getMaskAttrs } from '../smooth-path';\n\n/**\n * Smooth path mask\n * @ignore\n */\nclass SmoothPathMultiMask extends MultiplePathMask {\n protected getMaskPath = getMaskPath;\n protected getMaskAttrs = getMaskAttrs;\n}\n\nexport default SmoothPathMultiMask;\n"]}
@@ -1,4 +1,13 @@
1
1
  import MaskBase from './base';
2
+ /**
3
+ * 生成 mask 的路径
4
+ * @param points
5
+ * @returns
6
+ */
7
+ export declare function getMaskPath(points: any): any[];
8
+ export declare function getMaskAttrs(points: any): {
9
+ path: any[];
10
+ };
2
11
  /**
3
12
  * @ignore
4
13
  * 多个点构成的 Path 辅助框 Action