@antv/g2 4.2.8 → 4.2.9

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 (147) hide show
  1. package/CHANGELOG.md +1433 -0
  2. package/dist/g2.min.js +2 -2
  3. package/dist/g2.min.js.map +1 -1
  4. package/esm/animate/animation/index.d.ts +1 -1
  5. package/esm/chart/controller/axis.d.ts +1 -1
  6. package/esm/chart/controller/axis.js +2 -1
  7. package/esm/chart/controller/axis.js.map +1 -1
  8. package/esm/chart/controller/base.d.ts +1 -1
  9. package/esm/chart/layout/constraint/types.d.ts +2 -2
  10. package/esm/chart/layout/index.d.ts +1 -1
  11. package/esm/chart/layout/padding-cal.d.ts +1 -1
  12. package/esm/component/update-label.d.ts +1 -1
  13. package/esm/core.d.ts +1 -1
  14. package/esm/core.js +1 -1
  15. package/esm/core.js.map +1 -1
  16. package/esm/dependents.d.ts +1 -1
  17. package/esm/geometry/label/base.d.ts +1 -1
  18. package/esm/geometry/label/index.d.ts +1 -1
  19. package/esm/geometry/label/interface.d.ts +2 -2
  20. package/esm/index.js +67 -0
  21. package/esm/index.js.map +1 -1
  22. package/esm/interaction/action/element/highlight-util.d.ts +1 -1
  23. package/esm/interaction/action/element/highlight.d.ts +1 -1
  24. package/esm/interaction/action/element/link-by-color.d.ts +1 -1
  25. package/esm/interaction/action/mask/circle.d.ts +5 -0
  26. package/esm/interaction/action/mask/circle.js +18 -16
  27. package/esm/interaction/action/mask/circle.js.map +1 -1
  28. package/esm/interaction/action/mask/dim-rect.d.ts +1 -0
  29. package/esm/interaction/action/mask/dim-rect.js +38 -37
  30. package/esm/interaction/action/mask/dim-rect.js.map +1 -1
  31. package/esm/interaction/action/mask/multiple/base.d.ts +125 -0
  32. package/esm/interaction/action/mask/multiple/base.js +286 -0
  33. package/esm/interaction/action/mask/multiple/base.js.map +1 -0
  34. package/esm/interaction/action/mask/multiple/circle.d.ts +11 -0
  35. package/esm/interaction/action/mask/multiple/circle.js +19 -0
  36. package/esm/interaction/action/mask/multiple/circle.js.map +1 -0
  37. package/esm/interaction/action/mask/multiple/dim-rect.d.ts +10 -0
  38. package/esm/interaction/action/mask/multiple/dim-rect.js +22 -0
  39. package/esm/interaction/action/mask/multiple/dim-rect.js.map +1 -0
  40. package/esm/interaction/action/mask/multiple/path.d.ts +12 -0
  41. package/esm/interaction/action/mask/multiple/path.js +22 -0
  42. package/esm/interaction/action/mask/multiple/path.js.map +1 -0
  43. package/esm/interaction/action/mask/multiple/rect.d.ts +16 -0
  44. package/esm/interaction/action/mask/multiple/rect.js +25 -0
  45. package/esm/interaction/action/mask/multiple/rect.js.map +1 -0
  46. package/esm/interaction/action/mask/multiple/smooth-path.d.ts +11 -0
  47. package/esm/interaction/action/mask/multiple/smooth-path.js +19 -0
  48. package/esm/interaction/action/mask/multiple/smooth-path.js.map +1 -0
  49. package/esm/interaction/action/mask/path.d.ts +9 -0
  50. package/esm/interaction/action/mask/path.js +27 -18
  51. package/esm/interaction/action/mask/path.js.map +1 -1
  52. package/esm/interaction/action/mask/rect.d.ts +12 -0
  53. package/esm/interaction/action/mask/rect.js +25 -16
  54. package/esm/interaction/action/mask/rect.js.map +1 -1
  55. package/esm/interaction/action/mask/smooth-path.d.ts +12 -0
  56. package/esm/interaction/action/mask/smooth-path.js +17 -3
  57. package/esm/interaction/action/mask/smooth-path.js.map +1 -1
  58. package/esm/interaction/action/register.d.ts +1 -1
  59. package/esm/interaction/action/util.d.ts +6 -0
  60. package/esm/interaction/action/util.js +112 -12
  61. package/esm/interaction/action/util.js.map +1 -1
  62. package/esm/interaction/interaction.d.ts +1 -1
  63. package/esm/interface.d.ts +59 -59
  64. package/esm/util/collision-detect.d.ts +1 -1
  65. package/esm/util/legend.d.ts +1 -1
  66. package/esm/util/text.d.ts +2 -2
  67. package/esm/util/types.d.ts +1 -1
  68. package/lib/animate/animation/index.d.ts +1 -1
  69. package/lib/chart/controller/axis.d.ts +1 -1
  70. package/lib/chart/controller/axis.js +2 -1
  71. package/lib/chart/controller/axis.js.map +1 -1
  72. package/lib/chart/controller/base.d.ts +1 -1
  73. package/lib/chart/layout/constraint/types.d.ts +2 -2
  74. package/lib/chart/layout/index.d.ts +1 -1
  75. package/lib/chart/layout/padding-cal.d.ts +1 -1
  76. package/lib/component/update-label.d.ts +1 -1
  77. package/lib/core.d.ts +1 -1
  78. package/lib/core.js +1 -1
  79. package/lib/core.js.map +1 -1
  80. package/lib/dependents.d.ts +1 -1
  81. package/lib/geometry/label/base.d.ts +1 -1
  82. package/lib/geometry/label/index.d.ts +1 -1
  83. package/lib/geometry/label/interface.d.ts +2 -2
  84. package/lib/index.js +67 -0
  85. package/lib/index.js.map +1 -1
  86. package/lib/interaction/action/element/highlight-util.d.ts +1 -1
  87. package/lib/interaction/action/element/highlight.d.ts +1 -1
  88. package/lib/interaction/action/element/link-by-color.d.ts +1 -1
  89. package/lib/interaction/action/mask/circle.d.ts +5 -0
  90. package/lib/interaction/action/mask/circle.js +20 -16
  91. package/lib/interaction/action/mask/circle.js.map +1 -1
  92. package/lib/interaction/action/mask/dim-rect.d.ts +1 -0
  93. package/lib/interaction/action/mask/dim-rect.js +40 -37
  94. package/lib/interaction/action/mask/dim-rect.js.map +1 -1
  95. package/lib/interaction/action/mask/multiple/base.d.ts +125 -0
  96. package/lib/interaction/action/mask/multiple/base.js +288 -0
  97. package/lib/interaction/action/mask/multiple/base.js.map +1 -0
  98. package/lib/interaction/action/mask/multiple/circle.d.ts +11 -0
  99. package/lib/interaction/action/mask/multiple/circle.js +21 -0
  100. package/lib/interaction/action/mask/multiple/circle.js.map +1 -0
  101. package/lib/interaction/action/mask/multiple/dim-rect.d.ts +10 -0
  102. package/lib/interaction/action/mask/multiple/dim-rect.js +24 -0
  103. package/lib/interaction/action/mask/multiple/dim-rect.js.map +1 -0
  104. package/lib/interaction/action/mask/multiple/path.d.ts +12 -0
  105. package/lib/interaction/action/mask/multiple/path.js +24 -0
  106. package/lib/interaction/action/mask/multiple/path.js.map +1 -0
  107. package/lib/interaction/action/mask/multiple/rect.d.ts +16 -0
  108. package/lib/interaction/action/mask/multiple/rect.js +27 -0
  109. package/lib/interaction/action/mask/multiple/rect.js.map +1 -0
  110. package/lib/interaction/action/mask/multiple/smooth-path.d.ts +11 -0
  111. package/lib/interaction/action/mask/multiple/smooth-path.js +21 -0
  112. package/lib/interaction/action/mask/multiple/smooth-path.js.map +1 -0
  113. package/lib/interaction/action/mask/path.d.ts +9 -0
  114. package/lib/interaction/action/mask/path.js +30 -18
  115. package/lib/interaction/action/mask/path.js.map +1 -1
  116. package/lib/interaction/action/mask/rect.d.ts +12 -0
  117. package/lib/interaction/action/mask/rect.js +28 -16
  118. package/lib/interaction/action/mask/rect.js.map +1 -1
  119. package/lib/interaction/action/mask/smooth-path.d.ts +12 -0
  120. package/lib/interaction/action/mask/smooth-path.js +20 -3
  121. package/lib/interaction/action/mask/smooth-path.js.map +1 -1
  122. package/lib/interaction/action/register.d.ts +1 -1
  123. package/lib/interaction/action/util.d.ts +6 -0
  124. package/lib/interaction/action/util.js +115 -14
  125. package/lib/interaction/action/util.js.map +1 -1
  126. package/lib/interaction/interaction.d.ts +1 -1
  127. package/lib/interface.d.ts +59 -59
  128. package/lib/util/collision-detect.d.ts +1 -1
  129. package/lib/util/legend.d.ts +1 -1
  130. package/lib/util/text.d.ts +2 -2
  131. package/lib/util/types.d.ts +1 -1
  132. package/package.json +2 -21
  133. package/src/chart/controller/axis.ts +1 -1
  134. package/src/core.ts +1 -1
  135. package/src/index.ts +70 -0
  136. package/src/interaction/action/mask/circle.ts +19 -16
  137. package/src/interaction/action/mask/dim-rect.ts +39 -37
  138. package/src/interaction/action/mask/multiple/base.ts +314 -0
  139. package/src/interaction/action/mask/multiple/circle.ts +13 -0
  140. package/src/interaction/action/mask/multiple/dim-rect.ts +16 -0
  141. package/src/interaction/action/mask/multiple/path.ts +16 -0
  142. package/src/interaction/action/mask/multiple/rect.ts +19 -0
  143. package/src/interaction/action/mask/multiple/smooth-path.ts +13 -0
  144. package/src/interaction/action/mask/path.ts +28 -18
  145. package/src/interaction/action/mask/rect.ts +28 -17
  146. package/src/interaction/action/mask/smooth-path.ts +19 -3
  147. package/src/interaction/action/util.ts +123 -12
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRegion = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  var util_1 = require("@antv/util");
5
6
  var rect_1 = tslib_1.__importDefault(require("./rect"));
@@ -7,6 +8,44 @@ function clampPoint(point) {
7
8
  point.x = (0, util_1.clamp)(point.x, 0, 1);
8
9
  point.y = (0, util_1.clamp)(point.y, 0, 1);
9
10
  }
11
+ function getRegion(points, dim, inPlot, coord) {
12
+ var start = null;
13
+ var end = null;
14
+ var normalStart = coord.invert((0, util_1.head)(points));
15
+ var normalEnd = coord.invert((0, util_1.last)(points));
16
+ if (inPlot) {
17
+ // 约束到 0 - 1 范围内
18
+ clampPoint(normalStart);
19
+ clampPoint(normalEnd);
20
+ }
21
+ if (dim === 'x') {
22
+ // x 轴方向扩展, y 轴方向占满全部
23
+ start = coord.convert({
24
+ x: normalStart.x,
25
+ y: 0,
26
+ });
27
+ end = coord.convert({
28
+ x: normalEnd.x,
29
+ y: 1,
30
+ });
31
+ }
32
+ else {
33
+ // y 轴方向扩展, x 轴方向占满全部
34
+ start = coord.convert({
35
+ x: 0,
36
+ y: normalStart.y,
37
+ });
38
+ end = coord.convert({
39
+ x: 1,
40
+ y: normalEnd.y,
41
+ });
42
+ }
43
+ return {
44
+ start: start,
45
+ end: end,
46
+ };
47
+ }
48
+ exports.getRegion = getRegion;
10
49
  /**
11
50
  * @ignore
12
51
  */
@@ -19,44 +58,8 @@ var DimRect = /** @class */ (function (_super) {
19
58
  return _this;
20
59
  }
21
60
  DimRect.prototype.getRegion = function () {
22
- var start = null;
23
- var end = null;
24
- var points = this.points;
25
- var dim = this.dim;
26
61
  var coord = this.context.view.getCoordinate();
27
- var normalStart = coord.invert((0, util_1.head)(points));
28
- var normalEnd = coord.invert((0, util_1.last)(points));
29
- if (this.inPlot) {
30
- // 约束到 0 - 1 范围内
31
- clampPoint(normalStart);
32
- clampPoint(normalEnd);
33
- }
34
- if (dim === 'x') {
35
- // x 轴方向扩展, y 轴方向占满全部
36
- start = coord.convert({
37
- x: normalStart.x,
38
- y: 0,
39
- });
40
- end = coord.convert({
41
- x: normalEnd.x,
42
- y: 1,
43
- });
44
- }
45
- else {
46
- // y 轴方向扩展, x 轴方向占满全部
47
- start = coord.convert({
48
- x: 0,
49
- y: normalStart.y,
50
- });
51
- end = coord.convert({
52
- x: 1,
53
- y: normalEnd.y,
54
- });
55
- }
56
- return {
57
- start: start,
58
- end: end,
59
- };
62
+ return getRegion(this.points, this.dim, this.inPlot, coord);
60
63
  };
61
64
  return DimRect;
62
65
  }(rect_1.default));
@@ -1 +1 @@
1
- {"version":3,"file":"dim-rect.js","sourceRoot":"","sources":["../../../../src/interaction/action/mask/dim-rect.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,wDAA8B;AAE9B,SAAS,UAAU,CAAC,KAAK;IACvB,KAAK,CAAC,CAAC,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,KAAK,CAAC,CAAC,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH;IAAsB,mCAAQ;IAA9B;QAAA,qEA0CC;QAzCW,SAAG,GAAG,GAAG,CAAC;QACV,YAAM,GAAG,IAAI,CAAC;;IAwC1B,CAAC;IAvCW,2BAAS,GAAnB;QACE,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACrB,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAChD,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC;QAC/C,IAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,gBAAgB;YAChB,UAAU,CAAC,WAAW,CAAC,CAAC;YACxB,UAAU,CAAC,SAAS,CAAC,CAAC;SACvB;QACD,IAAI,GAAG,KAAK,GAAG,EAAE;YACf,qBAAqB;YACrB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;gBACpB,CAAC,EAAE,WAAW,CAAC,CAAC;gBAChB,CAAC,EAAE,CAAC;aACL,CAAC,CAAC;YACH,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;gBAClB,CAAC,EAAE,SAAS,CAAC,CAAC;gBACd,CAAC,EAAE,CAAC;aACL,CAAC,CAAC;SACJ;aAAM;YACL,qBAAqB;YACrB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;gBACpB,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,WAAW,CAAC,CAAC;aACjB,CAAC,CAAC;YACH,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;gBAClB,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,SAAS,CAAC,CAAC;aACf,CAAC,CAAC;SACJ;QACD,OAAO;YACL,KAAK,OAAA;YACL,GAAG,KAAA;SACJ,CAAC;IACJ,CAAC;IACH,cAAC;AAAD,CAAC,AA1CD,CAAsB,cAAQ,GA0C7B;AAED,kBAAe,OAAO,CAAC","sourcesContent":["import { clamp, head, last } from '@antv/util';\nimport { Region } from '../../../interface';\nimport RectMask from './rect';\n\nfunction clampPoint(point) {\n point.x = clamp(point.x, 0, 1);\n point.y = clamp(point.y, 0, 1);\n}\n\n/**\n * @ignore\n */\nclass DimRect extends RectMask {\n protected dim = 'x';\n protected inPlot = true;\n protected getRegion(): Region {\n let start = null;\n let end = null;\n const points = this.points;\n const dim = this.dim;\n const coord = this.context.view.getCoordinate();\n const normalStart = coord.invert(head(points));\n const normalEnd = coord.invert(last(points));\n if (this.inPlot) {\n // 约束到 0 - 1 范围内\n clampPoint(normalStart);\n clampPoint(normalEnd);\n }\n if (dim === 'x') {\n // x 轴方向扩展, y 轴方向占满全部\n start = coord.convert({\n x: normalStart.x,\n y: 0,\n });\n end = coord.convert({\n x: normalEnd.x,\n y: 1,\n });\n } else {\n // y 轴方向扩展, x 轴方向占满全部\n start = coord.convert({\n x: 0,\n y: normalStart.y,\n });\n end = coord.convert({\n x: 1,\n y: normalEnd.y,\n });\n }\n return {\n start,\n end,\n };\n }\n}\n\nexport default DimRect;\n"]}
1
+ {"version":3,"file":"dim-rect.js","sourceRoot":"","sources":["../../../../src/interaction/action/mask/dim-rect.ts"],"names":[],"mappings":";;;;AAAA,mCAA+C;AAE/C,wDAA8B;AAE9B,SAAS,UAAU,CAAC,KAAK;IACvB,KAAK,CAAC,CAAC,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,KAAK,CAAC,CAAC,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAgB,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK;IAClD,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,IAAI,MAAM,EAAE;QACV,gBAAgB;QAChB,UAAU,CAAC,WAAW,CAAC,CAAC;QACxB,UAAU,CAAC,SAAS,CAAC,CAAC;KACvB;IACD,IAAI,GAAG,KAAK,GAAG,EAAE;QACf,qBAAqB;QACrB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;YACpB,CAAC,EAAE,WAAW,CAAC,CAAC;YAChB,CAAC,EAAE,CAAC;SACL,CAAC,CAAC;QACH,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;YAClB,CAAC,EAAE,SAAS,CAAC,CAAC;YACd,CAAC,EAAE,CAAC;SACL,CAAC,CAAC;KACJ;SAAM;QACL,qBAAqB;QACrB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;YACpB,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,WAAW,CAAC,CAAC;SACjB,CAAC,CAAC;QACH,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;YAClB,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,SAAS,CAAC,CAAC;SACf,CAAC,CAAC;KACJ;IACD,OAAO;QACL,KAAK,OAAA;QACL,GAAG,KAAA;KACJ,CAAC;AACJ,CAAC;AAnCD,8BAmCC;AAED;;GAEG;AACH;IAAsB,mCAAQ;IAA9B;QAAA,qEAOC;QANW,SAAG,GAAG,GAAG,CAAC;QACV,YAAM,GAAG,IAAI,CAAC;;IAK1B,CAAC;IAJW,2BAAS,GAAnB;QACE,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IACH,cAAC;AAAD,CAAC,AAPD,CAAsB,cAAQ,GAO7B;AAED,kBAAe,OAAO,CAAC","sourcesContent":["import { clamp, head, last } from '@antv/util';\nimport { Region } from '../../../interface';\nimport RectMask from './rect';\n\nfunction clampPoint(point) {\n point.x = clamp(point.x, 0, 1);\n point.y = clamp(point.y, 0, 1);\n}\n\nexport function getRegion(points, dim, inPlot, coord): Region {\n let start = null;\n let end = null;\n const normalStart = coord.invert(head(points));\n const normalEnd = coord.invert(last(points));\n if (inPlot) {\n // 约束到 0 - 1 范围内\n clampPoint(normalStart);\n clampPoint(normalEnd);\n }\n if (dim === 'x') {\n // x 轴方向扩展, y 轴方向占满全部\n start = coord.convert({\n x: normalStart.x,\n y: 0,\n });\n end = coord.convert({\n x: normalEnd.x,\n y: 1,\n });\n } else {\n // y 轴方向扩展, x 轴方向占满全部\n start = coord.convert({\n x: 0,\n y: normalStart.y,\n });\n end = coord.convert({\n x: 1,\n y: normalEnd.y,\n });\n }\n return {\n start,\n end,\n };\n}\n\n/**\n * @ignore\n */\nclass DimRect extends RectMask {\n protected dim = 'x';\n protected inPlot = true;\n protected getRegion() {\n const coord = this.context.view.getCoordinate();\n return getRegion(this.points, this.dim, this.inPlot, coord);\n }\n}\n\nexport default DimRect;\n"]}
@@ -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,288 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var util_1 = require("@antv/util");
5
+ var base_1 = tslib_1.__importDefault(require("../../base"));
6
+ /**
7
+ * @ignore
8
+ * 辅助框 Action 的基类
9
+ */
10
+ var MultipleMaskBase = /** @class */ (function (_super) {
11
+ tslib_1.__extends(MultipleMaskBase, _super);
12
+ function MultipleMaskBase() {
13
+ var _this = _super !== null && _super.apply(this, arguments) || this;
14
+ // mask 图形
15
+ _this.maskShapes = [];
16
+ // 开始 mask 的标记
17
+ _this.starting = false;
18
+ // 开始移动的标记
19
+ _this.moving = false;
20
+ // 记录 mask 节点
21
+ _this.recordPoints = null;
22
+ _this.preMovePoint = null;
23
+ _this.shapeType = 'path';
24
+ _this.maskType = 'multi-mask';
25
+ return _this;
26
+ }
27
+ /**
28
+ * 获取当前的位置
29
+ */
30
+ MultipleMaskBase.prototype.getCurrentPoint = function () {
31
+ var event = this.context.event;
32
+ return {
33
+ x: event.x,
34
+ y: event.y,
35
+ };
36
+ };
37
+ /**
38
+ * 触发 mask 的事件
39
+ * @param type
40
+ */
41
+ MultipleMaskBase.prototype.emitEvent = function (type) {
42
+ var eventName = "".concat(this.maskType, ":").concat(type);
43
+ var view = this.context.view;
44
+ var event = this.context.event;
45
+ var target = {
46
+ type: this.shapeType,
47
+ name: this.maskType,
48
+ get: function (key) { return (target.hasOwnProperty(key) ? target[key] : undefined); },
49
+ };
50
+ view.emit(eventName, {
51
+ target: target,
52
+ maskShapes: this.maskShapes,
53
+ multiPoints: this.recordPoints,
54
+ x: event.x,
55
+ y: event.y,
56
+ });
57
+ };
58
+ /**
59
+ * 创建 mask
60
+ * @param index
61
+ */
62
+ MultipleMaskBase.prototype.createMask = function (index) {
63
+ var view = this.context.view;
64
+ var points = this.recordPoints[index];
65
+ var maskAttrs = this.getMaskAttrs(points);
66
+ var maskShape = view.foregroundGroup.addShape({
67
+ type: this.shapeType,
68
+ name: 'mask',
69
+ draggable: true,
70
+ attrs: tslib_1.__assign({ fill: '#C5D4EB', opacity: 0.3 }, maskAttrs),
71
+ });
72
+ this.maskShapes.push(maskShape);
73
+ };
74
+ /**
75
+ * 生成 mask 的路径
76
+ */
77
+ MultipleMaskBase.prototype.getMaskPath = function (points) {
78
+ return [];
79
+ };
80
+ /**
81
+ * 显示
82
+ */
83
+ MultipleMaskBase.prototype.show = function () {
84
+ if (this.maskShapes.length > 0) {
85
+ this.maskShapes.forEach(function (maskShape) { return maskShape.show(); });
86
+ this.emitEvent('show');
87
+ }
88
+ };
89
+ /**
90
+ * 开始
91
+ */
92
+ MultipleMaskBase.prototype.start = function (arg) {
93
+ this.recordPointStart();
94
+ this.starting = true;
95
+ // 开始时,保证移动结束
96
+ this.moving = false;
97
+ // 开始第 index 个 mask
98
+ var index = this.recordPoints.length - 1;
99
+ this.createMask(index);
100
+ // 开始时设置 capture: false,可以避免创建、resize 时触发事件
101
+ this.updateShapesCapture(false);
102
+ this.updateMask(arg === null || arg === void 0 ? void 0 : arg.maskStyle);
103
+ this.emitEvent('start');
104
+ };
105
+ /**
106
+ * 开始移动
107
+ */
108
+ MultipleMaskBase.prototype.moveStart = function () {
109
+ this.moving = true;
110
+ this.preMovePoint = this.getCurrentPoint();
111
+ this.updateShapesCapture(false);
112
+ };
113
+ /**
114
+ * 移动 mask
115
+ */
116
+ MultipleMaskBase.prototype.move = function () {
117
+ if (!this.moving || this.maskShapes.length === 0) {
118
+ return;
119
+ }
120
+ var currentPoint = this.getCurrentPoint();
121
+ var preMovePoint = this.preMovePoint;
122
+ var dx = currentPoint.x - preMovePoint.x;
123
+ var dy = currentPoint.y - preMovePoint.y;
124
+ // 只移动当前 event (x, y) 所在的某个 mask
125
+ var index = this.getCurMaskShapeIndex();
126
+ if (index > -1) {
127
+ this.recordPoints[index].forEach(function (point) {
128
+ point.x += dx;
129
+ point.y += dy;
130
+ });
131
+ this.updateMask();
132
+ this.emitEvent('change');
133
+ this.preMovePoint = currentPoint;
134
+ }
135
+ };
136
+ /**
137
+ * 更新
138
+ * @param maskStyle
139
+ */
140
+ MultipleMaskBase.prototype.updateMask = function (maskStyle) {
141
+ var _this = this;
142
+ this.recordPoints.forEach(function (points, index) {
143
+ var attrs = (0, util_1.deepMix)({}, _this.getMaskAttrs(points), maskStyle);
144
+ _this.maskShapes[index].attr(attrs);
145
+ });
146
+ };
147
+ /**
148
+ * 大小变化
149
+ */
150
+ MultipleMaskBase.prototype.resize = function () {
151
+ if (this.starting && this.maskShapes.length > 0) {
152
+ this.recordPointContinue();
153
+ this.updateMask();
154
+ this.emitEvent('change');
155
+ }
156
+ };
157
+ /**
158
+ * 结束移动
159
+ */
160
+ MultipleMaskBase.prototype.moveEnd = function () {
161
+ this.moving = false;
162
+ this.preMovePoint = null;
163
+ this.updateShapesCapture(true);
164
+ };
165
+ /**
166
+ * 结束
167
+ */
168
+ MultipleMaskBase.prototype.end = function () {
169
+ this.starting = false;
170
+ this.emitEvent('end');
171
+ this.updateShapesCapture(true);
172
+ };
173
+ /**
174
+ * 隐藏
175
+ */
176
+ MultipleMaskBase.prototype.hide = function () {
177
+ if (this.maskShapes.length > 0) {
178
+ this.maskShapes.forEach(function (maskShape) { return maskShape.hide(); });
179
+ this.emitEvent('hide');
180
+ }
181
+ };
182
+ /**
183
+ * 清除某个 mask
184
+ */
185
+ MultipleMaskBase.prototype.remove = function () {
186
+ var index = this.getCurMaskShapeIndex();
187
+ if (index > -1) {
188
+ // event (x, y) 在的某个 mask 区域内时,清除该 mask
189
+ this.recordPoints.splice(index, 1);
190
+ this.maskShapes[index].remove();
191
+ this.maskShapes.splice(index, 1);
192
+ this.preMovePoint = null;
193
+ this.updateShapesCapture(true);
194
+ this.emitEvent('change');
195
+ }
196
+ };
197
+ /**
198
+ * 清除全部 mask
199
+ */
200
+ MultipleMaskBase.prototype.clearAll = function () {
201
+ this.recordPointClear();
202
+ this.maskShapes.forEach(function (maskShape) { return maskShape.remove(); });
203
+ this.maskShapes = [];
204
+ this.preMovePoint = null;
205
+ };
206
+ /**
207
+ * 清除
208
+ */
209
+ MultipleMaskBase.prototype.clear = function () {
210
+ var index = this.getCurMaskShapeIndex();
211
+ if (index === -1) {
212
+ this.recordPointClear();
213
+ this.maskShapes.forEach(function (maskShape) { return maskShape.remove(); });
214
+ this.maskShapes = [];
215
+ this.emitEvent('clearAll');
216
+ }
217
+ else {
218
+ this.recordPoints.splice(index, 1);
219
+ this.maskShapes[index].remove();
220
+ this.maskShapes.splice(index, 1);
221
+ this.preMovePoint = null;
222
+ this.emitEvent('clearSingle');
223
+ }
224
+ this.preMovePoint = null;
225
+ };
226
+ /**
227
+ * 销毁
228
+ */
229
+ MultipleMaskBase.prototype.destroy = function () {
230
+ this.clear();
231
+ _super.prototype.destroy.call(this);
232
+ };
233
+ /**
234
+ * 获取 mask 节点记录
235
+ */
236
+ MultipleMaskBase.prototype.getRecordPoints = function () {
237
+ var _a;
238
+ return tslib_1.__spreadArray([], tslib_1.__read(((_a = this.recordPoints) !== null && _a !== void 0 ? _a : [])), false);
239
+ };
240
+ /**
241
+ * 创建 mask 节点记录
242
+ */
243
+ MultipleMaskBase.prototype.recordPointStart = function () {
244
+ var recordPoints = this.getRecordPoints();
245
+ var currentPoint = this.getCurrentPoint();
246
+ this.recordPoints = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(recordPoints), false), [[currentPoint]], false);
247
+ };
248
+ /**
249
+ * 持续记录 mask 节点
250
+ */
251
+ MultipleMaskBase.prototype.recordPointContinue = function () {
252
+ var recordPoints = this.getRecordPoints();
253
+ var currentPoint = this.getCurrentPoint();
254
+ var lastPoints = recordPoints.splice(-1, 1)[0] || [];
255
+ lastPoints.push(currentPoint);
256
+ this.recordPoints = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(recordPoints), false), [lastPoints], false);
257
+ };
258
+ /**
259
+ * 清除 mask 节点 记录
260
+ */
261
+ MultipleMaskBase.prototype.recordPointClear = function () {
262
+ this.recordPoints = [];
263
+ };
264
+ /**
265
+ * 设置 capture
266
+ * false: 避免创建、resize 时触发事件
267
+ * true: 正常触发其它事件
268
+ * @param isCapture
269
+ */
270
+ MultipleMaskBase.prototype.updateShapesCapture = function (isCapture) {
271
+ this.maskShapes.forEach(function (maskShape) { return maskShape.set('capture', isCapture); });
272
+ };
273
+ /**
274
+ *
275
+ * @returns 获取当前 event (x, y) 所在 maskShape 的 index
276
+ */
277
+ MultipleMaskBase.prototype.getCurMaskShapeIndex = function () {
278
+ var currentPoint = this.getCurrentPoint();
279
+ return this.maskShapes.findIndex(function (maskShape) {
280
+ var _a = maskShape.attrs, width = _a.width, height = _a.height, r = _a.r;
281
+ var isEmpty = width === 0 || height === 0 || r === 0;
282
+ return !isEmpty && maskShape.isHit(currentPoint.x, currentPoint.y);
283
+ });
284
+ };
285
+ return MultipleMaskBase;
286
+ }(base_1.default));
287
+ exports.default = MultipleMaskBase;
288
+ //# 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,mCAAqC;AACrC,4DAAgC;AAGhC;;;GAGG;AACH;IAAwC,4CAAM;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,GAA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vD,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,cAAM,GA+S7C;AAED,kBAAe,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,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var base_1 = tslib_1.__importDefault(require("./base"));
5
+ var circle_1 = require("../circle");
6
+ /**
7
+ * @ignore
8
+ * 圆形辅助框 Action
9
+ */
10
+ var CircleMultiMask = /** @class */ (function (_super) {
11
+ tslib_1.__extends(CircleMultiMask, _super);
12
+ function CircleMultiMask() {
13
+ var _this = _super !== null && _super.apply(this, arguments) || this;
14
+ _this.shapeType = 'circle';
15
+ _this.getMaskAttrs = circle_1.getMaskAttrs;
16
+ return _this;
17
+ }
18
+ return CircleMultiMask;
19
+ }(base_1.default));
20
+ exports.default = CircleMultiMask;
21
+ //# 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,wDAAsC;AACtC,oCAAyC;AAEzC;;;GAGG;AACH;IAA8B,2CAAgB;IAA9C;QAAA,qEAGC;QAFW,eAAS,GAAG,QAAQ,CAAC;QACrB,kBAAY,GAAG,qBAAY,CAAC;;IACxC,CAAC;IAAD,sBAAC;AAAD,CAAC,AAHD,CAA8B,cAAgB,GAG7C;AAED,kBAAe,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,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var rect_1 = tslib_1.__importDefault(require("./rect"));
5
+ var dim_rect_1 = require("../dim-rect");
6
+ /**
7
+ * @ignore
8
+ */
9
+ var DimRectMultiMask = /** @class */ (function (_super) {
10
+ tslib_1.__extends(DimRectMultiMask, _super);
11
+ function DimRectMultiMask() {
12
+ var _this = _super !== null && _super.apply(this, arguments) || this;
13
+ _this.dim = 'x';
14
+ _this.inPlot = true;
15
+ return _this;
16
+ }
17
+ DimRectMultiMask.prototype.getRegion = function (points) {
18
+ var coord = this.context.view.getCoordinate();
19
+ return (0, dim_rect_1.getRegion)(points, this.dim, this.inPlot, coord);
20
+ };
21
+ return DimRectMultiMask;
22
+ }(rect_1.default));
23
+ exports.default = DimRectMultiMask;
24
+ //# 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,wDAAsC;AACtC,wCAAwC;AAExC;;GAEG;AACH;IAA+B,4CAAgB;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,IAAA,oBAAS,EAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IACH,uBAAC;AAAD,CAAC,AAPD,CAA+B,cAAgB,GAO9C;AAED,kBAAe,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;