@visactor/vrender-core 0.17.8 → 0.17.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 (147) hide show
  1. package/cjs/canvas/conical-gradient.d.ts +10 -5
  2. package/cjs/canvas/conical-gradient.js +21 -14
  3. package/cjs/canvas/conical-gradient.js.map +1 -1
  4. package/cjs/common/render-area.js +3 -15
  5. package/cjs/common/render-area.js.map +1 -1
  6. package/cjs/common/render-curve.js +6 -17
  7. package/cjs/common/render-curve.js.map +1 -1
  8. package/cjs/common/render-utils.d.ts +10 -0
  9. package/cjs/common/render-utils.js +22 -0
  10. package/cjs/common/render-utils.js.map +1 -0
  11. package/cjs/common/seg-context.js +1 -2
  12. package/cjs/common/segment/basis.js +2 -3
  13. package/cjs/common/segment/basis.js.map +1 -1
  14. package/cjs/common/segment/common.d.ts +4 -1
  15. package/cjs/common/segment/common.js +13 -3
  16. package/cjs/common/segment/common.js.map +1 -1
  17. package/cjs/common/segment/linear-closed.d.ts +2 -16
  18. package/cjs/common/segment/linear-closed.js +3 -34
  19. package/cjs/common/segment/linear-closed.js.map +1 -1
  20. package/cjs/common/segment/linear.d.ts +1 -1
  21. package/cjs/common/segment/linear.js +2 -3
  22. package/cjs/common/segment/linear.js.map +1 -1
  23. package/cjs/common/segment/monotone.d.ts +2 -2
  24. package/cjs/common/segment/monotone.js +10 -12
  25. package/cjs/common/segment/monotone.js.map +1 -1
  26. package/cjs/common/sort.js +2 -1
  27. package/cjs/core/constants.js +1 -1
  28. package/cjs/core/stage.js +2 -1
  29. package/cjs/core/stage.js.map +1 -1
  30. package/cjs/graphic/config.js +2 -0
  31. package/cjs/graphic/config.js.map +1 -1
  32. package/cjs/interface/graphic.d.ts +2 -0
  33. package/cjs/interface/graphic.js.map +1 -1
  34. package/cjs/render/contributions/render/area-render.js +16 -11
  35. package/cjs/render/contributions/render/area-render.js.map +1 -1
  36. package/cjs/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
  37. package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
  38. package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  39. package/cjs/render/contributions/render/contributions/area-contribution-render.d.ts +1 -9
  40. package/cjs/render/contributions/render/contributions/area-contribution-render.js +3 -55
  41. package/cjs/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
  42. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.d.ts +9 -0
  43. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js +26 -0
  44. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js.map +1 -0
  45. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +1 -19
  46. package/cjs/render/contributions/render/contributions/base-contribution-render.js +2 -120
  47. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  48. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.d.ts +21 -0
  49. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +128 -0
  50. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -0
  51. package/cjs/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
  52. package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
  53. package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  54. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  55. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  56. package/cjs/render/contributions/render/contributions/index.d.ts +2 -0
  57. package/cjs/render/contributions/render/contributions/index.js +2 -1
  58. package/cjs/render/contributions/render/contributions/index.js.map +1 -1
  59. package/cjs/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
  60. package/cjs/render/contributions/render/contributions/path-contribution-render.js +2 -2
  61. package/cjs/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
  62. package/cjs/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
  63. package/cjs/render/contributions/render/contributions/polygon-contribution-render.js +2 -2
  64. package/cjs/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
  65. package/cjs/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
  66. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
  67. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  68. package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
  69. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
  70. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  71. package/cjs/render/contributions/render/line-render.js +2 -2
  72. package/cjs/render/contributions/render/line-render.js.map +1 -1
  73. package/dist/index.js +112 -187
  74. package/dist/index.min.js +1 -1
  75. package/es/canvas/conical-gradient.d.ts +10 -5
  76. package/es/canvas/conical-gradient.js +21 -16
  77. package/es/canvas/conical-gradient.js.map +1 -1
  78. package/es/common/render-area.js +2 -12
  79. package/es/common/render-area.js.map +1 -1
  80. package/es/common/render-curve.js +1 -13
  81. package/es/common/render-curve.js.map +1 -1
  82. package/es/common/render-utils.d.ts +10 -0
  83. package/es/common/render-utils.js +14 -0
  84. package/es/common/render-utils.js.map +1 -0
  85. package/es/common/seg-context.js +1 -2
  86. package/es/common/segment/basis.js +2 -8
  87. package/es/common/segment/basis.js.map +1 -1
  88. package/es/common/segment/common.d.ts +4 -1
  89. package/es/common/segment/common.js +11 -0
  90. package/es/common/segment/common.js.map +1 -1
  91. package/es/common/segment/linear-closed.d.ts +2 -16
  92. package/es/common/segment/linear-closed.js +4 -38
  93. package/es/common/segment/linear-closed.js.map +1 -1
  94. package/es/common/segment/linear.d.ts +1 -1
  95. package/es/common/segment/linear.js +2 -8
  96. package/es/common/segment/linear.js.map +1 -1
  97. package/es/common/segment/monotone.d.ts +2 -2
  98. package/es/common/segment/monotone.js +7 -13
  99. package/es/common/segment/monotone.js.map +1 -1
  100. package/es/common/sort.js +2 -1
  101. package/es/core/constants.js +1 -1
  102. package/es/core/stage.js +2 -1
  103. package/es/core/stage.js.map +1 -1
  104. package/es/graphic/config.js +2 -0
  105. package/es/graphic/config.js.map +1 -1
  106. package/es/interface/graphic.d.ts +2 -0
  107. package/es/interface/graphic.js.map +1 -1
  108. package/es/render/contributions/render/area-render.js +16 -11
  109. package/es/render/contributions/render/area-render.js.map +1 -1
  110. package/es/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
  111. package/es/render/contributions/render/contributions/arc-contribution-render.js +3 -1
  112. package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  113. package/es/render/contributions/render/contributions/area-contribution-render.d.ts +1 -9
  114. package/es/render/contributions/render/contributions/area-contribution-render.js +2 -51
  115. package/es/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
  116. package/es/render/contributions/render/contributions/area-texture-contribution-render.d.ts +9 -0
  117. package/es/render/contributions/render/contributions/area-texture-contribution-render.js +18 -0
  118. package/es/render/contributions/render/contributions/area-texture-contribution-render.js.map +1 -0
  119. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +1 -19
  120. package/es/render/contributions/render/contributions/base-contribution-render.js +0 -120
  121. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  122. package/es/render/contributions/render/contributions/base-texture-contribution-render.d.ts +21 -0
  123. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +124 -0
  124. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -0
  125. package/es/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
  126. package/es/render/contributions/render/contributions/circle-contribution-render.js +3 -1
  127. package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  128. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  129. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  130. package/es/render/contributions/render/contributions/index.d.ts +2 -0
  131. package/es/render/contributions/render/contributions/index.js +4 -0
  132. package/es/render/contributions/render/contributions/index.js.map +1 -1
  133. package/es/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
  134. package/es/render/contributions/render/contributions/path-contribution-render.js +3 -1
  135. package/es/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
  136. package/es/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
  137. package/es/render/contributions/render/contributions/polygon-contribution-render.js +3 -1
  138. package/es/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
  139. package/es/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
  140. package/es/render/contributions/render/contributions/rect-contribution-render.js +3 -1
  141. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  142. package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
  143. package/es/render/contributions/render/contributions/symbol-contribution-render.js +3 -1
  144. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  145. package/es/render/contributions/render/line-render.js +2 -2
  146. package/es/render/contributions/render/line-render.js.map +1 -1
  147. package/package.json +1 -1
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.genSegContext = exports.genCurveSegments = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), seg_context_1 = require("../seg-context"), enums_1 = require("../enums");
8
+
3
9
  function genCurveSegments(path, points, step = 1) {
4
10
  let defined0 = !1;
5
11
  for (let i = 0, n = points.length; i <= n; i++) i >= n === defined0 && ((defined0 = !defined0) ? path.lineStart() : path.lineEnd()),
6
12
  defined0 && path.point(points[i]);
7
13
  }
8
14
 
9
- Object.defineProperty(exports, "__esModule", {
10
- value: !0
11
- }), exports.genCurveSegments = void 0, exports.genCurveSegments = genCurveSegments;
15
+ function genSegContext(curveType, direction, points) {
16
+ const curveDirection = null != direction ? direction : (0, vutils_1.abs)(points[points.length - 1].x - points[0].x) > (0,
17
+ vutils_1.abs)(points[points.length - 1].y - points[0].y) ? enums_1.Direction.ROW : enums_1.Direction.COLUMN;
18
+ return "monotoneY" === curveType ? new seg_context_1.ReflectSegContext(curveType, curveDirection) : new seg_context_1.SegContext(curveType, curveDirection);
19
+ }
20
+
21
+ exports.genCurveSegments = genCurveSegments, exports.genSegContext = genSegContext;
12
22
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/segment/common.ts"],"names":[],"mappings":";;;AA0BA,SAAgB,gBAAgB,CAAC,IAAoB,EAAE,MAAoB,EAAE,OAAe,CAAC;IAC3F,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;YACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,OAAO,EAAE,CAAC;aAChB;SACF;QACD,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SACvB;KACF;AACH,CAAC;AAdD,4CAcC","file":"common.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { ILinearSegment } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n/**\n * 公用的绘制curve的方法\n * @param path\n * @param points\n * @param step\n */\nexport function genCurveSegments(path: ILinearSegment, points: IPointLike[], step: number = 1): void {\n let defined0 = false;\n for (let i = 0, n = points.length; i <= n; i++) {\n if (i >= n === defined0) {\n if ((defined0 = !defined0)) {\n path.lineStart();\n } else {\n path.lineEnd();\n }\n }\n if (defined0) {\n path.point(points[i]);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/common/segment/common.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,gDAA+D;AAC/D,oCAAqC;AAyBrC,SAAgB,gBAAgB,CAAC,IAAoB,EAAE,MAAoB,EAAE,OAAe,CAAC;IAC3F,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;YACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,OAAO,EAAE,CAAC;aAChB;SACF;QACD,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SACvB;KACF;AACH,CAAC;AAdD,4CAcC;AAED,SAAgB,aAAa,CAAC,SAAqB,EAAE,SAAqB,EAAE,MAAoB;IAC9F,MAAM,cAAc,GAClB,SAAS,aAAT,SAAS,cAAT,SAAS,GACT,CAAC,IAAA,YAAG,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAA,YAAG,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC,CAAC,iBAAS,CAAC,GAAG;QACf,CAAC,CAAC,iBAAS,CAAC,MAAM,CAAC,CAAC;IAExB,IAAI,SAAS,KAAK,WAAW,EAAE;QAC7B,OAAO,IAAI,+BAAiB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;KACzD;IAED,OAAO,IAAI,wBAAU,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AACnD,CAAC;AAZD,sCAYC","file":"common.js","sourcesContent":["import { abs, type IPointLike } from '@visactor/vutils';\nimport type { ILinearSegment } from '../../interface/curve';\nimport type { ICurveType, IDirection } from '../../interface';\nimport { ReflectSegContext, SegContext } from '../seg-context';\nimport { Direction } from '../enums';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n/**\n * 公用的绘制curve的方法\n * @param path\n * @param points\n * @param step\n */\nexport function genCurveSegments(path: ILinearSegment, points: IPointLike[], step: number = 1): void {\n let defined0 = false;\n for (let i = 0, n = points.length; i <= n; i++) {\n if (i >= n === defined0) {\n if ((defined0 = !defined0)) {\n path.lineStart();\n } else {\n path.lineEnd();\n }\n }\n if (defined0) {\n path.point(points[i]);\n }\n }\n}\n\nexport function genSegContext(curveType: ICurveType, direction: IDirection, points: IPointLike[]) {\n const curveDirection =\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN);\n\n if (curveType === 'monotoneY') {\n return new ReflectSegContext(curveType, curveDirection);\n }\n\n return new SegContext(curveType, curveDirection);\n}\n"]}
@@ -1,24 +1,10 @@
1
1
  import type { IPointLike } from '@visactor/vutils';
2
2
  import type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';
3
- export declare class LinearClosed implements ILinearSegment {
3
+ import { Linear } from './linear';
4
+ export declare class LinearClosed extends Linear implements ILinearSegment {
4
5
  context: ISegPath2D;
5
- private _lastDefined?;
6
6
  protected startPoint?: IPointLike;
7
- constructor(context: ISegPath2D, startPoint?: IPointLike);
8
- _x: number;
9
- _y: number;
10
- _x0: number;
11
- _x1: number;
12
- _y0: number;
13
- _y1: number;
14
- _line: number;
15
- _point: number;
16
- areaStart(): void;
17
- areaEnd(): void;
18
- lineStart(): void;
19
7
  lineEnd(): void;
20
- point(p: IPointLike): void;
21
- tryUpdateLength(): number;
22
8
  }
23
9
  export declare function genLinearClosedSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
24
10
  export declare function genLinearClosedTypeSegments(path: ILinearSegment, points: IPointLike[]): void;
@@ -4,49 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.genLinearClosedTypeSegments = exports.genLinearClosedSegments = exports.LinearClosed = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), seg_context_1 = require("../seg-context"), common_1 = require("./common"), enums_1 = require("../enums");
7
+ const common_1 = require("./common"), linear_1 = require("./linear");
8
8
 
9
- class LinearClosed {
10
- constructor(context, startPoint) {
11
- this.context = context, startPoint && (this.startPoint = startPoint);
12
- }
13
- areaStart() {
14
- this._line = 0;
15
- }
16
- areaEnd() {
17
- this._line = NaN;
18
- }
19
- lineStart() {
20
- this._point = 0, this.startPoint && this.point(this.startPoint);
21
- }
9
+ class LinearClosed extends linear_1.Linear {
22
10
  lineEnd() {
23
11
  this.context.closePath();
24
12
  }
25
- point(p) {
26
- const x = p.x, y = p.y;
27
- switch (this._point) {
28
- case 0:
29
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p) : this.context.moveTo(x, y, p);
30
- break;
31
-
32
- case 1:
33
- this._point = 2;
34
-
35
- default:
36
- this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p);
37
- }
38
- this._lastDefined = p.defined;
39
- }
40
- tryUpdateLength() {
41
- return this.context.tryUpdateLength();
42
- }
43
13
  }
44
14
 
45
15
  function genLinearClosedSegments(points, params = {}) {
46
16
  const {direction: direction, startPoint: startPoint} = params;
47
17
  if (points.length < 2 - Number(!!startPoint)) return null;
48
- const segContext = new seg_context_1.SegContext("linear", null != direction ? direction : (0,
49
- vutils_1.abs)(points[points.length - 1].x - points[0].x) > (0, vutils_1.abs)(points[points.length - 1].y - points[0].y) ? enums_1.Direction.ROW : enums_1.Direction.COLUMN);
18
+ const segContext = (0, common_1.genSegContext)("linear", direction, points);
50
19
  return genLinearClosedTypeSegments(new LinearClosed(segContext, startPoint), points),
51
20
  segContext;
52
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/segment/linear-closed.ts"],"names":[],"mappings":";;;AACA,6CAAuC;AACvC,gDAA4C;AAC5C,qCAA4C;AAC5C,oCAAqC;AAsBrC,MAAa,YAAY;IAMvB,YAAY,OAAmB,EAAE,UAAuB;QACt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AAC,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC;CACF;AAvDD,oCAuDC;AAED,SAAgB,uBAAuB,CAAC,MAAoB,EAAE,SAA4B,EAAE;IAC1F,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,UAAU,GAAG,IAAI,wBAAU,CAC/B,QAAQ,EACR,SAAS,aAAT,SAAS,cAAT,SAAS,GACP,CAAC,IAAA,YAAG,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAA,YAAG,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC,CAAC,iBAAS,CAAC,GAAG;QACf,CAAC,CAAC,iBAAS,CAAC,MAAM,CAAC,CACxB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AAlBD,0DAkBC;AAED,SAAgB,2BAA2B,CAAC,IAAoB,EAAE,MAAoB;IACpF,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAFD,kEAEC","file":"linear-closed.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { abs } from '@visactor/vutils';\nimport { SegContext } from '../seg-context';\nimport { genCurveSegments } from './common';\nimport { Direction } from '../enums';\nimport type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class LinearClosed implements ILinearSegment {\n declare context: ISegPath2D;\n private _lastDefined?: boolean;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n startPoint && (this.startPoint = startPoint);\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n this.context.closePath();\n }\n point(p: IPointLike): void {\n const x = p.x;\n const y = p.y;\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2; // falls through\n default:\n this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p);\n break;\n }\n\n this._lastDefined = p.defined;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport function genLinearClosedSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = new SegContext(\n 'linear',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const linear = new LinearClosed(segContext, startPoint);\n\n genLinearClosedTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearClosedTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
1
+ {"version":3,"sources":["../src/common/segment/linear-closed.ts"],"names":[],"mappings":";;;AACA,qCAA2D;AAE3D,qCAAkC;AAqBlC,MAAa,YAAa,SAAQ,eAAM;IAKtC,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;CACF;AARD,oCAQC;AAED,SAAgB,uBAAuB,CAAC,MAAoB,EAAE,SAA4B,EAAE;IAC1F,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AAbD,0DAaC;AAED,SAAgB,2BAA2B,CAAC,IAAoB,EAAE,MAAoB;IACpF,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAFD,kEAEC","file":"linear-closed.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { genCurveSegments, genSegContext } from './common';\nimport type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\nimport { Linear } from './linear';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class LinearClosed extends Linear implements ILinearSegment {\n declare context: ISegPath2D;\n\n protected startPoint?: IPointLike;\n\n lineEnd() {\n this.context.closePath();\n }\n}\n\nexport function genLinearClosedSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = genSegContext('linear', direction, points);\n\n const linear = new LinearClosed(segContext, startPoint);\n\n genLinearClosedTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearClosedTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
@@ -2,7 +2,7 @@ import type { IPointLike } from '@visactor/vutils';
2
2
  import type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';
3
3
  export declare class Linear implements ILinearSegment {
4
4
  context: ISegPath2D;
5
- private _lastDefined?;
5
+ protected _lastDefined?: boolean;
6
6
  protected startPoint?: IPointLike;
7
7
  constructor(context: ISegPath2D, startPoint?: IPointLike);
8
8
  _x: number;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.genLinearTypeSegments = exports.genLinearSegments = exports.Linear = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), seg_context_1 = require("../seg-context"), common_1 = require("./common"), enums_1 = require("../enums");
7
+ const common_1 = require("./common");
8
8
 
9
9
  class Linear {
10
10
  constructor(context, startPoint) {
@@ -46,8 +46,7 @@ class Linear {
46
46
  function genLinearSegments(points, params = {}) {
47
47
  const {direction: direction, startPoint: startPoint} = params;
48
48
  if (points.length < 2 - Number(!!startPoint)) return null;
49
- const segContext = new seg_context_1.SegContext("linear", null != direction ? direction : (0,
50
- vutils_1.abs)(points[points.length - 1].x - points[0].x) > (0, vutils_1.abs)(points[points.length - 1].y - points[0].y) ? enums_1.Direction.ROW : enums_1.Direction.COLUMN);
49
+ const segContext = (0, common_1.genSegContext)("linear", direction, points);
51
50
  return genLinearTypeSegments(new Linear(segContext, startPoint), points), segContext;
52
51
  }
53
52
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/segment/linear.ts"],"names":[],"mappings":";;;AACA,6CAAuC;AACvC,gDAA4C;AAC5C,qCAA4C;AAC5C,oCAAqC;AAsBrC,MAAa,MAAM;IAMjB,YAAY,OAAmB,EAAE,UAAuB;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC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B,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAFD,sDAEC","file":"linear.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { abs } from '@visactor/vutils';\nimport { SegContext } from '../seg-context';\nimport { genCurveSegments } from './common';\nimport { Direction } from '../enums';\nimport type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class Linear implements ILinearSegment {\n declare context: ISegPath2D;\n private _lastDefined?: boolean;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n startPoint && (this.startPoint = startPoint);\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n const x = p.x;\n const y = p.y;\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2; // falls through\n default:\n this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p);\n break;\n }\n\n this._lastDefined = p.defined;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport function genLinearSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = new SegContext(\n 'linear',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const linear = new Linear(segContext, startPoint);\n\n genLinearTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
1
+ {"version":3,"sources":["../src/common/segment/linear.ts"],"names":[],"mappings":";;;AACA,qCAA2D;AAsB3D,MAAa,MAAM;IAMjB,YAAY,OAAmB,EAAE,UAAuB;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;IAC/C,CAAC;IAUD,SAAS;QACP,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IACD,SAAS;QACP,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,C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oB,EAAE,SAA4B,EAAE;IACpF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAElD,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC,OAAO,UAAU,CAAC;AACpB,CAAC;AAbD,8CAaC;AAED,SAAgB,qBAAqB,CAAC,IAAoB,EAAE,MAAoB;IAC9E,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAFD,sDAEC","file":"linear.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { genCurveSegments, genSegContext } from './common';\nimport type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class Linear implements ILinearSegment {\n declare context: ISegPath2D;\n protected _lastDefined?: boolean;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n startPoint && (this.startPoint = startPoint);\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n const x = p.x;\n const y = p.y;\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2; // falls through\n default:\n this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false, p);\n break;\n }\n\n this._lastDefined = p.defined;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport function genLinearSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = genSegContext('linear', direction, points);\n\n const linear = new Linear(segContext, startPoint);\n\n genLinearTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
@@ -30,7 +30,7 @@ export declare class MonotoneY extends MonotoneX {
30
30
  constructor(context: ISegPath2D, startPoint?: IPointLike);
31
31
  point(p: IPointLike): void;
32
32
  }
33
- export declare function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void;
33
+ export declare function genMonotoneXTypeSegments(path: MonotoneX, points: IPointLike[]): void;
34
34
  export declare function genMonotoneXSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
35
- export declare function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void;
35
+ export declare function genMonotoneYTypeSegments(path: MonotoneX, points: IPointLike[]): void;
36
36
  export declare function genMonotoneYSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.genMonotoneYSegments = exports.genMonotpneYTypeSegments = exports.genMonotoneXSegments = exports.genMonotpneXTypeSegments = exports.MonotoneY = exports.MonotoneX = void 0;
5
+ }), exports.genMonotoneYSegments = exports.genMonotoneYTypeSegments = exports.genMonotoneXSegments = exports.genMonotoneXTypeSegments = exports.MonotoneY = exports.MonotoneX = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), linear_1 = require("./linear"), common_1 = require("./common"), seg_context_1 = require("../seg-context"), enums_1 = require("../enums");
7
+ const linear_1 = require("./linear"), common_1 = require("./common");
8
8
 
9
9
  function sign(x) {
10
10
  return x < 0 ? -1 : 1;
@@ -93,7 +93,7 @@ class MonotoneY extends MonotoneX {
93
93
  }
94
94
  }
95
95
 
96
- function genMonotpneXTypeSegments(path, points) {
96
+ function genMonotoneXTypeSegments(path, points) {
97
97
  return (0, common_1.genCurveSegments)(path, points, 2);
98
98
  }
99
99
 
@@ -101,13 +101,12 @@ function genMonotoneXSegments(points, params = {}) {
101
101
  const {direction: direction, startPoint: startPoint} = params;
102
102
  if (points.length < 2 - Number(!!startPoint)) return null;
103
103
  if (points.length < 3 - Number(!!startPoint)) return (0, linear_1.genLinearSegments)(points, params);
104
- const segContext = new seg_context_1.SegContext("monotoneX", null != direction ? direction : (0,
105
- vutils_1.abs)(points[points.length - 1].x - points[0].x) > (0, vutils_1.abs)(points[points.length - 1].y - points[0].y) ? enums_1.Direction.ROW : enums_1.Direction.COLUMN);
106
- return genMonotpneXTypeSegments(new MonotoneX(segContext, startPoint), points),
104
+ const segContext = (0, common_1.genSegContext)("monotoneX", direction, points);
105
+ return genMonotoneXTypeSegments(new MonotoneX(segContext, startPoint), points),
107
106
  segContext;
108
107
  }
109
108
 
110
- function genMonotpneYTypeSegments(path, points) {
109
+ function genMonotoneYTypeSegments(path, points) {
111
110
  return (0, common_1.genCurveSegments)(path, points, 2);
112
111
  }
113
112
 
@@ -115,13 +114,12 @@ function genMonotoneYSegments(points, params = {}) {
115
114
  const {direction: direction, startPoint: startPoint} = params;
116
115
  if (points.length < 2 - Number(!!startPoint)) return null;
117
116
  if (points.length < 3 - Number(!!startPoint)) return (0, linear_1.genLinearSegments)(points, params);
118
- const segContext = new seg_context_1.ReflectSegContext("monotoneY", null != direction ? direction : (0,
119
- vutils_1.abs)(points[points.length - 1].x - points[0].x) > (0, vutils_1.abs)(points[points.length - 1].y - points[0].y) ? enums_1.Direction.ROW : enums_1.Direction.COLUMN);
120
- return genMonotpneYTypeSegments(new MonotoneY(segContext, startPoint), points),
117
+ const segContext = (0, common_1.genSegContext)("monotoneY", direction, points);
118
+ return genMonotoneYTypeSegments(new MonotoneY(segContext, startPoint), points),
121
119
  segContext;
122
120
  }
123
121
 
124
- exports.MonotoneY = MonotoneY, exports.genMonotpneXTypeSegments = genMonotpneXTypeSegments,
125
- exports.genMonotoneXSegments = genMonotoneXSegments, exports.genMonotpneYTypeSegments = genMonotpneYTypeSegments,
122
+ exports.MonotoneY = MonotoneY, exports.genMonotoneXTypeSegments = genMonotoneXTypeSegments,
123
+ exports.genMonotoneXSegments = genMonotoneXSegments, exports.genMonotoneYTypeSegments = genMonotoneYTypeSegments,
126
124
  exports.genMonotoneYSegments = genMonotoneYSegments;
127
125
  //# sourceMappingURL=monotone.js.map
@@ -1 +1 @@
1
- {"version":3,"sources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G,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAA,YAAG,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC,CAAC,iBAAS,CAAC,GAAG;QACf,CAAC,CAAC,iBAAS,CAAC,MAAM,CAAC,CACxB,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AApBD,oDAoBC","file":"monotone.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { abs } from '@visactor/vutils';\nimport { genLinearSegments } from './linear';\nimport { genCurveSegments } from './common';\nimport { ReflectSegContext, SegContext } from '../seg-context';\nimport { Direction } from '../enums';\nimport type { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构\n// https://github.com/d3/d3-shape/blob/main/src/curve/monotone.js\nfunction sign(x: number): number {\n return x < 0 ? -1 : 1;\n}\n\n// Calculate the slopes of the tangents (Hermite-type interpolation) based on\n// the following paper: Steffen, M. 1990. A Simple Method for Monotonic\n// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.\n// NOV(II), P. 443, 1990.\nfunction slope3(curveClass: MonotoneX | MonotoneY, x2: number, y2: number) {\n const h0 = curveClass._x1 - curveClass._x0;\n const h1 = x2 - curveClass._x1;\n const s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0));\n const s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0));\n const p = (s0 * h1 + s1 * h0) / (h0 + h1);\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n}\n\n// Calculate a one-sided slope.\nfunction slope2(curveClass: MonotoneX | MonotoneY, t: number) {\n const h = curveClass._x1 - curveClass._x0;\n return h ? ((3 * (curveClass._y1 - curveClass._y0)) / h - t) / 2 : t;\n}\n\n// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\n// \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\n// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\nfunction point(curveClass: MonotoneX | MonotoneY, t0: number, t1: number, defined: boolean, p: IPointLike) {\n const x0 = curveClass._x0;\n const y0 = curveClass._y0;\n const x1 = curveClass._x1;\n const y1 = curveClass._y1;\n const dx = (x1 - x0) / 3;\n curveClass.context.bezierCurveTo(\n x0 + dx,\n y0 + dx * t0,\n x1 - dx,\n y1 - dx * t1,\n x1,\n y1,\n defined,\n curveClass.lastPoint1\n );\n}\n\nexport class MonotoneX implements ICurvedSegment {\n protected _lastDefined1?: boolean;\n protected _lastDefined2?: boolean;\n declare context: ISegPath2D;\n declare _t0: number;\n\n protected startPoint?: IPointLike;\n lastPoint0?: IPointLike;\n lastPoint1?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n this.startPoint = startPoint;\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n switch (this._point) {\n case 2:\n this.context.lineTo(\n this._x1,\n this._y1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n case 3:\n point(\n this,\n this._t0,\n slope2(this, this._t0),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n let t1 = NaN;\n const x = p.x;\n const y = p.y;\n // if (x === this._x1 && y === this._y1) {\n // return;\n // } // Ignore coincident points.\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined1 !== false && this._lastDefined2 !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2;\n break;\n case 2:\n this._point = 3;\n point(\n this,\n slope2(this, (t1 = slope3(this, x, y))),\n t1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n default:\n point(\n this,\n this._t0,\n (t1 = slope3(this, x, y)),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n }\n\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n this._t0 = t1;\n this._lastDefined1 = this._lastDefined2;\n this._lastDefined2 = p.defined !== false;\n this.lastPoint0 = this.lastPoint1;\n this.lastPoint1 = p;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport class MonotoneY extends MonotoneX {\n declare context: ISegPath2D;\n\n protected declare startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n super(context, startPoint);\n }\n\n point(p: IPointLike): void {\n return super.point({ y: p.x, x: p.y, defined: p.defined } as any);\n }\n}\n\nexport function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneXSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new SegContext(\n 'monotoneX',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneX = new MonotoneX(segContext, startPoint);\n\n genMonotpneXTypeSegments(monotoneX, points);\n\n return segContext;\n}\n\nexport function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneYSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new ReflectSegContext(\n 'monotoneY',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneY = new MonotoneY(segContext, startPoint);\n\n genMonotpneYTypeSegments(monotoneY, points);\n\n return segContext;\n}\n"]}
1
+ {"version":3,"sources":["../src/common/segment/monotone.ts"],"names":[],"mappings":";;;AACA,qCAA6C;AAC7C,qCAA2D;AAsB3D,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,CAAC,C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CAAC,IAAe,EAAE,MAAoB;IAC5E,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAFD,4DAEC;AAED,SAAgB,oBAAoB,CAAC,MAAoB,EAAE,SAA4B,EAAE;IACvF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAA,0BAAiB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C;IACD,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AAdD,oDAcC","file":"monotone.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { genLinearSegments } from './linear';\nimport { genCurveSegments, genSegContext } from './common';\nimport type { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构\n// https://github.com/d3/d3-shape/blob/main/src/curve/monotone.js\nfunction sign(x: number): number {\n return x < 0 ? -1 : 1;\n}\n\n// Calculate the slopes of the tangents (Hermite-type interpolation) based on\n// the following paper: Steffen, M. 1990. A Simple Method for Monotonic\n// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.\n// NOV(II), P. 443, 1990.\nfunction slope3(curveClass: MonotoneX | MonotoneY, x2: number, y2: number) {\n const h0 = curveClass._x1 - curveClass._x0;\n const h1 = x2 - curveClass._x1;\n const s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0));\n const s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0));\n const p = (s0 * h1 + s1 * h0) / (h0 + h1);\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n}\n\n// Calculate a one-sided slope.\nfunction slope2(curveClass: MonotoneX | MonotoneY, t: number) {\n const h = curveClass._x1 - curveClass._x0;\n return h ? ((3 * (curveClass._y1 - curveClass._y0)) / h - t) / 2 : t;\n}\n\n// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\n// \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\n// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\nfunction point(curveClass: MonotoneX | MonotoneY, t0: number, t1: number, defined: boolean, p: IPointLike) {\n const x0 = curveClass._x0;\n const y0 = curveClass._y0;\n const x1 = curveClass._x1;\n const y1 = curveClass._y1;\n const dx = (x1 - x0) / 3;\n curveClass.context.bezierCurveTo(\n x0 + dx,\n y0 + dx * t0,\n x1 - dx,\n y1 - dx * t1,\n x1,\n y1,\n defined,\n curveClass.lastPoint1\n );\n}\n\nexport class MonotoneX implements ICurvedSegment {\n protected _lastDefined1?: boolean;\n protected _lastDefined2?: boolean;\n declare context: ISegPath2D;\n declare _t0: number;\n\n protected startPoint?: IPointLike;\n lastPoint0?: IPointLike;\n lastPoint1?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n this.startPoint = startPoint;\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n switch (this._point) {\n case 2:\n this.context.lineTo(\n this._x1,\n this._y1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n case 3:\n point(\n this,\n this._t0,\n slope2(this, this._t0),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n let t1 = NaN;\n const x = p.x;\n const y = p.y;\n // if (x === this._x1 && y === this._y1) {\n // return;\n // } // Ignore coincident points.\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined1 !== false && this._lastDefined2 !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2;\n break;\n case 2:\n this._point = 3;\n point(\n this,\n slope2(this, (t1 = slope3(this, x, y))),\n t1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n default:\n point(\n this,\n this._t0,\n (t1 = slope3(this, x, y)),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n }\n\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n this._t0 = t1;\n this._lastDefined1 = this._lastDefined2;\n this._lastDefined2 = p.defined !== false;\n this.lastPoint0 = this.lastPoint1;\n this.lastPoint1 = p;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport class MonotoneY extends MonotoneX {\n declare context: ISegPath2D;\n\n protected declare startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n super(context, startPoint);\n }\n\n point(p: IPointLike): void {\n return super.point({ y: p.x, x: p.y, defined: p.defined } as any);\n }\n}\n\nexport function genMonotoneXTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneXSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = genSegContext('monotoneX', direction, points);\n\n const monotoneX = new MonotoneX(segContext, startPoint);\n\n genMonotoneXTypeSegments(monotoneX, points);\n\n return segContext;\n}\n\nexport function genMonotoneYTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneYSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = genSegContext('monotoneY', direction, points);\n const monotoneY = new MonotoneY(segContext, startPoint);\n\n genMonotoneYTypeSegments(monotoneY, points);\n\n return segContext;\n}\n"]}
@@ -97,4 +97,5 @@ function findNextGraphic(graphic, id, defaultZIndex, reverse = !1) {
97
97
  Object.defineProperty(exports, "__esModule", {
98
98
  value: !0
99
99
  }), exports.findNextGraphic = exports.foreachAsync = exports.foreach = void 0, exports.foreach = foreach,
100
- exports.foreachAsync = foreachAsync, exports.findNextGraphic = findNextGraphic;
100
+ exports.foreachAsync = foreachAsync, exports.findNextGraphic = findNextGraphic;
101
+ //# sourceMappingURL=sort.js.map
@@ -7,4 +7,4 @@ exports.TransformUtil = Symbol.for("TransformUtil"), exports.GraphicUtil = Symbo
7
7
  exports.LayerService = Symbol.for("LayerService"), exports.StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerContribution"),
8
8
  exports.DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution"),
9
9
  exports.VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
10
- //# sourceMappingURL=constants.js.map
10
+ //# sourceMappingURL=constants.js.map
package/cjs/core/stage.js CHANGED
@@ -281,7 +281,8 @@ class Stage extends graphic_1.Group {
281
281
  }
282
282
  tryInitInteractiveLayer() {
283
283
  this.supportInteractiveLayer && !this.interactiveLayer && (this.interactiveLayer = this.createLayer(),
284
- this.interactiveLayer.name = "_builtin_interactive", this.nextFrameRenderLayerSet.add(this.interactiveLayer));
284
+ this.interactiveLayer.name = "_builtin_interactive", this.interactiveLayer.attribute.pickable = !1,
285
+ this.nextFrameRenderLayerSet.add(this.interactiveLayer));
285
286
  }
286
287
  clearViewBox(color) {
287
288
  this.window.clearViewBox(this._viewBox, color);