@retikz/core 0.0.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/es/_virtual/jsx-runtime.js +5 -0
- package/dist/es/_virtual/jsx-runtime2.js +4 -0
- package/dist/es/_virtual/react-jsx-runtime.development.js +4 -0
- package/dist/es/_virtual/react-jsx-runtime.production.js +4 -0
- package/dist/es/components/Scope.d.ts +6 -0
- package/dist/es/components/Scope.js +10 -0
- package/dist/es/components/TikZ.d.ts +9 -0
- package/dist/es/components/TikZ.js +12 -0
- package/dist/es/components/draw/Draw.d.ts +18 -0
- package/dist/es/components/draw/Draw.js +34 -0
- package/dist/es/components/draw/InnerDraw.d.ts +13 -0
- package/dist/es/components/draw/InnerDraw.js +47 -0
- package/dist/es/components/draw/arrow/index.d.ts +9 -0
- package/dist/es/components/draw/arrow/index.js +10 -0
- package/dist/es/components/draw/arrow/stealth.d.ts +7 -0
- package/dist/es/components/draw/arrow/stealth.js +29 -0
- package/dist/es/components/draw/arrow/types.d.ts +21 -0
- package/dist/es/components/draw/common.d.ts +4 -0
- package/dist/es/components/draw/common.js +12 -0
- package/dist/es/components/draw/index.d.ts +3 -0
- package/dist/es/components/draw/segment/Segment.d.ts +12 -0
- package/dist/es/components/draw/segment/Segment.js +41 -0
- package/dist/es/components/draw/segment/index.d.ts +19 -0
- package/dist/es/components/draw/segment/index.js +41 -0
- package/dist/es/components/draw/segment/useArrow.d.ts +12 -0
- package/dist/es/components/draw/segment/useArrow.js +52 -0
- package/dist/es/components/draw/segment/useConvertWay.d.ts +14 -0
- package/dist/es/components/draw/segment/useConvertWay.js +95 -0
- package/dist/es/components/draw/types.d.ts +29 -0
- package/dist/es/components/node/InnerNode.d.ts +33 -0
- package/dist/es/components/node/InnerNode.js +88 -0
- package/dist/es/components/node/Node.d.ts +54 -0
- package/dist/es/components/node/Node.js +87 -0
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +3 -0
- package/dist/es/components/node/_hooks/useNodeConfig.js +13 -0
- package/dist/es/components/node/_hooks/useNodeContent.d.ts +4 -0
- package/dist/es/components/node/_hooks/useNodeContent.js +27 -0
- package/dist/es/components/node/_hooks/useNodeShape.d.ts +4 -0
- package/dist/es/components/node/_hooks/useNodeShape.js +34 -0
- package/dist/es/components/node/index.d.ts +3 -0
- package/dist/es/components/node/index.js +4 -0
- package/dist/es/components/pathNode/PathNode.d.ts +39 -0
- package/dist/es/components/pathNode/PathNode.js +76 -0
- package/dist/es/components/pathNode/index.d.ts +3 -0
- package/dist/es/components/pathNode/index.js +4 -0
- package/dist/es/components/pathNode/useAnchor.d.ts +6 -0
- package/dist/es/components/pathNode/useAnchor.js +49 -0
- package/dist/es/container/Group.d.ts +6 -0
- package/dist/es/container/Group.js +7 -0
- package/dist/es/container/Surface.d.ts +17 -0
- package/dist/es/container/Surface.js +23 -0
- package/dist/es/elements/Path.d.ts +4 -0
- package/dist/es/elements/Path.js +13 -0
- package/dist/es/elements/Rect.d.ts +6 -0
- package/dist/es/elements/Rect.js +8 -0
- package/dist/es/elements/Text.d.ts +19 -0
- package/dist/es/elements/Text.js +35 -0
- package/dist/es/hooks/context/useCalculate.d.ts +7 -0
- package/dist/es/hooks/context/useCalculate.js +9 -0
- package/dist/es/hooks/context/useNodes.d.ts +9 -0
- package/dist/es/hooks/context/useNodes.js +33 -0
- package/dist/es/hooks/context/usePath.d.ts +13 -0
- package/dist/es/hooks/context/usePath.js +20 -0
- package/dist/es/hooks/context/useScope.d.ts +11 -0
- package/dist/es/hooks/context/useScope.js +7 -0
- package/dist/es/hooks/useForceUpdate.d.ts +2 -0
- package/dist/es/hooks/useForceUpdate.js +8 -0
- package/dist/es/index.d.ts +10 -0
- package/dist/es/index.js +12 -0
- package/dist/es/model/component/node.d.ts +45 -0
- package/dist/es/model/component/node.js +164 -0
- package/dist/es/model/component/path.d.ts +19 -0
- package/dist/es/model/component/path.js +47 -0
- package/dist/es/model/equation/line.d.ts +21 -0
- package/dist/es/model/equation/line.js +75 -0
- package/dist/es/model/geometry/point/DescartesPoint.d.ts +21 -0
- package/dist/es/model/geometry/point/DescartesPoint.js +50 -0
- package/dist/es/model/geometry/point/PolarPoint.d.ts +14 -0
- package/dist/es/model/geometry/point/PolarPoint.js +27 -0
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +338 -0
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +13 -0
- package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +88 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +6 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +8 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +39 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +41 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +19 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +10 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +20 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +41 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +17 -0
- package/dist/es/types/coordinate/descartes.d.ts +23 -0
- package/dist/es/types/coordinate/index.d.ts +5 -0
- package/dist/es/types/coordinate/polar.d.ts +5 -0
- package/dist/es/types/distance/index.d.ts +8 -0
- package/dist/es/types/distance/sep.d.ts +9 -0
- package/dist/es/types/shape/index.d.ts +8 -0
- package/dist/es/types/shape/index.js +9 -0
- package/dist/es/types/shape/rect.d.ts +25 -0
- package/dist/es/types/shape/rect.js +30 -0
- package/dist/es/types/svg/font.d.ts +10 -0
- package/dist/es/types/svg/stroke.d.ts +10 -0
- package/dist/es/types/tikz/index.d.ts +6 -0
- package/dist/es/utils/compare.d.ts +4 -0
- package/dist/es/utils/compare.js +20 -0
- package/dist/es/utils/css.d.ts +6 -0
- package/dist/es/utils/css.js +26 -0
- package/dist/es/utils/math.d.ts +9 -0
- package/dist/es/utils/math.js +26 -0
- package/dist/es/utils/string.d.ts +7 -0
- package/dist/es/utils/string.js +7 -0
- package/dist/es/utils/style/font.d.ts +17 -0
- package/dist/es/utils/style/font.js +34 -0
- package/dist/es/utils/style/stroke.d.ts +19 -0
- package/dist/es/utils/style/stroke.js +40 -0
- package/dist/lib/_virtual/jsx-runtime.cjs +5 -0
- package/dist/lib/_virtual/jsx-runtime2.cjs +4 -0
- package/dist/lib/_virtual/react-jsx-runtime.development.cjs +4 -0
- package/dist/lib/_virtual/react-jsx-runtime.production.cjs +4 -0
- package/dist/lib/components/Scope.cjs +10 -0
- package/dist/lib/components/Scope.d.ts +6 -0
- package/dist/lib/components/TikZ.cjs +12 -0
- package/dist/lib/components/TikZ.d.ts +9 -0
- package/dist/lib/components/draw/Draw.cjs +34 -0
- package/dist/lib/components/draw/Draw.d.ts +18 -0
- package/dist/lib/components/draw/InnerDraw.cjs +47 -0
- package/dist/lib/components/draw/InnerDraw.d.ts +13 -0
- package/dist/lib/components/draw/arrow/index.cjs +10 -0
- package/dist/lib/components/draw/arrow/index.d.ts +9 -0
- package/dist/lib/components/draw/arrow/stealth.cjs +29 -0
- package/dist/lib/components/draw/arrow/stealth.d.ts +7 -0
- package/dist/lib/components/draw/arrow/types.d.ts +21 -0
- package/dist/lib/components/draw/common.cjs +12 -0
- package/dist/lib/components/draw/common.d.ts +4 -0
- package/dist/lib/components/draw/index.d.ts +3 -0
- package/dist/lib/components/draw/segment/Segment.cjs +41 -0
- package/dist/lib/components/draw/segment/Segment.d.ts +12 -0
- package/dist/lib/components/draw/segment/index.cjs +41 -0
- package/dist/lib/components/draw/segment/index.d.ts +19 -0
- package/dist/lib/components/draw/segment/useArrow.cjs +52 -0
- package/dist/lib/components/draw/segment/useArrow.d.ts +12 -0
- package/dist/lib/components/draw/segment/useConvertWay.cjs +95 -0
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +14 -0
- package/dist/lib/components/draw/types.d.ts +29 -0
- package/dist/lib/components/node/InnerNode.cjs +88 -0
- package/dist/lib/components/node/InnerNode.d.ts +33 -0
- package/dist/lib/components/node/Node.cjs +87 -0
- package/dist/lib/components/node/Node.d.ts +54 -0
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +13 -0
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +3 -0
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +27 -0
- package/dist/lib/components/node/_hooks/useNodeContent.d.ts +4 -0
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +34 -0
- package/dist/lib/components/node/_hooks/useNodeShape.d.ts +4 -0
- package/dist/lib/components/node/index.cjs +4 -0
- package/dist/lib/components/node/index.d.ts +3 -0
- package/dist/lib/components/pathNode/PathNode.cjs +76 -0
- package/dist/lib/components/pathNode/PathNode.d.ts +39 -0
- package/dist/lib/components/pathNode/index.cjs +4 -0
- package/dist/lib/components/pathNode/index.d.ts +3 -0
- package/dist/lib/components/pathNode/useAnchor.cjs +49 -0
- package/dist/lib/components/pathNode/useAnchor.d.ts +6 -0
- package/dist/lib/container/Group.cjs +7 -0
- package/dist/lib/container/Group.d.ts +6 -0
- package/dist/lib/container/Surface.cjs +23 -0
- package/dist/lib/container/Surface.d.ts +17 -0
- package/dist/lib/elements/Path.cjs +13 -0
- package/dist/lib/elements/Path.d.ts +4 -0
- package/dist/lib/elements/Rect.cjs +8 -0
- package/dist/lib/elements/Rect.d.ts +6 -0
- package/dist/lib/elements/Text.cjs +35 -0
- package/dist/lib/elements/Text.d.ts +19 -0
- package/dist/lib/hooks/context/useCalculate.cjs +9 -0
- package/dist/lib/hooks/context/useCalculate.d.ts +7 -0
- package/dist/lib/hooks/context/useNodes.cjs +33 -0
- package/dist/lib/hooks/context/useNodes.d.ts +9 -0
- package/dist/lib/hooks/context/usePath.cjs +20 -0
- package/dist/lib/hooks/context/usePath.d.ts +13 -0
- package/dist/lib/hooks/context/useScope.cjs +7 -0
- package/dist/lib/hooks/context/useScope.d.ts +11 -0
- package/dist/lib/hooks/useForceUpdate.cjs +8 -0
- package/dist/lib/hooks/useForceUpdate.d.ts +2 -0
- package/dist/lib/index.cjs +12 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/model/component/node.cjs +164 -0
- package/dist/lib/model/component/node.d.ts +45 -0
- package/dist/lib/model/component/path.cjs +47 -0
- package/dist/lib/model/component/path.d.ts +19 -0
- package/dist/lib/model/equation/line.cjs +75 -0
- package/dist/lib/model/equation/line.d.ts +21 -0
- package/dist/lib/model/geometry/point/DescartesPoint.cjs +50 -0
- package/dist/lib/model/geometry/point/DescartesPoint.d.ts +21 -0
- package/dist/lib/model/geometry/point/PolarPoint.cjs +27 -0
- package/dist/lib/model/geometry/point/PolarPoint.d.ts +14 -0
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +338 -0
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +13 -0
- package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +88 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +6 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +8 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +39 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +41 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +19 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +10 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.cjs +20 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.cjs +41 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs +17 -0
- package/dist/lib/types/coordinate/descartes.d.ts +23 -0
- package/dist/lib/types/coordinate/index.d.ts +5 -0
- package/dist/lib/types/coordinate/polar.d.ts +5 -0
- package/dist/lib/types/distance/index.d.ts +8 -0
- package/dist/lib/types/distance/sep.d.ts +9 -0
- package/dist/lib/types/shape/index.cjs +9 -0
- package/dist/lib/types/shape/index.d.ts +8 -0
- package/dist/lib/types/shape/rect.cjs +30 -0
- package/dist/lib/types/shape/rect.d.ts +25 -0
- package/dist/lib/types/svg/font.d.ts +10 -0
- package/dist/lib/types/svg/stroke.d.ts +10 -0
- package/dist/lib/types/tikz/index.d.ts +6 -0
- package/dist/lib/utils/compare.cjs +20 -0
- package/dist/lib/utils/compare.d.ts +4 -0
- package/dist/lib/utils/css.cjs +26 -0
- package/dist/lib/utils/css.d.ts +6 -0
- package/dist/lib/utils/math.cjs +26 -0
- package/dist/lib/utils/math.d.ts +9 -0
- package/dist/lib/utils/string.cjs +7 -0
- package/dist/lib/utils/string.d.ts +7 -0
- package/dist/lib/utils/style/font.cjs +34 -0
- package/dist/lib/utils/style/font.d.ts +17 -0
- package/dist/lib/utils/style/stroke.cjs +40 -0
- package/dist/lib/utils/style/stroke.d.ts +19 -0
- package/package.json +57 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Draw = require("./components/draw/Draw.cjs");
|
|
4
|
+
const Node = require("./components/node/Node.cjs");
|
|
5
|
+
const PathNode = require("./components/pathNode/PathNode.cjs");
|
|
6
|
+
const Scope = require("./components/Scope.cjs");
|
|
7
|
+
const TikZ = require("./components/TikZ.cjs");
|
|
8
|
+
exports.Draw = Draw.default;
|
|
9
|
+
exports.Node = Node.default;
|
|
10
|
+
exports.PathNode = PathNode.default;
|
|
11
|
+
exports.Scope = Scope.default;
|
|
12
|
+
exports.TikZ = TikZ.default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Draw } from './components/draw/Draw';
|
|
2
|
+
export type { DrawProps } from './components/draw/Draw';
|
|
3
|
+
export { default as Node } from './components/node';
|
|
4
|
+
export type { NodeProps } from './components/node';
|
|
5
|
+
export { default as PathNode } from './components/pathNode';
|
|
6
|
+
export type { PathNodeProps } from './components/pathNode';
|
|
7
|
+
export { default as Scope } from './components/Scope';
|
|
8
|
+
export type { ScopeProps } from './components/Scope';
|
|
9
|
+
export { default as TikZ } from './components/TikZ';
|
|
10
|
+
export type { TikZProps } from './components/TikZ';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
const index = require("../../types/shape/index.cjs");
|
|
7
|
+
const rect = require("../../types/shape/rect.cjs");
|
|
8
|
+
const compare = require("../../utils/compare.cjs");
|
|
9
|
+
const math = require("../../utils/math.cjs");
|
|
10
|
+
const line = require("../equation/line.cjs");
|
|
11
|
+
const _NodeModel = class _NodeModel {
|
|
12
|
+
constructor(config, init = true) {
|
|
13
|
+
__publicField(this, "type", ["node"]);
|
|
14
|
+
/** 是否初始化节点数据, 很多节点在 layout 阶段才能初始化全部数据 */
|
|
15
|
+
__publicField(this, "init", false);
|
|
16
|
+
/** 节点是否已经被销毁,如果已近销毁,其他地方应该删除对节点对象的引用 */
|
|
17
|
+
__publicField(this, "disposed", false);
|
|
18
|
+
__publicField(this, "center", [0, 0]);
|
|
19
|
+
__publicField(this, "size", [0, 0]);
|
|
20
|
+
__publicField(this, "innerSep", { left: 0, right: 0, top: 0, bottom: 0 });
|
|
21
|
+
__publicField(this, "outerSep", { left: 0, right: 0, top: 0, bottom: 0 });
|
|
22
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
23
|
+
this.update(config, init);
|
|
24
|
+
}
|
|
25
|
+
update(config, init = true) {
|
|
26
|
+
const preSelf = { ...this };
|
|
27
|
+
const { position, contentSize, innerSep, outerSep } = config;
|
|
28
|
+
let needUpdate = false;
|
|
29
|
+
if (!this.init && init) {
|
|
30
|
+
this.init = init;
|
|
31
|
+
needUpdate = true;
|
|
32
|
+
}
|
|
33
|
+
if (position && !compare.isSameArray(position, this.center)) {
|
|
34
|
+
this.center = position;
|
|
35
|
+
needUpdate = true;
|
|
36
|
+
}
|
|
37
|
+
if (contentSize && !compare.isSameArray(contentSize, this.size)) {
|
|
38
|
+
this.size = contentSize;
|
|
39
|
+
needUpdate = true;
|
|
40
|
+
}
|
|
41
|
+
if (innerSep && !compare.isSameObj(innerSep, this.innerSep)) {
|
|
42
|
+
this.innerSep = innerSep;
|
|
43
|
+
needUpdate = true;
|
|
44
|
+
}
|
|
45
|
+
if (outerSep && !compare.isSameObj(outerSep, this.outerSep)) {
|
|
46
|
+
this.outerSep = outerSep;
|
|
47
|
+
needUpdate = true;
|
|
48
|
+
}
|
|
49
|
+
if (this.init && needUpdate) {
|
|
50
|
+
this.notify(preSelf);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
notify(preSelf) {
|
|
54
|
+
this.listeners.forEach((listener) => listener({ ...this }, preSelf));
|
|
55
|
+
}
|
|
56
|
+
subscribe(listener) {
|
|
57
|
+
this.listeners.add(listener);
|
|
58
|
+
return () => this.listeners.delete(listener);
|
|
59
|
+
}
|
|
60
|
+
dispose() {
|
|
61
|
+
this.listeners.clear();
|
|
62
|
+
this.disposed = true;
|
|
63
|
+
this.notify(this);
|
|
64
|
+
}
|
|
65
|
+
/** 获取某个点相对于节点外边界的区域 */
|
|
66
|
+
getPointArea(point) {
|
|
67
|
+
const [pX, pY] = point;
|
|
68
|
+
const [x, y] = this.center;
|
|
69
|
+
const edgeX = [x - this.getOuterDistance("left"), x + this.getOuterDistance("right")];
|
|
70
|
+
const edgeY = [y - this.getOuterDistance("top"), y + this.getOuterDistance("bottom")];
|
|
71
|
+
if (math.between(pX, edgeX) && math.between(pY, edgeY)) return index.Area.INSIDE;
|
|
72
|
+
if (math.between(pX, edgeX, true) && math.between(pY, edgeY, true)) return index.Area.EDGE;
|
|
73
|
+
return index.Area.OUTSIDE;
|
|
74
|
+
}
|
|
75
|
+
/** 获取外边界特殊点(中点,顶点,三等分点) */
|
|
76
|
+
getOuterPoint(point) {
|
|
77
|
+
if (!this.init) return void 0;
|
|
78
|
+
const [x, y] = this.center;
|
|
79
|
+
const [width, height] = this.size;
|
|
80
|
+
const { left: innerLeft, right: innerRight, top: innerTop, bottom: innerBottom } = this.innerSep;
|
|
81
|
+
const { left: outerLeft, right: outerRight, top: outerTop, bottom: outerBottom } = this.outerSep;
|
|
82
|
+
switch (point) {
|
|
83
|
+
case rect.RectVertexPoint.TL:
|
|
84
|
+
return [x - width / 2 - innerLeft - outerLeft, y - height / 2 - innerTop - outerTop];
|
|
85
|
+
case rect.RectVertexPoint.TR:
|
|
86
|
+
return [x + width / 2 + innerRight + outerRight, y - height / 2 - innerTop - outerTop];
|
|
87
|
+
case rect.RectVertexPoint.BL:
|
|
88
|
+
return [x - width / 2 - innerLeft - outerLeft, y + height / 2 + innerBottom + outerBottom];
|
|
89
|
+
case rect.RectVertexPoint.BR:
|
|
90
|
+
return [x + width / 2 + innerRight + outerRight, y + height / 2 + innerBottom + outerBottom];
|
|
91
|
+
case rect.RectMidPoint.T:
|
|
92
|
+
return [x, y - height / 2 - innerTop - outerTop];
|
|
93
|
+
case rect.RectMidPoint.B:
|
|
94
|
+
return [x, y + height / 2 + innerBottom + outerBottom];
|
|
95
|
+
case rect.RectMidPoint.L:
|
|
96
|
+
return [x - width / 2 - innerLeft - outerLeft, y];
|
|
97
|
+
case rect.RectMidPoint.R:
|
|
98
|
+
return [x + width / 2 + innerRight + outerRight, y];
|
|
99
|
+
case rect.RectThirdPoint.TL:
|
|
100
|
+
return [x - (width / 2 + innerLeft + outerLeft) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
101
|
+
case rect.RectThirdPoint.TR:
|
|
102
|
+
return [x + (width / 2 + innerRight + outerRight) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
103
|
+
case rect.RectThirdPoint.BL:
|
|
104
|
+
return [x - (width / 2 + innerLeft + outerLeft) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
105
|
+
case rect.RectThirdPoint.BR:
|
|
106
|
+
return [x + (width / 2 + innerRight + outerRight) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
107
|
+
case rect.RectThirdPoint.LT:
|
|
108
|
+
return [x - (width / 2 + innerLeft + outerLeft) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
109
|
+
case rect.RectThirdPoint.LB:
|
|
110
|
+
return [x - (width / 2 + innerLeft + outerLeft) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
111
|
+
case rect.RectThirdPoint.RT:
|
|
112
|
+
return [x + (width / 2 + innerRight + outerRight) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
113
|
+
case rect.RectThirdPoint.RB:
|
|
114
|
+
return [x + (width / 2 + innerRight + outerRight) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** 获取外部点与 node 中心连线与外边缘的交点 */
|
|
118
|
+
getCrossPoint(point) {
|
|
119
|
+
if (!this.init) return this.center;
|
|
120
|
+
const pointArea = this.getPointArea(point);
|
|
121
|
+
if (pointArea === index.Area.EDGE) return point;
|
|
122
|
+
const line$1 = line.default.fromPoints(point, this.center);
|
|
123
|
+
const PointTL = this.getOuterPoint(rect.RectVertexPoint.TL);
|
|
124
|
+
const PointTR = this.getOuterPoint(rect.RectVertexPoint.TR);
|
|
125
|
+
const topCrossPoint = line$1.getIntersection(line.default.fromPoints(PointTL, PointTR));
|
|
126
|
+
if (topCrossPoint && point[1] < this.center[1] && math.between(topCrossPoint[0], [PointTL[0], PointTR[0]], true)) {
|
|
127
|
+
return topCrossPoint;
|
|
128
|
+
}
|
|
129
|
+
const PointBL = this.getOuterPoint(rect.RectVertexPoint.BL);
|
|
130
|
+
const PointBR = this.getOuterPoint(rect.RectVertexPoint.BR);
|
|
131
|
+
const belowCrossPoint = line$1.getIntersection(line.default.fromPoints(PointBL, PointBR));
|
|
132
|
+
if (belowCrossPoint && point[1] > this.center[1] && math.between(belowCrossPoint[0], [PointBL[0], PointBR[0]], true))
|
|
133
|
+
return belowCrossPoint;
|
|
134
|
+
const leftCrossPoint = line$1.getIntersection(line.default.fromPoints(PointTL, PointBL));
|
|
135
|
+
if (leftCrossPoint && point[0] < this.center[0] && math.between(leftCrossPoint[1], [PointTL[1], PointBL[1]], true))
|
|
136
|
+
return leftCrossPoint;
|
|
137
|
+
const rightCrossPoint = line$1.getIntersection(line.default.fromPoints(PointTR, PointBR));
|
|
138
|
+
return rightCrossPoint;
|
|
139
|
+
}
|
|
140
|
+
/** 获取到边界的距离 */
|
|
141
|
+
getOuterDistance(direction) {
|
|
142
|
+
switch (direction) {
|
|
143
|
+
case "top":
|
|
144
|
+
return this.size[1] / 2 + this.innerSep.top + this.outerSep.top;
|
|
145
|
+
case "bottom":
|
|
146
|
+
return this.size[1] / 2 + this.innerSep.bottom + this.outerSep.bottom;
|
|
147
|
+
case "left":
|
|
148
|
+
return this.size[0] / 2 + this.innerSep.left + this.outerSep.left;
|
|
149
|
+
case "right":
|
|
150
|
+
return this.size[0] / 2 + this.innerSep.right + this.outerSep.right;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
/** 判断某个变量是否为初始化完成的节点 */
|
|
155
|
+
__publicField(_NodeModel, "isInitializedNode", (node) => {
|
|
156
|
+
return _NodeModel.isNode(node) && node.init;
|
|
157
|
+
});
|
|
158
|
+
__publicField(_NodeModel, "isNode", (node) => {
|
|
159
|
+
if (typeof node !== "object" || node === null) return false;
|
|
160
|
+
if (!("type" in node) || !Array.isArray(node.type)) return false;
|
|
161
|
+
return node.type.includes("node");
|
|
162
|
+
});
|
|
163
|
+
let NodeModel = _NodeModel;
|
|
164
|
+
exports.default = NodeModel;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Direction } from '../../types/coordinate';
|
|
2
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
+
import { DirectionDistance } from '../../types/distance';
|
|
4
|
+
import { Area, Size } from '../../types/shape';
|
|
5
|
+
import { RectMidPoint, RectThirdPoint, RectVertexPoint } from '../../types/shape/rect';
|
|
6
|
+
export type StateListener = (state?: NodeModel, prevState?: NodeModel) => void;
|
|
7
|
+
export type NodeConfig = {
|
|
8
|
+
/** 内容中心位置 */
|
|
9
|
+
position: Position;
|
|
10
|
+
/** 内容(文本)尺寸 */
|
|
11
|
+
contentSize: Size;
|
|
12
|
+
/** 内边框距离 */
|
|
13
|
+
innerSep: DirectionDistance;
|
|
14
|
+
/** 外边框距离 */
|
|
15
|
+
outerSep: DirectionDistance;
|
|
16
|
+
};
|
|
17
|
+
export type NodeAttribute = keyof NodeConfig;
|
|
18
|
+
export default class NodeModel {
|
|
19
|
+
type: string[];
|
|
20
|
+
/** 是否初始化节点数据, 很多节点在 layout 阶段才能初始化全部数据 */
|
|
21
|
+
init: boolean;
|
|
22
|
+
/** 节点是否已经被销毁,如果已近销毁,其他地方应该删除对节点对象的引用 */
|
|
23
|
+
disposed: boolean;
|
|
24
|
+
center: Position;
|
|
25
|
+
size: Size;
|
|
26
|
+
innerSep: DirectionDistance;
|
|
27
|
+
outerSep: DirectionDistance;
|
|
28
|
+
listeners: Set<StateListener>;
|
|
29
|
+
constructor(config: NodeConfig, init?: boolean);
|
|
30
|
+
update(config: Partial<NodeConfig>, init?: boolean): void;
|
|
31
|
+
notify(preSelf?: NodeModel): void;
|
|
32
|
+
subscribe(listener: StateListener): () => boolean;
|
|
33
|
+
dispose(): void;
|
|
34
|
+
/** 获取某个点相对于节点外边界的区域 */
|
|
35
|
+
getPointArea(point: Position): Area;
|
|
36
|
+
/** 获取外边界特殊点(中点,顶点,三等分点) */
|
|
37
|
+
getOuterPoint(point: RectVertexPoint | RectMidPoint | RectThirdPoint): Position | undefined;
|
|
38
|
+
/** 获取外部点与 node 中心连线与外边缘的交点 */
|
|
39
|
+
getCrossPoint(point: Position): Position;
|
|
40
|
+
/** 获取到边界的距离 */
|
|
41
|
+
getOuterDistance(direction: Direction): number;
|
|
42
|
+
/** 判断某个变量是否为初始化完成的节点 */
|
|
43
|
+
static isInitializedNode: (node: unknown) => boolean;
|
|
44
|
+
static isNode: (node: unknown) => boolean;
|
|
45
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
class PathModel {
|
|
7
|
+
constructor(ways, lineWidth, init = true) {
|
|
8
|
+
__publicField(this, "type", ["path"]);
|
|
9
|
+
__publicField(this, "init", false);
|
|
10
|
+
__publicField(this, "disposed", false);
|
|
11
|
+
__publicField(this, "ways", []);
|
|
12
|
+
__publicField(this, "lineWidth", 1);
|
|
13
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
14
|
+
this.update({ ways, lineWidth, init });
|
|
15
|
+
}
|
|
16
|
+
update(config) {
|
|
17
|
+
const { ways, lineWidth, init } = config;
|
|
18
|
+
const preSelf = { ...this };
|
|
19
|
+
let needUpdate = false;
|
|
20
|
+
if (!this.init && init) {
|
|
21
|
+
this.init = init;
|
|
22
|
+
needUpdate = true;
|
|
23
|
+
}
|
|
24
|
+
if (ways && ways !== this.ways) {
|
|
25
|
+
this.ways = ways;
|
|
26
|
+
needUpdate = true;
|
|
27
|
+
}
|
|
28
|
+
if (lineWidth && lineWidth !== this.lineWidth) {
|
|
29
|
+
this.lineWidth = lineWidth;
|
|
30
|
+
needUpdate = true;
|
|
31
|
+
}
|
|
32
|
+
if (this.init && needUpdate) this.notify(preSelf);
|
|
33
|
+
}
|
|
34
|
+
notify(preSelf) {
|
|
35
|
+
this.listeners.forEach((listener) => listener({ ...this }, preSelf));
|
|
36
|
+
}
|
|
37
|
+
subscribe(listener) {
|
|
38
|
+
this.listeners.add(listener);
|
|
39
|
+
return () => this.listeners.delete(listener);
|
|
40
|
+
}
|
|
41
|
+
dispose() {
|
|
42
|
+
this.listeners.clear();
|
|
43
|
+
this.disposed = true;
|
|
44
|
+
this.notify(this);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = PathModel;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
2
|
+
export type StateListener = (state?: PathModel, prevState?: PathModel) => void;
|
|
3
|
+
export default class PathModel {
|
|
4
|
+
type: string[];
|
|
5
|
+
init: boolean;
|
|
6
|
+
disposed: boolean;
|
|
7
|
+
ways: Array<Position[]>;
|
|
8
|
+
lineWidth: number;
|
|
9
|
+
listeners: Set<StateListener>;
|
|
10
|
+
constructor(ways: Array<Position[]>, lineWidth: number, init?: boolean);
|
|
11
|
+
update(config: {
|
|
12
|
+
ways?: Array<Position[]>;
|
|
13
|
+
lineWidth?: number;
|
|
14
|
+
init?: boolean;
|
|
15
|
+
}): void;
|
|
16
|
+
notify(preSelf?: PathModel): void;
|
|
17
|
+
subscribe(listener: StateListener): () => boolean;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
const _Line = class _Line {
|
|
7
|
+
constructor(a, b, c) {
|
|
8
|
+
// 一般式系数 Ax + By + C = 0,A >= 0
|
|
9
|
+
__publicField(this, "a", 0);
|
|
10
|
+
__publicField(this, "b", 0);
|
|
11
|
+
__publicField(this, "c", 0);
|
|
12
|
+
if (a === 0 && b === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.a = a;
|
|
16
|
+
this.b = b;
|
|
17
|
+
this.c = c;
|
|
18
|
+
}
|
|
19
|
+
getY(x) {
|
|
20
|
+
if (this.b === 0) return;
|
|
21
|
+
return -(this.a * x + this.c) / this.b;
|
|
22
|
+
}
|
|
23
|
+
getX(y) {
|
|
24
|
+
if (this.a === 0) return;
|
|
25
|
+
return -(this.b * y + this.c) / this.a;
|
|
26
|
+
}
|
|
27
|
+
/** 判断点是否在线上 */
|
|
28
|
+
isPointOn(point, epsilon = 1e-9) {
|
|
29
|
+
const value = this.a * point[0] + this.b * point[1] + this.c;
|
|
30
|
+
return Math.abs(value) <= epsilon;
|
|
31
|
+
}
|
|
32
|
+
/** 获取两条直线交点 */
|
|
33
|
+
getIntersection(line, epsilon = 1e-9) {
|
|
34
|
+
const A1 = this.a;
|
|
35
|
+
const B1 = this.b;
|
|
36
|
+
const C1 = this.c;
|
|
37
|
+
const A2 = line.a;
|
|
38
|
+
const B2 = line.b;
|
|
39
|
+
const C2 = line.c;
|
|
40
|
+
const D = A1 * B2 - A2 * B1;
|
|
41
|
+
if (Math.abs(D) <= epsilon) return;
|
|
42
|
+
const x = (C2 * B1 - C1 * B2) / D;
|
|
43
|
+
const y = (A2 * C1 - A1 * C2) / D;
|
|
44
|
+
return [x, y];
|
|
45
|
+
}
|
|
46
|
+
/** 点到直线距离 */
|
|
47
|
+
getPointDistance(point) {
|
|
48
|
+
return Math.abs(this.a * point[0] + this.b * point[1] + this.c) / Math.sqrt(this.a * this.a + this.b * this.b);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** 两点获取直线方程 */
|
|
52
|
+
__publicField(_Line, "fromPoints", (point1, point2) => {
|
|
53
|
+
const [x1, y1] = point1;
|
|
54
|
+
const [x2, y2] = point2;
|
|
55
|
+
const A = y2 - y1;
|
|
56
|
+
const B = x1 - x2;
|
|
57
|
+
const C = x2 * y1 - x1 * y2;
|
|
58
|
+
return new _Line(A, B, C);
|
|
59
|
+
});
|
|
60
|
+
/** 获取两点的夹角(弧度制) */
|
|
61
|
+
__publicField(_Line, "getDegree", (point1, point2) => {
|
|
62
|
+
const [x1, y1] = point1;
|
|
63
|
+
const [x2, y2] = point2;
|
|
64
|
+
return Math.atan2(y2 - y1, x2 - x1);
|
|
65
|
+
});
|
|
66
|
+
/** 根据百分比获取点位置 */
|
|
67
|
+
__publicField(_Line, "getPositionByPercent", (startPoint, endPoint, percent) => {
|
|
68
|
+
const [x1, y1] = startPoint;
|
|
69
|
+
const [x2, y2] = endPoint;
|
|
70
|
+
const dirX = x2 - x1;
|
|
71
|
+
const dirY = y2 - y1;
|
|
72
|
+
return [x1 + dirX * percent, y1 + dirY * percent];
|
|
73
|
+
});
|
|
74
|
+
let Line = _Line;
|
|
75
|
+
exports.default = Line;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
2
|
+
export default class Line {
|
|
3
|
+
private a;
|
|
4
|
+
private b;
|
|
5
|
+
private c;
|
|
6
|
+
constructor(a: number, b: number, c: number);
|
|
7
|
+
getY(x: number): number | undefined;
|
|
8
|
+
getX(y: number): number | undefined;
|
|
9
|
+
/** 判断点是否在线上 */
|
|
10
|
+
isPointOn(point: Position, epsilon?: number): boolean;
|
|
11
|
+
/** 两点获取直线方程 */
|
|
12
|
+
static fromPoints: (point1: Position, point2: Position) => Line;
|
|
13
|
+
/** 获取两点的夹角(弧度制) */
|
|
14
|
+
static getDegree: (point1: Position, point2: Position) => number;
|
|
15
|
+
/** 根据百分比获取点位置 */
|
|
16
|
+
static getPositionByPercent: (startPoint: Position, endPoint: Position, percent: number) => Position;
|
|
17
|
+
/** 获取两条直线交点 */
|
|
18
|
+
getIntersection(line: Line, epsilon?: number): Position | undefined;
|
|
19
|
+
/** 点到直线距离 */
|
|
20
|
+
getPointDistance(point: Position): number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
const PolarPoint = require("./PolarPoint.cjs");
|
|
7
|
+
const _DescartesPoint = class _DescartesPoint {
|
|
8
|
+
constructor(point) {
|
|
9
|
+
__publicField(this, "position");
|
|
10
|
+
this.position = Array.isArray(point) ? [...point] : [point.x, point.y];
|
|
11
|
+
}
|
|
12
|
+
/** 获取极坐标 */
|
|
13
|
+
getPolarPosition() {
|
|
14
|
+
return _DescartesPoint.convertPolarToDescartesPosition(this.position);
|
|
15
|
+
}
|
|
16
|
+
/** 获取极点 */
|
|
17
|
+
getPolarPoint() {
|
|
18
|
+
return new PolarPoint.default(this.getPolarPosition());
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** 将笛卡尔坐标点转换为极坐标点 */
|
|
22
|
+
__publicField(_DescartesPoint, "convertPolarToDescartesPosition", (position) => {
|
|
23
|
+
const [x, y] = position;
|
|
24
|
+
return { radius: Math.sqrt(x * x + y * y), angle: Math.atan2(y, x) };
|
|
25
|
+
});
|
|
26
|
+
/** 对象形式转换为数组形式 */
|
|
27
|
+
__publicField(_DescartesPoint, "covertToPosition", (position) => {
|
|
28
|
+
return [position.x, position.y];
|
|
29
|
+
});
|
|
30
|
+
/** 将坐标格式转换为笛卡尔坐标数组形式 */
|
|
31
|
+
__publicField(_DescartesPoint, "formatPosition", (point) => {
|
|
32
|
+
if (Array.isArray(point)) return point;
|
|
33
|
+
if (point.hasOwnProperty("x") && point.hasOwnProperty("y")) {
|
|
34
|
+
const p = point;
|
|
35
|
+
return [p.x, p.y];
|
|
36
|
+
}
|
|
37
|
+
return PolarPoint.default.convertPolarToDescartesPosition(point);
|
|
38
|
+
});
|
|
39
|
+
/** 多个点相加 */
|
|
40
|
+
__publicField(_DescartesPoint, "plus", (...positions) => {
|
|
41
|
+
return positions.reduce(
|
|
42
|
+
(acc, cur) => {
|
|
43
|
+
const formatCur = _DescartesPoint.formatPosition(cur);
|
|
44
|
+
return [acc[0] + formatCur[0], acc[1] + formatCur[1]];
|
|
45
|
+
},
|
|
46
|
+
[0, 0]
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
let DescartesPoint = _DescartesPoint;
|
|
50
|
+
exports.default = DescartesPoint;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PointPosition } from '../../../types/coordinate';
|
|
2
|
+
import { DescartesPosition, Position } from '../../../types/coordinate/descartes';
|
|
3
|
+
import { PolarPosition } from '../../../types/coordinate/polar';
|
|
4
|
+
import { default as PolarPoint } from './PolarPoint';
|
|
5
|
+
/** 笛卡尔坐标点 */
|
|
6
|
+
export default class DescartesPoint {
|
|
7
|
+
readonly position: Position;
|
|
8
|
+
constructor(point: Position | DescartesPosition);
|
|
9
|
+
/** 获取极坐标 */
|
|
10
|
+
getPolarPosition(): PolarPosition;
|
|
11
|
+
/** 获取极点 */
|
|
12
|
+
getPolarPoint(): PolarPoint;
|
|
13
|
+
/** 将笛卡尔坐标点转换为极坐标点 */
|
|
14
|
+
static convertPolarToDescartesPosition: (position: Position) => PolarPosition;
|
|
15
|
+
/** 对象形式转换为数组形式 */
|
|
16
|
+
static covertToPosition: (position: DescartesPosition) => number[];
|
|
17
|
+
/** 将坐标格式转换为笛卡尔坐标数组形式 */
|
|
18
|
+
static formatPosition: (point: PointPosition) => Position;
|
|
19
|
+
/** 多个点相加 */
|
|
20
|
+
static plus: (...positions: Array<PointPosition>) => Position;
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
const DescartesPoint = require("./DescartesPoint.cjs");
|
|
7
|
+
const _PolarPoint = class _PolarPoint {
|
|
8
|
+
constructor(point) {
|
|
9
|
+
__publicField(this, "position");
|
|
10
|
+
this.position = { radius: point.radius, angle: point.angle };
|
|
11
|
+
}
|
|
12
|
+
/** 获取笛卡尔坐标 */
|
|
13
|
+
getDescartesPosition() {
|
|
14
|
+
return _PolarPoint.convertPolarToDescartesPosition(this.position);
|
|
15
|
+
}
|
|
16
|
+
/** 获取笛卡尔点 */
|
|
17
|
+
getDescartesPoint() {
|
|
18
|
+
return new DescartesPoint.default(this.getDescartesPosition());
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** 将极坐标点转换为笛卡尔坐标点 */
|
|
22
|
+
__publicField(_PolarPoint, "convertPolarToDescartesPosition", (position) => {
|
|
23
|
+
const { radius, angle } = position;
|
|
24
|
+
return [radius * Math.cos(angle), radius * Math.sin(angle)];
|
|
25
|
+
});
|
|
26
|
+
let PolarPoint = _PolarPoint;
|
|
27
|
+
exports.default = PolarPoint;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Position } from '../../../types/coordinate/descartes';
|
|
2
|
+
import { PolarPosition } from '../../../types/coordinate/polar';
|
|
3
|
+
import { default as DescartesPoint } from './DescartesPoint';
|
|
4
|
+
/** 笛卡尔坐标点 */
|
|
5
|
+
export default class PolarPoint {
|
|
6
|
+
readonly position: PolarPosition;
|
|
7
|
+
constructor(point: PolarPosition);
|
|
8
|
+
/** 获取笛卡尔坐标 */
|
|
9
|
+
getDescartesPosition(): Position;
|
|
10
|
+
/** 获取笛卡尔点 */
|
|
11
|
+
getDescartesPoint(): DescartesPoint;
|
|
12
|
+
/** 将极坐标点转换为笛卡尔坐标点 */
|
|
13
|
+
static convertPolarToDescartesPosition: (position: PolarPosition) => Position;
|
|
14
|
+
}
|