@retikz/core 0.0.1-rc.2 → 0.1.0-alpha.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 -21
- package/dist/es/compile/compile.d.ts +27 -0
- package/dist/es/compile/compile.d.ts.map +1 -0
- package/dist/es/compile/compile.js +43 -0
- package/dist/es/compile/index.d.ts +8 -0
- package/dist/es/compile/index.d.ts.map +1 -0
- package/dist/es/compile/node.d.ts +51 -0
- package/dist/es/compile/node.d.ts.map +1 -0
- package/dist/es/compile/node.js +100 -0
- package/dist/es/compile/path.d.ts +19 -0
- package/dist/es/compile/path.d.ts.map +1 -0
- package/dist/es/compile/path.js +55 -0
- package/dist/es/compile/position.d.ts +9 -0
- package/dist/es/compile/position.d.ts.map +1 -0
- package/dist/es/compile/position.js +24 -0
- package/dist/es/compile/precision.d.ts +5 -0
- package/dist/es/compile/precision.d.ts.map +1 -0
- package/dist/es/compile/precision.js +8 -0
- package/dist/es/compile/text-metrics.d.ts +32 -0
- package/dist/es/compile/text-metrics.d.ts.map +1 -0
- package/dist/es/compile/text-metrics.js +8 -0
- package/dist/es/compile/view-box.d.ts +8 -0
- package/dist/es/compile/view-box.d.ts.map +1 -0
- package/dist/es/compile/view-box.js +31 -0
- package/dist/es/geometry/index.d.ts +4 -0
- package/dist/es/geometry/index.d.ts.map +1 -0
- package/dist/es/geometry/point.d.ts +25 -0
- package/dist/es/geometry/point.d.ts.map +1 -0
- package/dist/es/geometry/point.js +34 -0
- package/dist/es/geometry/polar.d.ts +44 -0
- package/dist/es/geometry/polar.d.ts.map +1 -0
- package/dist/es/geometry/polar.js +45 -0
- package/dist/es/geometry/rect.d.ts +59 -0
- package/dist/es/geometry/rect.d.ts.map +1 -0
- package/dist/es/geometry/rect.js +120 -0
- package/dist/es/index.d.ts +18 -10
- package/dist/es/index.d.ts.map +1 -0
- package/dist/es/index.js +14 -12
- package/dist/es/ir/index.d.ts +5 -0
- package/dist/es/ir/index.d.ts.map +1 -0
- package/dist/es/ir/node.d.ts +41 -0
- package/dist/es/ir/node.d.ts.map +1 -0
- package/dist/es/ir/node.js +19 -0
- package/dist/es/ir/path/index.d.ts +4 -0
- package/dist/es/ir/path/index.d.ts.map +1 -0
- package/dist/es/ir/path/path.d.ts +63 -0
- package/dist/es/ir/path/path.d.ts.map +1 -0
- package/dist/es/ir/path/path.js +12 -0
- package/dist/es/ir/path/step.d.ts +62 -0
- package/dist/es/ir/path/step.d.ts.map +1 -0
- package/dist/es/ir/path/step.js +16 -0
- package/dist/es/ir/path/target.d.ts +5 -0
- package/dist/es/ir/path/target.d.ts.map +1 -0
- package/dist/es/ir/path/target.js +11 -0
- package/dist/es/ir/position/index.d.ts +3 -0
- package/dist/es/ir/position/index.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.d.ts +9 -0
- package/dist/es/ir/position/polar-position.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.js +18 -0
- package/dist/es/ir/position/position.d.ts +5 -0
- package/dist/es/ir/position/position.d.ts.map +1 -0
- package/dist/es/ir/position/position.js +5 -0
- package/dist/es/ir/scene.d.ts +262 -0
- package/dist/es/ir/scene.d.ts.map +1 -0
- package/dist/es/ir/scene.js +14 -0
- package/dist/es/parsers/index.d.ts +2 -0
- package/dist/es/parsers/index.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.d.ts +25 -0
- package/dist/es/parsers/parseWay.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.js +30 -0
- package/dist/es/primitive/group.d.ts +11 -0
- package/dist/es/primitive/group.d.ts.map +1 -0
- package/dist/es/primitive/index.d.ts +7 -0
- package/dist/es/primitive/index.d.ts.map +1 -0
- package/dist/es/primitive/path.d.ts +22 -0
- package/dist/es/primitive/path.d.ts.map +1 -0
- package/dist/es/primitive/rect.d.ts +28 -0
- package/dist/es/primitive/rect.d.ts.map +1 -0
- package/dist/es/primitive/scene.d.ts +20 -0
- package/dist/es/primitive/scene.d.ts.map +1 -0
- package/dist/es/primitive/text.d.ts +32 -0
- package/dist/es/primitive/text.d.ts.map +1 -0
- package/dist/es/primitive/view-box.d.ts +12 -0
- package/dist/es/primitive/view-box.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +43 -0
- package/dist/lib/compile/compile.d.ts +27 -0
- package/dist/lib/compile/compile.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +8 -0
- package/dist/lib/compile/index.d.ts.map +1 -0
- package/dist/lib/compile/node.cjs +102 -0
- package/dist/lib/compile/node.d.ts +51 -0
- package/dist/lib/compile/node.d.ts.map +1 -0
- package/dist/lib/compile/path.cjs +55 -0
- package/dist/lib/compile/path.d.ts +19 -0
- package/dist/lib/compile/path.d.ts.map +1 -0
- package/dist/lib/compile/position.cjs +24 -0
- package/dist/lib/compile/position.d.ts +9 -0
- package/dist/lib/compile/position.d.ts.map +1 -0
- package/dist/lib/compile/precision.cjs +8 -0
- package/dist/lib/compile/precision.d.ts +5 -0
- package/dist/lib/compile/precision.d.ts.map +1 -0
- package/dist/lib/compile/text-metrics.cjs +8 -0
- package/dist/lib/compile/text-metrics.d.ts +32 -0
- package/dist/lib/compile/text-metrics.d.ts.map +1 -0
- package/dist/lib/compile/view-box.cjs +31 -0
- package/dist/lib/compile/view-box.d.ts +8 -0
- package/dist/lib/compile/view-box.d.ts.map +1 -0
- package/dist/lib/geometry/index.d.ts +4 -0
- package/dist/lib/geometry/index.d.ts.map +1 -0
- package/dist/lib/geometry/point.cjs +34 -0
- package/dist/lib/geometry/point.d.ts +25 -0
- package/dist/lib/geometry/point.d.ts.map +1 -0
- package/dist/lib/geometry/polar.cjs +45 -0
- package/dist/lib/geometry/polar.d.ts +44 -0
- package/dist/lib/geometry/polar.d.ts.map +1 -0
- package/dist/lib/geometry/rect.cjs +121 -0
- package/dist/lib/geometry/rect.d.ts +59 -0
- package/dist/lib/geometry/rect.d.ts.map +1 -0
- package/dist/lib/index.cjs +31 -11
- package/dist/lib/index.d.ts +18 -10
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +5 -0
- package/dist/lib/ir/index.d.ts.map +1 -0
- package/dist/lib/ir/node.cjs +19 -0
- package/dist/lib/ir/node.d.ts +41 -0
- package/dist/lib/ir/node.d.ts.map +1 -0
- package/dist/lib/ir/path/index.d.ts +4 -0
- package/dist/lib/ir/path/index.d.ts.map +1 -0
- package/dist/lib/ir/path/path.cjs +12 -0
- package/dist/lib/ir/path/path.d.ts +63 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -0
- package/dist/lib/ir/path/step.cjs +18 -0
- package/dist/lib/ir/path/step.d.ts +62 -0
- package/dist/lib/ir/path/step.d.ts.map +1 -0
- package/dist/lib/ir/path/target.cjs +11 -0
- package/dist/lib/ir/path/target.d.ts +5 -0
- package/dist/lib/ir/path/target.d.ts.map +1 -0
- package/dist/lib/ir/position/index.d.ts +3 -0
- package/dist/lib/ir/position/index.d.ts.map +1 -0
- package/dist/lib/ir/position/polar-position.cjs +18 -0
- package/dist/lib/ir/position/polar-position.d.ts +9 -0
- package/dist/lib/ir/position/polar-position.d.ts.map +1 -0
- package/dist/lib/ir/position/position.cjs +5 -0
- package/dist/lib/ir/position/position.d.ts +5 -0
- package/dist/lib/ir/position/position.d.ts.map +1 -0
- package/dist/lib/ir/scene.cjs +16 -0
- package/dist/lib/ir/scene.d.ts +262 -0
- package/dist/lib/ir/scene.d.ts.map +1 -0
- package/dist/lib/parsers/index.d.ts +2 -0
- package/dist/lib/parsers/index.d.ts.map +1 -0
- package/dist/lib/parsers/parseWay.cjs +30 -0
- package/dist/lib/parsers/parseWay.d.ts +25 -0
- package/dist/lib/parsers/parseWay.d.ts.map +1 -0
- package/dist/lib/primitive/group.d.ts +11 -0
- package/dist/lib/primitive/group.d.ts.map +1 -0
- package/dist/lib/primitive/index.d.ts +7 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/path.d.ts +22 -0
- package/dist/lib/primitive/path.d.ts.map +1 -0
- package/dist/lib/primitive/rect.d.ts +28 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -0
- package/dist/lib/primitive/scene.d.ts +20 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -0
- package/dist/lib/primitive/text.d.ts +32 -0
- package/dist/lib/primitive/text.d.ts.map +1 -0
- package/dist/lib/primitive/view-box.d.ts +12 -0
- package/dist/lib/primitive/view-box.d.ts.map +1 -0
- package/package.json +21 -29
- package/README.md +0 -2
- package/dist/es/components/Scope.d.ts +0 -6
- package/dist/es/components/Scope.js +0 -12
- package/dist/es/components/TikZ.d.ts +0 -9
- package/dist/es/components/TikZ.js +0 -12
- package/dist/es/components/draw/Draw.d.ts +0 -26
- package/dist/es/components/draw/Draw.js +0 -59
- package/dist/es/components/draw/InnerDraw.d.ts +0 -17
- package/dist/es/components/draw/InnerDraw.js +0 -52
- package/dist/es/components/draw/arrow/circle.d.ts +0 -7
- package/dist/es/components/draw/arrow/circle.js +0 -20
- package/dist/es/components/draw/arrow/index.d.ts +0 -9
- package/dist/es/components/draw/arrow/index.js +0 -13
- package/dist/es/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/es/components/draw/arrow/stealth.js +0 -29
- package/dist/es/components/draw/arrow/types.d.ts +0 -21
- package/dist/es/components/draw/common.d.ts +0 -4
- package/dist/es/components/draw/common.js +0 -12
- package/dist/es/components/draw/index.d.ts +0 -3
- package/dist/es/components/draw/index.js +0 -4
- package/dist/es/components/draw/segment/Segment.d.ts +0 -12
- package/dist/es/components/draw/segment/Segment.js +0 -41
- package/dist/es/components/draw/segment/index.d.ts +0 -15
- package/dist/es/components/draw/segment/index.js +0 -41
- package/dist/es/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/es/components/draw/segment/useArrow.js +0 -52
- package/dist/es/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/es/components/draw/segment/useConvertWay.js +0 -110
- package/dist/es/components/draw/types.d.ts +0 -29
- package/dist/es/components/node/InnerNode.d.ts +0 -33
- package/dist/es/components/node/InnerNode.js +0 -88
- package/dist/es/components/node/Node.d.ts +0 -93
- package/dist/es/components/node/Node.js +0 -88
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/es/components/node/_hooks/useNodeConfig.js +0 -13
- package/dist/es/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeContent.js +0 -30
- package/dist/es/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeShape.js +0 -34
- package/dist/es/components/node/index.d.ts +0 -3
- package/dist/es/components/node/index.js +0 -4
- package/dist/es/components/path-node/PathNode.d.ts +0 -48
- package/dist/es/components/path-node/PathNode.js +0 -76
- package/dist/es/components/path-node/index.d.ts +0 -3
- package/dist/es/components/path-node/index.js +0 -4
- package/dist/es/components/path-node/useAnchor.d.ts +0 -6
- package/dist/es/components/path-node/useAnchor.js +0 -49
- package/dist/es/container/Group.d.ts +0 -6
- package/dist/es/container/Group.js +0 -8
- package/dist/es/container/Surface.d.ts +0 -19
- package/dist/es/container/Surface.js +0 -23
- package/dist/es/elements/Path.d.ts +0 -4
- package/dist/es/elements/Path.js +0 -14
- package/dist/es/elements/Rect.d.ts +0 -4
- package/dist/es/elements/Rect.js +0 -9
- package/dist/es/elements/Text.d.ts +0 -18
- package/dist/es/elements/Text.js +0 -35
- package/dist/es/hooks/context/useCalculate.d.ts +0 -7
- package/dist/es/hooks/context/useCalculate.js +0 -9
- package/dist/es/hooks/context/useNodes.d.ts +0 -9
- package/dist/es/hooks/context/useNodes.js +0 -33
- package/dist/es/hooks/context/usePath.d.ts +0 -13
- package/dist/es/hooks/context/usePath.js +0 -20
- package/dist/es/hooks/context/useScope.d.ts +0 -11
- package/dist/es/hooks/context/useScope.js +0 -7
- package/dist/es/hooks/useForceUpdate.d.ts +0 -2
- package/dist/es/hooks/useForceUpdate.js +0 -8
- package/dist/es/model/component/node.d.ts +0 -45
- package/dist/es/model/component/node.js +0 -164
- package/dist/es/model/component/path.d.ts +0 -19
- package/dist/es/model/component/path.js +0 -47
- package/dist/es/model/equation/line.d.ts +0 -21
- package/dist/es/model/equation/line.js +0 -76
- package/dist/es/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/es/model/geometry/point/DescartesPoint.js +0 -50
- package/dist/es/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/es/model/geometry/point/PolarPoint.js +0 -27
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +0 -338
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +0 -13
- package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +0 -88
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +0 -6
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +0 -8
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +0 -39
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +0 -41
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +0 -19
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +0 -10
- package/dist/es/test.d.ts +0 -1
- package/dist/es/types/coordinate/descartes.d.ts +0 -23
- package/dist/es/types/coordinate/index.d.ts +0 -5
- package/dist/es/types/coordinate/polar.d.ts +0 -5
- package/dist/es/types/distance/index.d.ts +0 -8
- package/dist/es/types/distance/sep.d.ts +0 -9
- package/dist/es/types/shape/index.d.ts +0 -8
- package/dist/es/types/shape/index.js +0 -9
- package/dist/es/types/shape/rect.d.ts +0 -25
- package/dist/es/types/shape/rect.js +0 -30
- package/dist/es/types/svg/font.d.ts +0 -10
- package/dist/es/types/svg/stroke.d.ts +0 -10
- package/dist/es/types/tikz/index.d.ts +0 -6
- package/dist/es/utils/compare.d.ts +0 -4
- package/dist/es/utils/compare.js +0 -20
- package/dist/es/utils/css.d.ts +0 -6
- package/dist/es/utils/css.js +0 -26
- package/dist/es/utils/math.d.ts +0 -9
- package/dist/es/utils/math.js +0 -26
- package/dist/es/utils/string.d.ts +0 -7
- package/dist/es/utils/string.js +0 -7
- package/dist/es/utils/style/font.d.ts +0 -17
- package/dist/es/utils/style/font.js +0 -34
- package/dist/es/utils/style/stroke.d.ts +0 -20
- package/dist/es/utils/style/stroke.js +0 -42
- package/dist/lib/components/Scope.cjs +0 -12
- package/dist/lib/components/Scope.d.ts +0 -6
- package/dist/lib/components/TikZ.cjs +0 -12
- package/dist/lib/components/TikZ.d.ts +0 -9
- package/dist/lib/components/draw/Draw.cjs +0 -59
- package/dist/lib/components/draw/Draw.d.ts +0 -26
- package/dist/lib/components/draw/InnerDraw.cjs +0 -52
- package/dist/lib/components/draw/InnerDraw.d.ts +0 -17
- package/dist/lib/components/draw/arrow/circle.cjs +0 -20
- package/dist/lib/components/draw/arrow/circle.d.ts +0 -7
- package/dist/lib/components/draw/arrow/index.cjs +0 -13
- package/dist/lib/components/draw/arrow/index.d.ts +0 -9
- package/dist/lib/components/draw/arrow/stealth.cjs +0 -29
- package/dist/lib/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/lib/components/draw/arrow/types.d.ts +0 -21
- package/dist/lib/components/draw/common.cjs +0 -12
- package/dist/lib/components/draw/common.d.ts +0 -4
- package/dist/lib/components/draw/index.cjs +0 -4
- package/dist/lib/components/draw/index.d.ts +0 -3
- package/dist/lib/components/draw/segment/Segment.cjs +0 -41
- package/dist/lib/components/draw/segment/Segment.d.ts +0 -12
- package/dist/lib/components/draw/segment/index.cjs +0 -41
- package/dist/lib/components/draw/segment/index.d.ts +0 -15
- package/dist/lib/components/draw/segment/useArrow.cjs +0 -52
- package/dist/lib/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/lib/components/draw/segment/useConvertWay.cjs +0 -110
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/lib/components/draw/types.d.ts +0 -29
- package/dist/lib/components/node/InnerNode.cjs +0 -88
- package/dist/lib/components/node/InnerNode.d.ts +0 -33
- package/dist/lib/components/node/Node.cjs +0 -88
- package/dist/lib/components/node/Node.d.ts +0 -93
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +0 -13
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +0 -30
- package/dist/lib/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +0 -34
- package/dist/lib/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/lib/components/node/index.cjs +0 -4
- package/dist/lib/components/node/index.d.ts +0 -3
- package/dist/lib/components/path-node/PathNode.cjs +0 -76
- package/dist/lib/components/path-node/PathNode.d.ts +0 -48
- package/dist/lib/components/path-node/index.cjs +0 -4
- package/dist/lib/components/path-node/index.d.ts +0 -3
- package/dist/lib/components/path-node/useAnchor.cjs +0 -49
- package/dist/lib/components/path-node/useAnchor.d.ts +0 -6
- package/dist/lib/container/Group.cjs +0 -8
- package/dist/lib/container/Group.d.ts +0 -6
- package/dist/lib/container/Surface.cjs +0 -23
- package/dist/lib/container/Surface.d.ts +0 -19
- package/dist/lib/elements/Path.cjs +0 -14
- package/dist/lib/elements/Path.d.ts +0 -4
- package/dist/lib/elements/Rect.cjs +0 -9
- package/dist/lib/elements/Rect.d.ts +0 -4
- package/dist/lib/elements/Text.cjs +0 -35
- package/dist/lib/elements/Text.d.ts +0 -18
- package/dist/lib/hooks/context/useCalculate.cjs +0 -9
- package/dist/lib/hooks/context/useCalculate.d.ts +0 -7
- package/dist/lib/hooks/context/useNodes.cjs +0 -33
- package/dist/lib/hooks/context/useNodes.d.ts +0 -9
- package/dist/lib/hooks/context/usePath.cjs +0 -20
- package/dist/lib/hooks/context/usePath.d.ts +0 -13
- package/dist/lib/hooks/context/useScope.cjs +0 -7
- package/dist/lib/hooks/context/useScope.d.ts +0 -11
- package/dist/lib/hooks/useForceUpdate.cjs +0 -8
- package/dist/lib/hooks/useForceUpdate.d.ts +0 -2
- package/dist/lib/model/component/node.cjs +0 -164
- package/dist/lib/model/component/node.d.ts +0 -45
- package/dist/lib/model/component/path.cjs +0 -47
- package/dist/lib/model/component/path.d.ts +0 -19
- package/dist/lib/model/equation/line.cjs +0 -76
- package/dist/lib/model/equation/line.d.ts +0 -21
- package/dist/lib/model/geometry/point/DescartesPoint.cjs +0 -50
- package/dist/lib/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/lib/model/geometry/point/PolarPoint.cjs +0 -27
- package/dist/lib/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +0 -338
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +0 -13
- package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +0 -88
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +0 -6
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +0 -8
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +0 -39
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +0 -41
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +0 -19
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +0 -10
- package/dist/lib/test.d.ts +0 -1
- package/dist/lib/types/coordinate/descartes.d.ts +0 -23
- package/dist/lib/types/coordinate/index.d.ts +0 -5
- package/dist/lib/types/coordinate/polar.d.ts +0 -5
- package/dist/lib/types/distance/index.d.ts +0 -8
- package/dist/lib/types/distance/sep.d.ts +0 -9
- package/dist/lib/types/shape/index.cjs +0 -9
- package/dist/lib/types/shape/index.d.ts +0 -8
- package/dist/lib/types/shape/rect.cjs +0 -30
- package/dist/lib/types/shape/rect.d.ts +0 -25
- package/dist/lib/types/svg/font.d.ts +0 -10
- package/dist/lib/types/svg/stroke.d.ts +0 -10
- package/dist/lib/types/tikz/index.d.ts +0 -6
- package/dist/lib/utils/compare.cjs +0 -20
- package/dist/lib/utils/compare.d.ts +0 -4
- package/dist/lib/utils/css.cjs +0 -26
- package/dist/lib/utils/css.d.ts +0 -6
- package/dist/lib/utils/math.cjs +0 -26
- package/dist/lib/utils/math.d.ts +0 -9
- package/dist/lib/utils/string.cjs +0 -7
- package/dist/lib/utils/string.d.ts +0 -7
- package/dist/lib/utils/style/font.cjs +0 -34
- package/dist/lib/utils/style/font.d.ts +0 -17
- package/dist/lib/utils/style/stroke.cjs +0 -42
- package/dist/lib/utils/style/stroke.d.ts +0 -20
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 pionpill
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 pionpill
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IR } from '../ir';
|
|
2
|
+
import { Scene } from '../primitive';
|
|
3
|
+
import { TextMeasurer } from './text-metrics';
|
|
4
|
+
/** compileToScene 的可选参数 */
|
|
5
|
+
export type CompileOptions = {
|
|
6
|
+
/** 注入文字度量函数;不传则用 fallback(不准但可跑) */
|
|
7
|
+
measureText?: TextMeasurer;
|
|
8
|
+
/** viewBox 周围的留白(user units),默认 10 */
|
|
9
|
+
padding?: number;
|
|
10
|
+
/**
|
|
11
|
+
* 输出坐标的小数位精度;默认 2(保留 2 位小数四舍五入)。
|
|
12
|
+
* 仅在写入 Scene primitive / path d 字符串 / viewBox 时生效;
|
|
13
|
+
* 内部几何计算保持完整 double 精度,避免误差累积。
|
|
14
|
+
*/
|
|
15
|
+
precision?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* IR → Scene。纯函数。
|
|
19
|
+
* 这是所有 adapter 共享的最深层共享代码。
|
|
20
|
+
*
|
|
21
|
+
* 流程:
|
|
22
|
+
* 1. Pass 1:按 IR children 源码顺序处理 Node——计算 layout、注册 nodeIndex、发出 RectPrim/TextPrim、累积 bbox 角点
|
|
23
|
+
* 2. Pass 2:处理 Path——解析每个 step 端点(节点 ref 走 boundaryPoint,其他走 resolvePosition),写 d 字符串
|
|
24
|
+
* 3. 末端用 computeViewBox 折算最终 viewBox(按 precision 四舍五入)
|
|
25
|
+
*/
|
|
26
|
+
export declare const compileToScene: (ir: IR, options?: CompileOptions) => Scene;
|
|
27
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,cAAc,CAAC;AAI1D,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAGrE,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KA2CrE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { rect } from "../geometry/rect.js";
|
|
2
|
+
import { emitNodePrimitives, layoutNode } from "./node.js";
|
|
3
|
+
import { emitPathPrimitive } from "./path.js";
|
|
4
|
+
import { makeRound } from "./precision.js";
|
|
5
|
+
import { fallbackMeasurer } from "./text-metrics.js";
|
|
6
|
+
import { computeViewBox } from "./view-box.js";
|
|
7
|
+
//#region src/compile/compile.ts
|
|
8
|
+
/**
|
|
9
|
+
* IR → Scene。纯函数。
|
|
10
|
+
* 这是所有 adapter 共享的最深层共享代码。
|
|
11
|
+
*
|
|
12
|
+
* 流程:
|
|
13
|
+
* 1. Pass 1:按 IR children 源码顺序处理 Node——计算 layout、注册 nodeIndex、发出 RectPrim/TextPrim、累积 bbox 角点
|
|
14
|
+
* 2. Pass 2:处理 Path——解析每个 step 端点(节点 ref 走 boundaryPoint,其他走 resolvePosition),写 d 字符串
|
|
15
|
+
* 3. 末端用 computeViewBox 折算最终 viewBox(按 precision 四舍五入)
|
|
16
|
+
*/
|
|
17
|
+
var compileToScene = (ir, options = {}) => {
|
|
18
|
+
const measureText = options.measureText ?? fallbackMeasurer;
|
|
19
|
+
const viewBoxPadding = options.padding ?? 10;
|
|
20
|
+
const round = makeRound(options.precision ?? 2);
|
|
21
|
+
const primitives = [];
|
|
22
|
+
const nodeIndex = /* @__PURE__ */ new Map();
|
|
23
|
+
const allPoints = [];
|
|
24
|
+
for (const child of ir.children) if (child.type === "node") {
|
|
25
|
+
const layout = layoutNode(child, measureText, nodeIndex);
|
|
26
|
+
if (child.id) nodeIndex.set(child.id, layout);
|
|
27
|
+
for (const prim of emitNodePrimitives(layout, round)) primitives.push(prim);
|
|
28
|
+
allPoints.push(rect.anchor(layout.rect, "north-west"), rect.anchor(layout.rect, "north-east"), rect.anchor(layout.rect, "south-west"), rect.anchor(layout.rect, "south-east"));
|
|
29
|
+
}
|
|
30
|
+
for (const child of ir.children) if (child.type === "path") {
|
|
31
|
+
const result = emitPathPrimitive(child, nodeIndex, round);
|
|
32
|
+
if (result) {
|
|
33
|
+
primitives.push(result.primitive);
|
|
34
|
+
for (const p of result.points) allPoints.push(p);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
primitives,
|
|
39
|
+
viewBox: computeViewBox(allPoints, viewBoxPadding, round)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { compileToScene };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compile/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Rect } from '../geometry/rect';
|
|
2
|
+
import { IRNode } from '../ir';
|
|
3
|
+
import { ScenePrimitive } from '../primitive';
|
|
4
|
+
import { TextMeasurer } from './text-metrics';
|
|
5
|
+
export type NodeLayout = {
|
|
6
|
+
/** 节点 id(如 IR Node 提供);其他位置可通过 id 引用本节点 */
|
|
7
|
+
id?: string;
|
|
8
|
+
/** 节点几何盒(x, y 是几何中心,rotate 是弧度,见 packages/core/AGENTS.md) */
|
|
9
|
+
rect: Rect;
|
|
10
|
+
/** IR 中原始的旋转角(度数),保留供 emit 阶段写 SVG transform */
|
|
11
|
+
rotateDeg: number;
|
|
12
|
+
/** 外边距(user units,≥ 0);path 附着到 rect 外扩 margin 的虚拟 attachRect 上 */
|
|
13
|
+
margin: number;
|
|
14
|
+
/** 节点文本内容;空字符串视为无文本(undefined) */
|
|
15
|
+
text?: string;
|
|
16
|
+
/** 文本宽度(user units),由 TextMeasurer 算出 */
|
|
17
|
+
textWidth: number;
|
|
18
|
+
/** 文本高度(user units),由 TextMeasurer 算出 */
|
|
19
|
+
textHeight: number;
|
|
20
|
+
/** 文本字号(user units) */
|
|
21
|
+
fontSize: number;
|
|
22
|
+
/** 节点矩形背景色,CSS 颜色字符串;emit 时用 'transparent' 兜底 */
|
|
23
|
+
fill?: string;
|
|
24
|
+
/** 节点矩形边框色,CSS 颜色字符串;emit 时用 'currentColor' 兜底 */
|
|
25
|
+
stroke?: string;
|
|
26
|
+
/** 节点矩形边框宽度(user units);emit 时用 1 兜底 */
|
|
27
|
+
strokeWidth?: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 取节点的"附着 rect"——用于 path 端点贴边的几何盒。
|
|
31
|
+
* 在视觉 rect 基础上每边外扩 margin,保持中心与旋转不变。
|
|
32
|
+
* margin = 0 时直接返回视觉 rect 自身(避免无意义复制)。
|
|
33
|
+
*/
|
|
34
|
+
export declare const attachRectOf: (layout: NodeLayout) => Rect;
|
|
35
|
+
/**
|
|
36
|
+
* 把 IR Node 解析为内部 NodeLayout:
|
|
37
|
+
* - 算出文本度量与 padding 推导出的视觉 rect 尺寸
|
|
38
|
+
* - 解析 position(笛卡尔或极坐标)为几何中心
|
|
39
|
+
* - IR 的 rotate(度数)转弧度存进 Rect.rotate
|
|
40
|
+
* - 透传 margin / 样式属性
|
|
41
|
+
*/
|
|
42
|
+
export declare const layoutNode: (node: IRNode, measureText: TextMeasurer, nodeIndex: Map<string, NodeLayout>) => NodeLayout;
|
|
43
|
+
/**
|
|
44
|
+
* 把 NodeLayout 翻译为 Scene primitives:
|
|
45
|
+
* - rect(背景边框;x/y 转为 SVG 风格的左上角)
|
|
46
|
+
* - text(如有内容)
|
|
47
|
+
* - 若有旋转,外面套一层 GroupPrim 用 SVG `rotate(deg cx cy)` 实现,
|
|
48
|
+
* 内层 RectPrim/TextPrim 自身保持轴对齐
|
|
49
|
+
*/
|
|
50
|
+
export declare const emitNodePrimitives: (layout: NodeLayout, round: (n: number) => number) => Array<ScenePrimitive>;
|
|
51
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMnD,MAAM,MAAM,UAAU,GAAG;IACvB,2CAA2C;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,IAAI,EAAE,IAAI,CAAC;IACX,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,UAAU,KAAG,IASjD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,aAAa,YAAY,EACzB,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,KACjC,UAqCF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B,KAAK,CAAC,cAAc,CAuCtB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { resolvePosition } from "./position.js";
|
|
2
|
+
//#region src/compile/node.ts
|
|
3
|
+
var DEFAULT_FONT_SIZE = 14;
|
|
4
|
+
var DEFAULT_PADDING = 8;
|
|
5
|
+
var DEG_TO_RAD = Math.PI / 180;
|
|
6
|
+
/**
|
|
7
|
+
* 取节点的"附着 rect"——用于 path 端点贴边的几何盒。
|
|
8
|
+
* 在视觉 rect 基础上每边外扩 margin,保持中心与旋转不变。
|
|
9
|
+
* margin = 0 时直接返回视觉 rect 自身(避免无意义复制)。
|
|
10
|
+
*/
|
|
11
|
+
var attachRectOf = (layout) => {
|
|
12
|
+
if (layout.margin === 0) return layout.rect;
|
|
13
|
+
return {
|
|
14
|
+
x: layout.rect.x,
|
|
15
|
+
y: layout.rect.y,
|
|
16
|
+
width: layout.rect.width + 2 * layout.margin,
|
|
17
|
+
height: layout.rect.height + 2 * layout.margin,
|
|
18
|
+
rotate: layout.rect.rotate
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 把 IR Node 解析为内部 NodeLayout:
|
|
23
|
+
* - 算出文本度量与 padding 推导出的视觉 rect 尺寸
|
|
24
|
+
* - 解析 position(笛卡尔或极坐标)为几何中心
|
|
25
|
+
* - IR 的 rotate(度数)转弧度存进 Rect.rotate
|
|
26
|
+
* - 透传 margin / 样式属性
|
|
27
|
+
*/
|
|
28
|
+
var layoutNode = (node, measureText, nodeIndex) => {
|
|
29
|
+
const fontSize = node.fontSize ?? DEFAULT_FONT_SIZE;
|
|
30
|
+
const padding = node.padding ?? DEFAULT_PADDING;
|
|
31
|
+
const metrics = node.text ? measureText(node.text, { size: fontSize }) : {
|
|
32
|
+
width: 0,
|
|
33
|
+
height: 0
|
|
34
|
+
};
|
|
35
|
+
const width = Math.max(metrics.width + padding * 2, padding * 2);
|
|
36
|
+
const height = Math.max(metrics.height + padding * 2, padding * 2);
|
|
37
|
+
const rotateDeg = node.rotate ?? 0;
|
|
38
|
+
const center = resolvePosition(node.position, nodeIndex);
|
|
39
|
+
if (!center) throw new Error(`Cannot resolve position for node ${node.id ?? "(unnamed)"}; polar.origin may reference an undefined node`);
|
|
40
|
+
return {
|
|
41
|
+
id: node.id,
|
|
42
|
+
rect: {
|
|
43
|
+
x: center[0],
|
|
44
|
+
y: center[1],
|
|
45
|
+
width,
|
|
46
|
+
height,
|
|
47
|
+
rotate: rotateDeg * DEG_TO_RAD
|
|
48
|
+
},
|
|
49
|
+
rotateDeg,
|
|
50
|
+
margin: node.margin ?? 0,
|
|
51
|
+
text: node.text,
|
|
52
|
+
textWidth: metrics.width,
|
|
53
|
+
textHeight: metrics.height,
|
|
54
|
+
fontSize,
|
|
55
|
+
fill: node.fill,
|
|
56
|
+
stroke: node.stroke,
|
|
57
|
+
strokeWidth: node.strokeWidth
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* 把 NodeLayout 翻译为 Scene primitives:
|
|
62
|
+
* - rect(背景边框;x/y 转为 SVG 风格的左上角)
|
|
63
|
+
* - text(如有内容)
|
|
64
|
+
* - 若有旋转,外面套一层 GroupPrim 用 SVG `rotate(deg cx cy)` 实现,
|
|
65
|
+
* 内层 RectPrim/TextPrim 自身保持轴对齐
|
|
66
|
+
*/
|
|
67
|
+
var emitNodePrimitives = (layout, round) => {
|
|
68
|
+
const halfW = layout.rect.width / 2;
|
|
69
|
+
const halfH = layout.rect.height / 2;
|
|
70
|
+
const inner = [{
|
|
71
|
+
type: "rect",
|
|
72
|
+
x: round(layout.rect.x - halfW),
|
|
73
|
+
y: round(layout.rect.y - halfH),
|
|
74
|
+
width: round(layout.rect.width),
|
|
75
|
+
height: round(layout.rect.height),
|
|
76
|
+
fill: layout.fill ?? "transparent",
|
|
77
|
+
stroke: layout.stroke ?? "currentColor",
|
|
78
|
+
strokeWidth: layout.strokeWidth ?? 1
|
|
79
|
+
}];
|
|
80
|
+
if (layout.text) inner.push({
|
|
81
|
+
type: "text",
|
|
82
|
+
x: round(layout.rect.x),
|
|
83
|
+
y: round(layout.rect.y),
|
|
84
|
+
content: layout.text,
|
|
85
|
+
fontSize: layout.fontSize,
|
|
86
|
+
align: "middle",
|
|
87
|
+
baseline: "middle",
|
|
88
|
+
fill: "currentColor",
|
|
89
|
+
measuredWidth: round(layout.textWidth),
|
|
90
|
+
measuredHeight: round(layout.textHeight)
|
|
91
|
+
});
|
|
92
|
+
if (layout.rotateDeg === 0) return inner;
|
|
93
|
+
return [{
|
|
94
|
+
type: "group",
|
|
95
|
+
transform: `rotate(${round(layout.rotateDeg)} ${round(layout.rect.x)} ${round(layout.rect.y)})`,
|
|
96
|
+
children: inner
|
|
97
|
+
}];
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { attachRectOf, emitNodePrimitives, layoutNode };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IRPath, IRPosition } from '../ir';
|
|
2
|
+
import { ScenePrimitive } from '../primitive';
|
|
3
|
+
import { NodeLayout } from './node';
|
|
4
|
+
/**
|
|
5
|
+
* 把 IR Path 翻译为单个 PathPrim。
|
|
6
|
+
* 算法:
|
|
7
|
+
* 1. 第一遍:把每个 step.to 解析为"参考点"(节点中心 / 直接坐标 / 极坐标解算后),
|
|
8
|
+
* 用于给邻居 step 算节点边界点的方向;
|
|
9
|
+
* 2. 第二遍:算每个 step 的实际终点——节点引用调用 boundaryPoint 贴 attachRect;
|
|
10
|
+
* 其他形态直接用解析后的笛卡尔。
|
|
11
|
+
* 3. 把点序列写成 SVG path d 字符串。
|
|
12
|
+
*
|
|
13
|
+
* 引用未定义节点时返回 null(path 整体跳过)。
|
|
14
|
+
*/
|
|
15
|
+
export declare const emitPathPrimitive: (path: IRPath, nodeIndex: Map<string, NodeLayout>, round: (n: number) => number) => {
|
|
16
|
+
primitive: ScenePrimitive;
|
|
17
|
+
points: Array<IRPosition>;
|
|
18
|
+
} | null;
|
|
19
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/compile/path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAY,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,QAAQ,CAAC;AAcvD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAClC,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,IA6C7D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { rect } from "../geometry/rect.js";
|
|
2
|
+
import { resolvePosition } from "./position.js";
|
|
3
|
+
import { attachRectOf } from "./node.js";
|
|
4
|
+
//#region src/compile/path.ts
|
|
5
|
+
/**
|
|
6
|
+
* 求一个 step.to 的"参考点"——给邻居 step 算节点边界方向用:
|
|
7
|
+
* - string(节点 ref) → 节点中心
|
|
8
|
+
* - Position / PolarPosition → 解析后的笛卡尔
|
|
9
|
+
* 解析失败返回 null(与 resolvePosition 一致)。
|
|
10
|
+
*/
|
|
11
|
+
var refPointOfTarget = (target, nodeIndex) => resolvePosition(target, nodeIndex);
|
|
12
|
+
/**
|
|
13
|
+
* 把 IR Path 翻译为单个 PathPrim。
|
|
14
|
+
* 算法:
|
|
15
|
+
* 1. 第一遍:把每个 step.to 解析为"参考点"(节点中心 / 直接坐标 / 极坐标解算后),
|
|
16
|
+
* 用于给邻居 step 算节点边界点的方向;
|
|
17
|
+
* 2. 第二遍:算每个 step 的实际终点——节点引用调用 boundaryPoint 贴 attachRect;
|
|
18
|
+
* 其他形态直接用解析后的笛卡尔。
|
|
19
|
+
* 3. 把点序列写成 SVG path d 字符串。
|
|
20
|
+
*
|
|
21
|
+
* 引用未定义节点时返回 null(path 整体跳过)。
|
|
22
|
+
*/
|
|
23
|
+
var emitPathPrimitive = (path, nodeIndex, round) => {
|
|
24
|
+
const steps = path.children;
|
|
25
|
+
if (steps.length < 2) return null;
|
|
26
|
+
const refPoints = steps.map((s) => refPointOfTarget(s.to, nodeIndex));
|
|
27
|
+
const points = [];
|
|
28
|
+
for (let i = 0; i < steps.length; i++) {
|
|
29
|
+
const target = steps[i].to;
|
|
30
|
+
if (typeof target === "string") {
|
|
31
|
+
const node = nodeIndex.get(target);
|
|
32
|
+
if (!node) return null;
|
|
33
|
+
const neighbor = i > 0 ? refPoints[i - 1] : i + 1 < steps.length ? refPoints[i + 1] : null;
|
|
34
|
+
if (!neighbor) points.push([node.rect.x, node.rect.y]);
|
|
35
|
+
else points.push(rect.boundaryPoint(attachRectOf(node), neighbor));
|
|
36
|
+
} else {
|
|
37
|
+
const resolved = resolvePosition(target, nodeIndex);
|
|
38
|
+
if (!resolved) return null;
|
|
39
|
+
points.push(resolved);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
primitive: {
|
|
44
|
+
type: "path",
|
|
45
|
+
d: points.map((p, i) => `${i === 0 ? "M" : "L"} ${round(p[0])} ${round(p[1])}`).join(" "),
|
|
46
|
+
stroke: path.stroke ?? "currentColor",
|
|
47
|
+
strokeWidth: path.strokeWidth ?? 1,
|
|
48
|
+
fill: "none",
|
|
49
|
+
strokeDasharray: path.strokeDasharray
|
|
50
|
+
},
|
|
51
|
+
points
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { emitPathPrimitive };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IRPosition, PolarPosition } from '../ir';
|
|
2
|
+
import { NodeLayout } from './node';
|
|
3
|
+
/**
|
|
4
|
+
* 把 IR 里出现的位置形态(笛卡尔 / 极坐标 / 节点 id)解析为笛卡尔位置。
|
|
5
|
+
* 极坐标的 origin 可递归 / 可引用节点 id;按节点定义顺序处理(前向引用要求节点先定义)。
|
|
6
|
+
* 解析失败返回 null(如引用了未定义节点)。
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolvePosition: (pos: IRPosition | PolarPosition | string, nodeMap: Map<string, NodeLayout>) => IRPosition | null;
|
|
9
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/compile/position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,UAAU,GAAG,aAAa,GAAG,MAAM,EACxC,SAAS,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,KAC/B,UAAU,GAAG,IAoBf,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/compile/position.ts
|
|
2
|
+
/**
|
|
3
|
+
* 把 IR 里出现的位置形态(笛卡尔 / 极坐标 / 节点 id)解析为笛卡尔位置。
|
|
4
|
+
* 极坐标的 origin 可递归 / 可引用节点 id;按节点定义顺序处理(前向引用要求节点先定义)。
|
|
5
|
+
* 解析失败返回 null(如引用了未定义节点)。
|
|
6
|
+
*/
|
|
7
|
+
var resolvePosition = (pos, nodeMap) => {
|
|
8
|
+
if (typeof pos === "string") {
|
|
9
|
+
const node = nodeMap.get(pos);
|
|
10
|
+
return node ? [node.rect.x, node.rect.y] : null;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(pos)) return pos;
|
|
13
|
+
let origin;
|
|
14
|
+
if (!pos.origin) origin = [0, 0];
|
|
15
|
+
else {
|
|
16
|
+
const resolved = resolvePosition(pos.origin, nodeMap);
|
|
17
|
+
if (!resolved) return null;
|
|
18
|
+
origin = resolved;
|
|
19
|
+
}
|
|
20
|
+
const rad = pos.angle * Math.PI / 180;
|
|
21
|
+
return [origin[0] + Math.cos(rad) * pos.radius, origin[1] + Math.sin(rad) * pos.radius];
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { resolvePosition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,sCAAsC;AACtC,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAClB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** 字体规格:传给 TextMeasurer 的最小信息 */
|
|
2
|
+
export type FontSpec = {
|
|
3
|
+
/** 字体族;不填走 fallback "sans-serif" */
|
|
4
|
+
family?: string;
|
|
5
|
+
/** 字号(user units) */
|
|
6
|
+
size: number;
|
|
7
|
+
/** 字重;可以是 'normal' / 'bold' / 100~900 数字等 */
|
|
8
|
+
weight?: string | number;
|
|
9
|
+
/** 字形:normal 或 italic */
|
|
10
|
+
style?: 'normal' | 'italic';
|
|
11
|
+
};
|
|
12
|
+
/** 文字度量结果:宽高 + 可选的基线 ascent/descent */
|
|
13
|
+
export type TextMetrics = {
|
|
14
|
+
/** 文本宽度(user units) */
|
|
15
|
+
width: number;
|
|
16
|
+
/** 文本高度(user units),通常 ≈ ascent + descent */
|
|
17
|
+
height: number;
|
|
18
|
+
/** 基线以上的高度;不一定所有 measurer 都返回 */
|
|
19
|
+
ascent?: number;
|
|
20
|
+
/** 基线以下的深度;不一定所有 measurer 都返回 */
|
|
21
|
+
descent?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 文字度量函数接口(编译期由 adapter 注入)。
|
|
25
|
+
* - @retikz/react:用 canvas measureText
|
|
26
|
+
* - @retikz/ssr:用 opentype.js / fontkit
|
|
27
|
+
* - @retikz/canvas:用 ctx.measureText
|
|
28
|
+
*/
|
|
29
|
+
export type TextMeasurer = (text: string, font: FontSpec) => TextMetrics;
|
|
30
|
+
/** 默认 fallback 度量:基于平均字宽估算,不准但保证可运行 */
|
|
31
|
+
export declare const fallbackMeasurer: TextMeasurer;
|
|
32
|
+
//# sourceMappingURL=text-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-metrics.d.ts","sourceRoot":"","sources":["../../../src/compile/text-metrics.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG;IACrB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,yBAAyB;IACzB,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC7B,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,WAAW,CAAC;AAEzE,uCAAuC;AACvC,eAAO,MAAM,gBAAgB,EAAE,YAG7B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IRPosition } from '../ir';
|
|
2
|
+
import { ViewBox } from '../primitive';
|
|
3
|
+
/**
|
|
4
|
+
* 由所有"贡献给 bbox"的点算出 viewBox(含四周 padding)。
|
|
5
|
+
* points 为空时返回固定的 100×100 兜底框。
|
|
6
|
+
*/
|
|
7
|
+
export declare const computeViewBox: (points: Array<IRPosition>, padding: number, round: (n: number) => number) => ViewBox;
|
|
8
|
+
//# sourceMappingURL=view-box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-box.d.ts","sourceRoot":"","sources":["../../../src/compile/view-box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,KAAK,CAAC,UAAU,CAAC,EACzB,SAAS,MAAM,EACf,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B,OAkBF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/compile/view-box.ts
|
|
2
|
+
/**
|
|
3
|
+
* 由所有"贡献给 bbox"的点算出 viewBox(含四周 padding)。
|
|
4
|
+
* points 为空时返回固定的 100×100 兜底框。
|
|
5
|
+
*/
|
|
6
|
+
var computeViewBox = (points, padding, round) => {
|
|
7
|
+
if (points.length === 0) return {
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
width: 100,
|
|
11
|
+
height: 100
|
|
12
|
+
};
|
|
13
|
+
let minX = Infinity;
|
|
14
|
+
let minY = Infinity;
|
|
15
|
+
let maxX = -Infinity;
|
|
16
|
+
let maxY = -Infinity;
|
|
17
|
+
for (const [x, y] of points) {
|
|
18
|
+
if (x < minX) minX = x;
|
|
19
|
+
if (y < minY) minY = y;
|
|
20
|
+
if (x > maxX) maxX = x;
|
|
21
|
+
if (y > maxY) maxY = y;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
x: round(minX - padding),
|
|
25
|
+
y: round(minY - padding),
|
|
26
|
+
width: round(maxX - minX + padding * 2),
|
|
27
|
+
height: round(maxY - minY + padding * 2)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { computeViewBox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PolarPosition } from './polar';
|
|
2
|
+
/** 笛卡尔坐标点 [x, y] */
|
|
3
|
+
export type Position = [number, number];
|
|
4
|
+
/** 二维向量 / 坐标的基础运算工具集 */
|
|
5
|
+
export declare const point: {
|
|
6
|
+
/** 两点相加(向量加法):a + b */
|
|
7
|
+
add: (a: Position, b: Position) => Position;
|
|
8
|
+
/** 两点相减(向量减法):a - b */
|
|
9
|
+
sub: (a: Position, b: Position) => Position;
|
|
10
|
+
/** 等比缩放:a * k */
|
|
11
|
+
scale: (a: Position, k: number) => Position;
|
|
12
|
+
/** 判断两点坐标是否完全相等(精确比较,不带容差) */
|
|
13
|
+
equal: (a: Position, b: Position) => boolean;
|
|
14
|
+
/** 笛卡尔点 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
|
|
15
|
+
toPolar: (p: Position) => PolarPosition;
|
|
16
|
+
/**
|
|
17
|
+
* 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition;
|
|
18
|
+
* 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
|
|
19
|
+
* `polar.equal` 委托到本方法。
|
|
20
|
+
* @param precision 小数点后位数;默认 2
|
|
21
|
+
* @throws 当 PolarPosition 的 origin 是节点 id 字符串时——字符串解析需 Scene 上下文
|
|
22
|
+
*/
|
|
23
|
+
equalPolar: (a: Position | PolarPosition, b: Position | PolarPosition, precision?: number) => boolean;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=point.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAS,MAAM,SAAS,CAAC;AAEpD,oBAAoB;AACpB,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAIxC,wBAAwB;AACxB,eAAO,MAAM,KAAK;IAChB,uBAAuB;aACd,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,uBAAuB;aACd,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,iBAAiB;eACN,QAAQ,KAAK,MAAM,KAAG,QAAQ;IACzC,8BAA8B;eACnB,QAAQ,KAAK,QAAQ,KAAG,OAAO;IAC1C,yDAAyD;iBAC5C,QAAQ,KAAG,aAAa;IAIrC;;;;;;OAMG;oBAEE,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CASX,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { polar } from "./polar.js";
|
|
2
|
+
//#region src/geometry/point.ts
|
|
3
|
+
var RAD_TO_DEG = 180 / Math.PI;
|
|
4
|
+
/** 二维向量 / 坐标的基础运算工具集 */
|
|
5
|
+
var point = {
|
|
6
|
+
/** 两点相加(向量加法):a + b */
|
|
7
|
+
add: (a, b) => [a[0] + b[0], a[1] + b[1]],
|
|
8
|
+
/** 两点相减(向量减法):a - b */
|
|
9
|
+
sub: (a, b) => [a[0] - b[0], a[1] - b[1]],
|
|
10
|
+
/** 等比缩放:a * k */
|
|
11
|
+
scale: (a, k) => [a[0] * k, a[1] * k],
|
|
12
|
+
/** 判断两点坐标是否完全相等(精确比较,不带容差) */
|
|
13
|
+
equal: (a, b) => a[0] === b[0] && a[1] === b[1],
|
|
14
|
+
/** 笛卡尔点 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
|
|
15
|
+
toPolar: (p) => ({
|
|
16
|
+
angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
|
|
17
|
+
radius: Math.hypot(p[0], p[1])
|
|
18
|
+
}),
|
|
19
|
+
/**
|
|
20
|
+
* 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition;
|
|
21
|
+
* 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
|
|
22
|
+
* `polar.equal` 委托到本方法。
|
|
23
|
+
* @param precision 小数点后位数;默认 2
|
|
24
|
+
* @throws 当 PolarPosition 的 origin 是节点 id 字符串时——字符串解析需 Scene 上下文
|
|
25
|
+
*/
|
|
26
|
+
equalPolar: (a, b, precision = 2) => {
|
|
27
|
+
const aCart = Array.isArray(a) ? a : polar.toPosition(a);
|
|
28
|
+
const bCart = Array.isArray(b) ? b : polar.toPosition(b);
|
|
29
|
+
const factor = 10 ** precision;
|
|
30
|
+
return Math.round(aCart[0] * factor) === Math.round(bCart[0] * factor) && Math.round(aCart[1] * factor) === Math.round(bCart[1] * factor);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { point };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Position } from './point';
|
|
2
|
+
/**
|
|
3
|
+
* 极坐标点:相对 origin 的角度 + 半径偏移。
|
|
4
|
+
* - 可进 IR;Scene 编译时统一解析为笛卡尔
|
|
5
|
+
* - 不直接参与几何计算,参与时先转为 Position(见本文件顶部说明)
|
|
6
|
+
* - origin 可嵌套(PolarPosition),可引用节点 id(string),可直接给坐标(Position),省略表示原点 [0, 0]
|
|
7
|
+
*/
|
|
8
|
+
export type PolarPosition = {
|
|
9
|
+
/** 极坐标原点:节点 id / 笛卡尔位置 / 嵌套极坐标;省略表示 [0, 0] */
|
|
10
|
+
origin?: string | Position | PolarPosition;
|
|
11
|
+
/** 角度(度数,逆时针为正,与 TikZ / 数学习惯一致) */
|
|
12
|
+
angle: number;
|
|
13
|
+
/** 半径(user units,应为非负) */
|
|
14
|
+
radius: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 极坐标 ↔ 笛卡尔坐标 转换工具集。
|
|
18
|
+
*
|
|
19
|
+
* 注意 polar 不参与几何计算——参与计算时一律先用 `polar.toPosition` 转成 Position。
|
|
20
|
+
* 详见本文件顶部的整体说明。
|
|
21
|
+
*/
|
|
22
|
+
export declare const polar: {
|
|
23
|
+
/**
|
|
24
|
+
* 极坐标 → 笛卡尔位置(递归处理 origin)。
|
|
25
|
+
* **限制**:origin 为字符串(节点 id)时本方法无法解析,会抛错——
|
|
26
|
+
* 字符串解析依赖 Scene 编译器的 nodeIndex 上下文。
|
|
27
|
+
*/
|
|
28
|
+
toPosition: (p: PolarPosition) => Position;
|
|
29
|
+
/** 笛卡尔位置 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
|
|
30
|
+
fromPosition: (p: Position) => PolarPosition;
|
|
31
|
+
/** 在某个原点附近按极坐标偏移;返回结果点的世界笛卡尔坐标 */
|
|
32
|
+
offsetFrom: (origin: Position, offset: {
|
|
33
|
+
angle: number;
|
|
34
|
+
radius: number;
|
|
35
|
+
}) => Position;
|
|
36
|
+
/**
|
|
37
|
+
* 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition;
|
|
38
|
+
* 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
|
|
39
|
+
* 实际是 `point.equalPolar` 的别名(同一份实现,两处可发现)。
|
|
40
|
+
* @param precision 小数点后位数;默认 2
|
|
41
|
+
*/
|
|
42
|
+
equal: (a: Position | PolarPosition, b: Position | PolarPosition, precision?: number) => boolean;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=polar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polar.d.ts","sourceRoot":"","sources":["../../../src/geometry/polar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAS,MAAM,SAAS,CAAC;AAkB/C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC3C,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;OAIG;oBACa,aAAa,KAAG,QAAQ;IAmBxC,0DAA0D;sBACxC,QAAQ,KAAG,aAAa;IAI1C,kCAAkC;yBAExB,QAAQ,UACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KACxC,QAAQ;IAOX;;;;;OAKG;eAEE,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CACX,CAAC"}
|