@retikz/core 0.3.0-alpha.5 → 0.3.0-beta.2
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/dist/es/arrows/define.d.ts +9 -0
- package/dist/es/arrows/define.d.ts.map +1 -0
- package/dist/es/arrows/define.js +10 -0
- package/dist/es/arrows/index.d.ts +3 -1
- package/dist/es/arrows/index.d.ts.map +1 -1
- package/dist/es/arrows/index.js +15 -2
- package/dist/es/arrows/types.d.ts +4 -2
- package/dist/es/arrows/types.d.ts.map +1 -1
- package/dist/es/compile/anchor-cache.d.ts +3 -3
- package/dist/es/compile/anchor-cache.d.ts.map +1 -1
- package/dist/es/compile/anchor-cache.js +18 -5
- package/dist/es/compile/compile.d.ts +5 -14
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +46 -43
- package/dist/es/compile/{lowerComposites.d.ts → composite.d.ts} +9 -2
- package/dist/es/compile/composite.d.ts.map +1 -0
- package/dist/es/compile/{lowerComposites.js → composite.js} +9 -1
- package/dist/es/compile/constant.d.ts +30 -0
- package/dist/es/compile/constant.d.ts.map +1 -0
- package/dist/es/compile/constant.js +21 -0
- package/dist/es/compile/direction.d.ts +27 -0
- package/dist/es/compile/direction.d.ts.map +1 -0
- package/dist/es/compile/direction.js +30 -0
- package/dist/es/compile/index.d.ts +3 -1
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/name-stack.d.ts +3 -1
- package/dist/es/compile/name-stack.d.ts.map +1 -1
- package/dist/es/compile/name-stack.js +5 -1
- package/dist/es/compile/node.d.ts +19 -8
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +56 -70
- package/dist/es/compile/paint.js +1 -1
- package/dist/es/compile/path/anchor.d.ts +4 -3
- package/dist/es/compile/path/anchor.d.ts.map +1 -1
- package/dist/es/compile/path/anchor.js +9 -12
- package/dist/es/compile/path/index.d.ts +6 -8
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +97 -44
- package/dist/es/compile/path/label.d.ts.map +1 -1
- package/dist/es/compile/path/label.js +8 -4
- package/dist/es/compile/path/relative.d.ts +1 -1
- package/dist/es/compile/path/relative.js +1 -1
- package/dist/es/compile/path/shrink.d.ts +3 -1
- package/dist/es/compile/path/shrink.d.ts.map +1 -1
- package/dist/es/compile/path/shrink.js +16 -11
- package/dist/es/compile/position.d.ts +2 -2
- package/dist/es/compile/position.d.ts.map +1 -1
- package/dist/es/compile/position.js +6 -19
- package/dist/es/compile/precision.d.ts +1 -1
- package/dist/es/compile/precision.d.ts.map +1 -1
- package/dist/es/compile/precision.js +2 -2
- package/dist/es/compile/scope.d.ts +7 -5
- package/dist/es/compile/scope.d.ts.map +1 -1
- package/dist/es/compile/scope.js +44 -16
- package/dist/es/compile/style.d.ts +2 -2
- package/dist/es/compile/style.d.ts.map +1 -1
- package/dist/es/compile/style.js +2 -2
- package/dist/es/compile/text-metrics.d.ts +1 -1
- package/dist/es/compile/text-metrics.js +2 -2
- package/dist/es/composites/define.d.ts +8 -0
- package/dist/es/composites/define.d.ts.map +1 -0
- package/dist/es/composites/{types.js → define.js} +2 -2
- package/dist/es/composites/index.d.ts +1 -1
- package/dist/es/composites/index.d.ts.map +1 -1
- package/dist/es/composites/types.d.ts +0 -6
- package/dist/es/composites/types.d.ts.map +1 -1
- package/dist/es/geometry/anchor.d.ts +33 -0
- package/dist/es/geometry/anchor.d.ts.map +1 -0
- package/dist/es/geometry/anchor.js +45 -0
- package/dist/es/geometry/bend.d.ts +1 -1
- package/dist/es/geometry/bend.js +3 -3
- package/dist/es/geometry/circle.d.ts +4 -4
- package/dist/es/geometry/circle.d.ts.map +1 -1
- package/dist/es/geometry/circle.js +3 -3
- package/dist/es/geometry/{roundedContour.d.ts → contour.d.ts} +9 -5
- package/dist/es/geometry/contour.d.ts.map +1 -0
- package/dist/es/geometry/{roundedContour.js → contour.js} +27 -37
- package/dist/es/geometry/diamond.d.ts +10 -4
- package/dist/es/geometry/diamond.d.ts.map +1 -1
- package/dist/es/geometry/diamond.js +11 -3
- package/dist/{lib/geometry/_edge.d.ts → es/geometry/edge.d.ts} +1 -1
- package/dist/es/geometry/edge.d.ts.map +1 -0
- package/dist/es/geometry/{_edge.js → edge.js} +1 -1
- package/dist/es/geometry/ellipse.d.ts +3 -3
- package/dist/es/geometry/ellipse.d.ts.map +1 -1
- package/dist/es/geometry/ellipse.js +4 -2
- package/dist/es/geometry/index.d.ts +6 -1
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/geometry/point.d.ts +6 -0
- package/dist/es/geometry/point.d.ts.map +1 -1
- package/dist/es/geometry/point.js +17 -0
- package/dist/es/geometry/rect.d.ts +4 -17
- package/dist/es/geometry/rect.d.ts.map +1 -1
- package/dist/es/geometry/rect.js +4 -16
- package/dist/es/geometry/segment.d.ts +7 -0
- package/dist/es/geometry/segment.d.ts.map +1 -1
- package/dist/es/geometry/segment.js +48 -47
- package/dist/{lib/geometry/_transform.d.ts → es/geometry/transform.d.ts} +1 -1
- package/dist/es/geometry/transform.d.ts.map +1 -0
- package/dist/es/geometry/{_transform.js → transform.js} +1 -1
- package/dist/es/index.d.ts +13 -13
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +20 -16
- package/dist/es/ir/animation.d.ts +26 -125
- package/dist/es/ir/animation.d.ts.map +1 -1
- package/dist/es/ir/animation.js +6 -6
- package/dist/es/ir/boundary.d.ts +4 -10
- package/dist/es/ir/boundary.d.ts.map +1 -1
- package/dist/es/ir/clip.d.ts +6 -46
- package/dist/es/ir/clip.d.ts.map +1 -1
- package/dist/es/ir/composite.d.ts +2 -14
- package/dist/es/ir/composite.d.ts.map +1 -1
- package/dist/es/ir/coordinate.d.ts +14 -50
- package/dist/es/ir/coordinate.d.ts.map +1 -1
- package/dist/es/ir/coordinate.js +1 -1
- package/dist/es/ir/font.d.ts +10 -13
- package/dist/es/ir/font.d.ts.map +1 -1
- package/dist/es/ir/json.d.ts +1 -1
- package/dist/es/ir/json.d.ts.map +1 -1
- package/dist/es/ir/json.js +1 -1
- package/dist/es/ir/node.d.ts +175 -821
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +23 -23
- package/dist/es/ir/paint.d.ts +23 -100
- package/dist/es/ir/paint.d.ts.map +1 -1
- package/dist/es/ir/paint.js +10 -10
- package/dist/es/ir/path/arrow.d.ts +19 -131
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +18 -16
- package/dist/es/ir/path/path.d.ts +519 -3065
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +3 -3
- package/dist/es/ir/path/step.d.ts +929 -3474
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +74 -23
- package/dist/es/ir/path/target.d.ts +40 -121
- package/dist/es/ir/path/target.d.ts.map +1 -1
- package/dist/es/ir/path/target.js +3 -3
- package/dist/es/ir/position/at-position.d.ts +20 -28
- package/dist/es/ir/position/at-position.d.ts.map +1 -1
- package/dist/es/ir/position/at-position.js +11 -11
- package/dist/es/ir/position/offset-position.d.ts +2 -8
- package/dist/es/ir/position/offset-position.d.ts.map +1 -1
- package/dist/es/ir/scene.d.ts +17 -181
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/scope.d.ts +315 -7291
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +10 -7
- package/dist/es/ir/shape.d.ts +2 -8
- package/dist/es/ir/shape.d.ts.map +1 -1
- package/dist/es/ir/text.d.ts +24 -70
- package/dist/es/ir/text.d.ts.map +1 -1
- package/dist/es/ir/transform.d.ts +47 -144
- package/dist/es/ir/transform.d.ts.map +1 -1
- package/dist/es/ir/transform.js +12 -5
- package/dist/es/parsers/index.d.ts +3 -3
- package/dist/es/parsers/index.d.ts.map +1 -1
- package/dist/es/parsers/{parseNodeTarget.d.ts → node-target.d.ts} +1 -1
- package/dist/es/parsers/node-target.d.ts.map +1 -0
- package/dist/es/parsers/{parseNodeTarget.js → node-target.js} +10 -8
- package/dist/{lib/parsers/parseTargetSugar.d.ts → es/parsers/target-sugar.d.ts} +1 -1
- package/dist/es/parsers/target-sugar.d.ts.map +1 -0
- package/dist/es/parsers/{parseTargetSugar.js → target-sugar.js} +9 -4
- package/dist/{lib/parsers/parseWay.d.ts → es/parsers/way.d.ts} +2 -2
- package/dist/es/parsers/way.d.ts.map +1 -0
- package/dist/es/parsers/{parseWay.js → way.js} +10 -6
- package/dist/es/path-generators/define.d.ts.map +1 -0
- package/dist/es/{pathGenerators → path-generators}/define.js +1 -1
- package/dist/es/path-generators/index.d.ts.map +1 -0
- package/dist/es/path-generators/types.d.ts.map +1 -0
- package/dist/es/patterns/define.d.ts +9 -0
- package/dist/es/patterns/define.d.ts.map +1 -0
- package/dist/es/patterns/define.js +10 -0
- package/dist/es/patterns/index.d.ts +1 -0
- package/dist/es/patterns/index.d.ts.map +1 -1
- package/dist/es/patterns/index.js +42 -35
- package/dist/es/presets/animation.js +2 -2
- package/dist/es/primitive/marker.d.ts +7 -7
- package/dist/es/primitive/marker.d.ts.map +1 -1
- package/dist/es/primitive/paint.d.ts +1 -1
- package/dist/es/primitive/path.d.ts +1 -1
- package/dist/es/shapes/arc.d.ts.map +1 -1
- package/dist/es/shapes/arc.js +24 -5
- package/dist/{lib/shapes/_contour.d.ts → es/shapes/contour.d.ts} +6 -3
- package/dist/es/shapes/contour.d.ts.map +1 -0
- package/dist/es/shapes/{_contour.js → contour.js} +14 -2
- package/dist/es/shapes/ellipse.js +2 -2
- package/dist/es/shapes/index.d.ts +1 -1
- package/dist/es/shapes/index.d.ts.map +1 -1
- package/dist/es/shapes/index.js +1 -1
- package/dist/es/shapes/polygon.d.ts +1 -1
- package/dist/es/shapes/polygon.d.ts.map +1 -1
- package/dist/es/shapes/polygon.js +26 -21
- package/dist/es/shapes/rectangle.js +6 -6
- package/dist/es/shapes/sector.d.ts.map +1 -1
- package/dist/es/shapes/sector.js +30 -22
- package/dist/es/shapes/{_shared.d.ts → shared.d.ts} +7 -10
- package/dist/es/shapes/shared.d.ts.map +1 -0
- package/dist/es/shapes/{_shared.js → shared.js} +13 -15
- package/dist/es/shapes/star.d.ts.map +1 -1
- package/dist/es/shapes/star.js +6 -15
- package/dist/es/shapes/types.d.ts +10 -3
- package/dist/es/shapes/types.d.ts.map +1 -1
- package/dist/es/types.d.ts +1 -1
- package/dist/lib/arrows/define.cjs +10 -0
- package/dist/lib/arrows/define.d.ts +9 -0
- package/dist/lib/arrows/define.d.ts.map +1 -0
- package/dist/lib/arrows/index.cjs +15 -2
- package/dist/lib/arrows/index.d.ts +3 -1
- package/dist/lib/arrows/index.d.ts.map +1 -1
- package/dist/lib/arrows/types.d.ts +4 -2
- package/dist/lib/arrows/types.d.ts.map +1 -1
- package/dist/lib/compile/anchor-cache.cjs +17 -4
- package/dist/lib/compile/anchor-cache.d.ts +3 -3
- package/dist/lib/compile/anchor-cache.d.ts.map +1 -1
- package/dist/lib/compile/compile.cjs +44 -41
- package/dist/lib/compile/compile.d.ts +5 -14
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/{lowerComposites.cjs → composite.cjs} +9 -1
- package/dist/lib/compile/{lowerComposites.d.ts → composite.d.ts} +9 -2
- package/dist/lib/compile/composite.d.ts.map +1 -0
- package/dist/lib/compile/constant.cjs +22 -0
- package/dist/lib/compile/constant.d.ts +30 -0
- package/dist/lib/compile/constant.d.ts.map +1 -0
- package/dist/lib/compile/direction.cjs +31 -0
- package/dist/lib/compile/direction.d.ts +27 -0
- package/dist/lib/compile/direction.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +3 -1
- package/dist/lib/compile/index.d.ts.map +1 -1
- package/dist/lib/compile/name-stack.cjs +5 -1
- package/dist/lib/compile/name-stack.d.ts +3 -1
- package/dist/lib/compile/name-stack.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +56 -69
- package/dist/lib/compile/node.d.ts +19 -8
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/paint.cjs +1 -1
- package/dist/lib/compile/path/anchor.cjs +10 -12
- package/dist/lib/compile/path/anchor.d.ts +4 -3
- package/dist/lib/compile/path/anchor.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +95 -42
- package/dist/lib/compile/path/index.d.ts +6 -8
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/compile/path/label.cjs +8 -4
- package/dist/lib/compile/path/label.d.ts.map +1 -1
- package/dist/lib/compile/path/relative.cjs +1 -1
- package/dist/lib/compile/path/relative.d.ts +1 -1
- package/dist/lib/compile/path/shrink.cjs +16 -11
- package/dist/lib/compile/path/shrink.d.ts +3 -1
- package/dist/lib/compile/path/shrink.d.ts.map +1 -1
- package/dist/lib/compile/position.cjs +6 -19
- package/dist/lib/compile/position.d.ts +2 -2
- package/dist/lib/compile/position.d.ts.map +1 -1
- package/dist/lib/compile/precision.cjs +2 -2
- package/dist/lib/compile/precision.d.ts +1 -1
- package/dist/lib/compile/precision.d.ts.map +1 -1
- package/dist/lib/compile/scope.cjs +44 -16
- package/dist/lib/compile/scope.d.ts +7 -5
- package/dist/lib/compile/scope.d.ts.map +1 -1
- package/dist/lib/compile/style.cjs +2 -2
- package/dist/lib/compile/style.d.ts +2 -2
- package/dist/lib/compile/style.d.ts.map +1 -1
- package/dist/lib/compile/text-metrics.cjs +2 -2
- package/dist/lib/compile/text-metrics.d.ts +1 -1
- package/dist/lib/composites/{types.cjs → define.cjs} +2 -2
- package/dist/lib/composites/define.d.ts +8 -0
- package/dist/lib/composites/define.d.ts.map +1 -0
- package/dist/lib/composites/index.d.ts +1 -1
- package/dist/lib/composites/index.d.ts.map +1 -1
- package/dist/lib/composites/types.d.ts +0 -6
- package/dist/lib/composites/types.d.ts.map +1 -1
- package/dist/lib/geometry/anchor.cjs +47 -0
- package/dist/lib/geometry/anchor.d.ts +33 -0
- package/dist/lib/geometry/anchor.d.ts.map +1 -0
- package/dist/lib/geometry/bend.cjs +3 -3
- package/dist/lib/geometry/bend.d.ts +1 -1
- package/dist/lib/geometry/circle.cjs +9 -9
- package/dist/lib/geometry/circle.d.ts +4 -4
- package/dist/lib/geometry/circle.d.ts.map +1 -1
- package/dist/lib/geometry/{roundedContour.cjs → contour.cjs} +26 -35
- package/dist/lib/geometry/{roundedContour.d.ts → contour.d.ts} +9 -5
- package/dist/lib/geometry/contour.d.ts.map +1 -0
- package/dist/lib/geometry/diamond.cjs +16 -8
- package/dist/lib/geometry/diamond.d.ts +10 -4
- package/dist/lib/geometry/diamond.d.ts.map +1 -1
- package/dist/lib/geometry/{_edge.cjs → edge.cjs} +1 -1
- package/dist/{es/geometry/_edge.d.ts → lib/geometry/edge.d.ts} +1 -1
- package/dist/lib/geometry/edge.d.ts.map +1 -0
- package/dist/lib/geometry/ellipse.cjs +10 -8
- package/dist/lib/geometry/ellipse.d.ts +3 -3
- package/dist/lib/geometry/ellipse.d.ts.map +1 -1
- package/dist/lib/geometry/index.d.ts +6 -1
- package/dist/lib/geometry/index.d.ts.map +1 -1
- package/dist/lib/geometry/point.cjs +17 -0
- package/dist/lib/geometry/point.d.ts +6 -0
- package/dist/lib/geometry/point.d.ts.map +1 -1
- package/dist/lib/geometry/rect.cjs +9 -22
- package/dist/lib/geometry/rect.d.ts +4 -17
- package/dist/lib/geometry/rect.d.ts.map +1 -1
- package/dist/lib/geometry/segment.cjs +48 -46
- package/dist/lib/geometry/segment.d.ts +7 -0
- package/dist/lib/geometry/segment.d.ts.map +1 -1
- package/dist/lib/geometry/{_transform.cjs → transform.cjs} +1 -1
- package/dist/{es/geometry/_transform.d.ts → lib/geometry/transform.d.ts} +1 -1
- package/dist/lib/geometry/transform.d.ts.map +1 -0
- package/dist/lib/index.cjs +35 -22
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/animation.cjs +6 -6
- package/dist/lib/ir/animation.d.ts +26 -125
- package/dist/lib/ir/animation.d.ts.map +1 -1
- package/dist/lib/ir/boundary.d.ts +4 -10
- package/dist/lib/ir/boundary.d.ts.map +1 -1
- package/dist/lib/ir/clip.d.ts +6 -46
- package/dist/lib/ir/clip.d.ts.map +1 -1
- package/dist/lib/ir/composite.d.ts +2 -14
- package/dist/lib/ir/composite.d.ts.map +1 -1
- package/dist/lib/ir/coordinate.cjs +1 -1
- package/dist/lib/ir/coordinate.d.ts +14 -50
- package/dist/lib/ir/coordinate.d.ts.map +1 -1
- package/dist/lib/ir/font.d.ts +10 -13
- package/dist/lib/ir/font.d.ts.map +1 -1
- package/dist/lib/ir/json.cjs +1 -1
- package/dist/lib/ir/json.d.ts +1 -1
- package/dist/lib/ir/json.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +23 -23
- package/dist/lib/ir/node.d.ts +175 -821
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/paint.cjs +10 -10
- package/dist/lib/ir/paint.d.ts +23 -100
- package/dist/lib/ir/paint.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +18 -16
- package/dist/lib/ir/path/arrow.d.ts +19 -131
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +4 -2
- package/dist/lib/ir/path/path.d.ts +519 -3065
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +74 -22
- package/dist/lib/ir/path/step.d.ts +929 -3474
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +3 -3
- package/dist/lib/ir/path/target.d.ts +40 -121
- package/dist/lib/ir/path/target.d.ts.map +1 -1
- package/dist/lib/ir/position/at-position.cjs +11 -11
- package/dist/lib/ir/position/at-position.d.ts +20 -28
- package/dist/lib/ir/position/at-position.d.ts.map +1 -1
- package/dist/lib/ir/position/offset-position.d.ts +2 -8
- package/dist/lib/ir/position/offset-position.d.ts.map +1 -1
- package/dist/lib/ir/scene.d.ts +17 -181
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +10 -7
- package/dist/lib/ir/scope.d.ts +315 -7291
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/ir/shape.d.ts +2 -8
- package/dist/lib/ir/shape.d.ts.map +1 -1
- package/dist/lib/ir/text.d.ts +24 -70
- package/dist/lib/ir/text.d.ts.map +1 -1
- package/dist/lib/ir/transform.cjs +11 -4
- package/dist/lib/ir/transform.d.ts +47 -144
- package/dist/lib/ir/transform.d.ts.map +1 -1
- package/dist/lib/parsers/index.d.ts +3 -3
- package/dist/lib/parsers/index.d.ts.map +1 -1
- package/dist/lib/parsers/{parseNodeTarget.cjs → node-target.cjs} +10 -8
- package/dist/lib/parsers/{parseNodeTarget.d.ts → node-target.d.ts} +1 -1
- package/dist/lib/parsers/node-target.d.ts.map +1 -0
- package/dist/lib/parsers/{parseTargetSugar.cjs → target-sugar.cjs} +9 -4
- package/dist/{es/parsers/parseTargetSugar.d.ts → lib/parsers/target-sugar.d.ts} +1 -1
- package/dist/lib/parsers/target-sugar.d.ts.map +1 -0
- package/dist/lib/parsers/{parseWay.cjs → way.cjs} +13 -9
- package/dist/{es/parsers/parseWay.d.ts → lib/parsers/way.d.ts} +2 -2
- package/dist/lib/parsers/way.d.ts.map +1 -0
- package/dist/lib/{pathGenerators → path-generators}/define.cjs +1 -1
- package/dist/lib/path-generators/define.d.ts.map +1 -0
- package/dist/lib/path-generators/index.d.ts.map +1 -0
- package/dist/lib/path-generators/types.d.ts.map +1 -0
- package/dist/lib/patterns/define.cjs +10 -0
- package/dist/lib/patterns/define.d.ts +9 -0
- package/dist/lib/patterns/define.d.ts.map +1 -0
- package/dist/lib/patterns/index.cjs +42 -35
- package/dist/lib/patterns/index.d.ts +1 -0
- package/dist/lib/patterns/index.d.ts.map +1 -1
- package/dist/lib/presets/animation.cjs +2 -2
- package/dist/lib/primitive/marker.d.ts +7 -7
- package/dist/lib/primitive/marker.d.ts.map +1 -1
- package/dist/lib/primitive/paint.d.ts +1 -1
- package/dist/lib/primitive/path.d.ts +1 -1
- package/dist/lib/shapes/arc.cjs +26 -7
- package/dist/lib/shapes/arc.d.ts.map +1 -1
- package/dist/lib/shapes/{_contour.cjs → contour.cjs} +14 -1
- package/dist/{es/shapes/_contour.d.ts → lib/shapes/contour.d.ts} +6 -3
- package/dist/lib/shapes/contour.d.ts.map +1 -0
- package/dist/lib/shapes/ellipse.cjs +2 -2
- package/dist/lib/shapes/index.cjs +1 -1
- package/dist/lib/shapes/index.d.ts +1 -1
- package/dist/lib/shapes/index.d.ts.map +1 -1
- package/dist/lib/shapes/polygon.cjs +29 -24
- package/dist/lib/shapes/polygon.d.ts +1 -1
- package/dist/lib/shapes/polygon.d.ts.map +1 -1
- package/dist/lib/shapes/rectangle.cjs +12 -12
- package/dist/lib/shapes/sector.cjs +41 -33
- package/dist/lib/shapes/sector.d.ts.map +1 -1
- package/dist/lib/shapes/{_shared.cjs → shared.cjs} +12 -15
- package/dist/lib/shapes/{_shared.d.ts → shared.d.ts} +7 -10
- package/dist/lib/shapes/shared.d.ts.map +1 -0
- package/dist/lib/shapes/star.cjs +9 -18
- package/dist/lib/shapes/star.d.ts.map +1 -1
- package/dist/lib/shapes/types.d.ts +10 -3
- package/dist/lib/shapes/types.d.ts.map +1 -1
- package/dist/lib/types.d.ts +1 -1
- package/package.json +3 -4
- package/dist/es/compile/lowerComposites.d.ts.map +0 -1
- package/dist/es/geometry/_edge.d.ts.map +0 -1
- package/dist/es/geometry/_transform.d.ts.map +0 -1
- package/dist/es/geometry/roundedContour.d.ts.map +0 -1
- package/dist/es/parsers/parseNodeTarget.d.ts.map +0 -1
- package/dist/es/parsers/parseTargetSugar.d.ts.map +0 -1
- package/dist/es/parsers/parseWay.d.ts.map +0 -1
- package/dist/es/pathGenerators/define.d.ts.map +0 -1
- package/dist/es/pathGenerators/index.d.ts.map +0 -1
- package/dist/es/pathGenerators/types.d.ts.map +0 -1
- package/dist/es/shapes/_contour.d.ts.map +0 -1
- package/dist/es/shapes/_shared.d.ts.map +0 -1
- package/dist/lib/compile/lowerComposites.d.ts.map +0 -1
- package/dist/lib/geometry/_edge.d.ts.map +0 -1
- package/dist/lib/geometry/_transform.d.ts.map +0 -1
- package/dist/lib/geometry/roundedContour.d.ts.map +0 -1
- package/dist/lib/parsers/parseNodeTarget.d.ts.map +0 -1
- package/dist/lib/parsers/parseTargetSugar.d.ts.map +0 -1
- package/dist/lib/parsers/parseWay.d.ts.map +0 -1
- package/dist/lib/pathGenerators/define.d.ts.map +0 -1
- package/dist/lib/pathGenerators/index.d.ts.map +0 -1
- package/dist/lib/pathGenerators/types.d.ts.map +0 -1
- package/dist/lib/shapes/_contour.d.ts.map +0 -1
- package/dist/lib/shapes/_shared.d.ts.map +0 -1
- /package/dist/es/{pathGenerators → path-generators}/define.d.ts +0 -0
- /package/dist/es/{pathGenerators → path-generators}/index.d.ts +0 -0
- /package/dist/es/{pathGenerators → path-generators}/types.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/define.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/index.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/types.d.ts +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { localToWorld } from "../geometry/
|
|
1
|
+
import { localToWorld } from "../geometry/transform.js";
|
|
2
2
|
import { rect } from "../geometry/rect.js";
|
|
3
3
|
import { defineShape } from "./define.js";
|
|
4
|
-
import {
|
|
5
|
-
import { boundaryFromContour } from "../geometry/
|
|
6
|
-
import { verticesToSegments } from "./
|
|
4
|
+
import { normalizeCompassAnchor } from "../geometry/anchor.js";
|
|
5
|
+
import { boundaryFromContour } from "../geometry/contour.js";
|
|
6
|
+
import { verticesToSegments } from "./contour.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
//#region src/shapes/rectangle.ts
|
|
9
9
|
/** 轴对齐 / 旋转矩形的 4 个角(CW 绕向:左上 → 右上 → 右下 → 左下),局部系经 localToWorld 投世界 */
|
|
@@ -37,14 +37,14 @@ var rectangle = defineShape({
|
|
|
37
37
|
return boundaryFromContour(segments, params.cornerRadius, center, toward) ?? center;
|
|
38
38
|
},
|
|
39
39
|
anchor: (r, name) => {
|
|
40
|
-
const a =
|
|
40
|
+
const a = normalizeCompassAnchor(name);
|
|
41
41
|
return a ? rect.anchor(r, a) : void 0;
|
|
42
42
|
},
|
|
43
43
|
edgePoint: (r, side, t) => rect.edgePoint(r, side, t),
|
|
44
44
|
*emit(r, style, round, params) {
|
|
45
45
|
const halfW = r.width / 2;
|
|
46
46
|
const halfH = r.height / 2;
|
|
47
|
-
const cornerRadius = params.cornerRadius
|
|
47
|
+
const cornerRadius = params.cornerRadius;
|
|
48
48
|
yield {
|
|
49
49
|
type: "rect",
|
|
50
50
|
x: round(r.x - halfW),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sector.d.ts","sourceRoot":"","sources":["../../../src/shapes/sector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sector.d.ts","sourceRoot":"","sources":["../../../src/shapes/sector.ts"],"names":[],"mappings":"AAoGA;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,mCAmFjB,CAAC"}
|
package/dist/es/shapes/sector.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { localToWorld } from "../geometry/
|
|
1
|
+
import { localToWorld } from "../geometry/transform.js";
|
|
2
2
|
import { defineShape } from "./define.js";
|
|
3
|
-
import { sectorGeometry, sectorPolarPoint } from "./
|
|
4
|
-
import { boundaryFromContour, contourCommands } from "../geometry/
|
|
5
|
-
import { contourToPathCommands } from "./
|
|
3
|
+
import { sectorGeometry, sectorPolarPoint } from "./shared.js";
|
|
4
|
+
import { boundaryFromContour, contourCommands, filletContour } from "../geometry/contour.js";
|
|
5
|
+
import { contourToPathCommands, contourToPathPrimitive } from "./contour.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/shapes/sector.ts
|
|
8
8
|
/** sector 局部 AABB 系点(圆心为原点偏移后)→ 世界系(含 rect 旋转 / 平移) */
|
|
@@ -76,6 +76,23 @@ var sectorSegments = (rect, geo, params) => {
|
|
|
76
76
|
}
|
|
77
77
|
];
|
|
78
78
|
};
|
|
79
|
+
var sectorGeometryCache = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
var getSectorGeometry = (params) => {
|
|
81
|
+
const cached = sectorGeometryCache.get(params);
|
|
82
|
+
if (cached !== void 0) return cached;
|
|
83
|
+
const geo = sectorGeometry(params);
|
|
84
|
+
sectorGeometryCache.set(params, geo);
|
|
85
|
+
return geo;
|
|
86
|
+
};
|
|
87
|
+
var createSectorContour = (rect, params) => {
|
|
88
|
+
const geo = getSectorGeometry(params);
|
|
89
|
+
const segments = sectorSegments(rect, geo, params);
|
|
90
|
+
return {
|
|
91
|
+
geo,
|
|
92
|
+
segments,
|
|
93
|
+
fillets: filletContour(segments, params.cornerRadius)
|
|
94
|
+
};
|
|
95
|
+
};
|
|
79
96
|
/**
|
|
80
97
|
* sector 注册项:环楔(内外半径 + 起止角围成的可填充 2D 区域)
|
|
81
98
|
* @description 四何函数共用 `sectorGeometry`(单一真源):circumscribe 返回含圆心 + 内外弧的精确 AABB 半轴
|
|
@@ -88,21 +105,21 @@ var sector = defineShape({
|
|
|
88
105
|
innerRadius: z.number().finite().nonnegative().describe("Inner radius (user units); 0 = solid pie slice."),
|
|
89
106
|
outerRadius: z.number().finite().positive().describe("Outer radius (user units); must be > innerRadius."),
|
|
90
107
|
startAngle: z.number().finite().describe("Start angle in degrees; polar convention 0°=+x, 90°=+y (screen y-down), matching core polar."),
|
|
91
|
-
endAngle: z.number().finite().describe("End angle in degrees; swept
|
|
108
|
+
endAngle: z.number().finite().describe("End angle in degrees; swept clockwise in screen space from startAngle."),
|
|
92
109
|
cornerRadius: z.number().finite().nonnegative().optional().describe("Corner radius in user units; 0 / omitted = sharp corners. Clamped per corner to the largest non-self-intersecting fillet.")
|
|
93
110
|
}).refine((p) => p.outerRadius > p.innerRadius, { message: "outerRadius must be greater than innerRadius" }),
|
|
94
|
-
circumscribe: (_hw, _hh, params) =>
|
|
111
|
+
circumscribe: (_hw, _hh, params) => getSectorGeometry(params).aabbHalfAxes,
|
|
95
112
|
circumscribeOffset: (params) => {
|
|
96
|
-
const { apexOffset } =
|
|
113
|
+
const { apexOffset } = getSectorGeometry(params);
|
|
97
114
|
return [-apexOffset[0], -apexOffset[1]];
|
|
98
115
|
},
|
|
99
116
|
boundaryPoint: (rect, toward, params) => {
|
|
100
|
-
const geo =
|
|
101
|
-
const
|
|
102
|
-
return boundaryFromContour(
|
|
117
|
+
const { geo, segments, fillets } = createSectorContour(rect, params);
|
|
118
|
+
const originWorld = localToWorld(rect, geo.boundaryOriginOffset);
|
|
119
|
+
return boundaryFromContour(segments, params.cornerRadius, originWorld, toward, fillets) ?? originWorld;
|
|
103
120
|
},
|
|
104
121
|
anchor: (rect, name, params) => {
|
|
105
|
-
const geo =
|
|
122
|
+
const geo = getSectorGeometry(params);
|
|
106
123
|
const { innerRadius, outerRadius } = params;
|
|
107
124
|
const { start, end, mid } = geo.range;
|
|
108
125
|
switch (name) {
|
|
@@ -117,17 +134,8 @@ var sector = defineShape({
|
|
|
117
134
|
}
|
|
118
135
|
},
|
|
119
136
|
*emit(rect, style, round, params) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
commands: contourToPathCommands(contourCommands(sectorSegments(rect, sectorGeometry(params), params), params.cornerRadius), round),
|
|
123
|
-
fill: style.fill ?? "transparent",
|
|
124
|
-
fillOpacity: style.fillOpacity,
|
|
125
|
-
stroke: style.stroke ?? "currentColor",
|
|
126
|
-
strokeOpacity: style.strokeOpacity,
|
|
127
|
-
strokeWidth: style.strokeWidth ?? 1,
|
|
128
|
-
dashPattern: style.dashPattern,
|
|
129
|
-
opacity: style.opacity
|
|
130
|
-
};
|
|
137
|
+
const { segments, fillets } = createSectorContour(rect, params);
|
|
138
|
+
yield contourToPathPrimitive(contourToPathCommands(contourCommands(segments, params.cornerRadius, fillets), round), style);
|
|
131
139
|
},
|
|
132
140
|
scaleParams: (params, sx, sy) => {
|
|
133
141
|
const factor = Math.sqrt(sx * sy);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { Position } from '../geometry/point';
|
|
2
|
-
import { RectAnchor } from '../geometry/rect';
|
|
3
|
-
/**
|
|
4
|
-
* 把任意字符串收窄为合法 RectAnchor,否则 undefined
|
|
5
|
-
* @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
|
|
6
|
-
*/
|
|
7
|
-
export declare const asRectAnchor: (name: string) => RectAnchor | undefined;
|
|
8
2
|
/** sector / arc 共用的角度约定起止角 */
|
|
9
3
|
type AngularRange = {
|
|
10
4
|
/** 规范化后的起始角(度)= 原 startAngle */
|
|
@@ -15,11 +9,12 @@ type AngularRange = {
|
|
|
15
9
|
mid: number;
|
|
16
10
|
};
|
|
17
11
|
/**
|
|
18
|
-
* 规范化起止角:保证 end
|
|
12
|
+
* 规范化起止角:保证 start ≤ end ≤ start+360(end<start 时加 360°、跨度>360° 钳到 360°),并给出中分角
|
|
19
13
|
* @description 角度沿屏幕系(角度递增=CW)从 start 扫到 end;end<start 视为跨过 360°,与 polar / geometry/arc 约定一致。
|
|
20
14
|
* end<start 时一次性加上 360°·k(k 为使 end ≥ start 的最小非负整数),O(1) 闭式计算——
|
|
21
15
|
* 避免 while 循环在巨型角度(如 1e308 浮点 end+360===end 卡死、1e9 退化成数百万次迭代)下挂死。
|
|
22
|
-
*
|
|
16
|
+
* 再把跨度钳到 ≤360°:sweep≥360° 视觉即整圆,超出部分冗余;钳定同时防住巨角(如 endAngle=1e8)
|
|
17
|
+
* 让下游 arcBoundingPoints 枚举海量 90°·k 轴向极值点。
|
|
23
18
|
*/
|
|
24
19
|
export declare const normalizeAngularRange: (startAngle: number, endAngle: number) => AngularRange;
|
|
25
20
|
/**
|
|
@@ -38,8 +33,10 @@ export type SectorGeometry = {
|
|
|
38
33
|
};
|
|
39
34
|
/** 圆心(apex)相对 AABB 中心的偏移(apex 常在 AABB 内角,非 AABB 中心) */
|
|
40
35
|
apexOffset: Position;
|
|
41
|
-
/** 质心(centroid)相对 AABB
|
|
36
|
+
/** 质心(centroid)相对 AABB 中心的偏移;大角度环形扇区的质心可能落入内孔。 */
|
|
42
37
|
centroidOffset: Position;
|
|
38
|
+
/** boundaryPoint 射线起点偏移;环形扇区使用填充环楔内的点,而不是质心。 */
|
|
39
|
+
boundaryOriginOffset: Position;
|
|
43
40
|
};
|
|
44
41
|
/** sector params 的最小结构(与 sector.ts 的 SectorParams 同形,避免循环 import 类型) */
|
|
45
42
|
type SectorGeometryInput = {
|
|
@@ -58,4 +55,4 @@ export declare const sectorGeometry: (params: SectorGeometryInput) => SectorGeom
|
|
|
58
55
|
/** sector 局部系点(圆心为原点):极角(度) + 半径 → 直角坐标 */
|
|
59
56
|
export declare const sectorPolarPoint: (radius: number, angleDeg: number) => Position;
|
|
60
57
|
export {};
|
|
61
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/shapes/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,8BAA8B;AAC9B,KAAK,YAAY,GAAG;IAClB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,EAAE,UAAU,MAAM,KAAG,YAI5E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,4CAA4C;IAC5C,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,uDAAuD;IACvD,UAAU,EAAE,QAAQ,CAAC;IACrB,kDAAkD;IAClD,cAAc,EAAE,QAAQ,CAAC;IACzB,gDAAgD;IAChD,oBAAoB,EAAE,QAAQ,CAAC;CAChC,CAAC;AAEF,wEAAwE;AACxE,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,mBAAmB,KAAG,cAoE5D,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,QAC7B,CAAC"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import { RECT_ANCHORS } from "../geometry/rect.js";
|
|
2
1
|
import { arcBoundingPoints, arcEndPoint } from "../geometry/arc.js";
|
|
3
|
-
//#region src/shapes/
|
|
4
|
-
/** RECT_ANCHORS 的 9 个合法 anchor 名集合(成员校验用) */
|
|
5
|
-
var RECT_ANCHOR_SET = new Set(Object.values(RECT_ANCHORS));
|
|
6
|
-
/**
|
|
7
|
-
* 把任意字符串收窄为合法 RectAnchor,否则 undefined
|
|
8
|
-
* @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
|
|
9
|
-
*/
|
|
10
|
-
var asRectAnchor = (name) => RECT_ANCHOR_SET.has(name) ? name : void 0;
|
|
2
|
+
//#region src/shapes/shared.ts
|
|
11
3
|
var DEG_TO_RAD = Math.PI / 180;
|
|
12
4
|
/**
|
|
13
|
-
* 规范化起止角:保证 end
|
|
5
|
+
* 规范化起止角:保证 start ≤ end ≤ start+360(end<start 时加 360°、跨度>360° 钳到 360°),并给出中分角
|
|
14
6
|
* @description 角度沿屏幕系(角度递增=CW)从 start 扫到 end;end<start 视为跨过 360°,与 polar / geometry/arc 约定一致。
|
|
15
7
|
* end<start 时一次性加上 360°·k(k 为使 end ≥ start 的最小非负整数),O(1) 闭式计算——
|
|
16
8
|
* 避免 while 循环在巨型角度(如 1e308 浮点 end+360===end 卡死、1e9 退化成数百万次迭代)下挂死。
|
|
17
|
-
*
|
|
9
|
+
* 再把跨度钳到 ≤360°:sweep≥360° 视觉即整圆,超出部分冗余;钳定同时防住巨角(如 endAngle=1e8)
|
|
10
|
+
* 让下游 arcBoundingPoints 枚举海量 90°·k 轴向极值点。
|
|
18
11
|
*/
|
|
19
12
|
var normalizeAngularRange = (startAngle, endAngle) => {
|
|
20
|
-
const
|
|
13
|
+
const k = Math.max(0, Math.ceil((startAngle - endAngle) / 360));
|
|
14
|
+
const end = Math.min(endAngle + 360 * k, startAngle + 360);
|
|
21
15
|
return {
|
|
22
16
|
start: startAngle,
|
|
23
17
|
end,
|
|
@@ -34,7 +28,7 @@ var sectorGeometry = (params) => {
|
|
|
34
28
|
const { innerRadius, outerRadius } = params;
|
|
35
29
|
const range = normalizeAngularRange(params.startAngle, params.endAngle);
|
|
36
30
|
const apex = [0, 0];
|
|
37
|
-
const candidates = [apex];
|
|
31
|
+
const candidates = innerRadius === 0 ? [apex] : [];
|
|
38
32
|
candidates.push(...arcBoundingPoints(apex, outerRadius, range.start, range.end));
|
|
39
33
|
if (innerRadius > 0) candidates.push(...arcBoundingPoints(apex, innerRadius, range.start, range.end));
|
|
40
34
|
let minX = Infinity;
|
|
@@ -62,6 +56,9 @@ var sectorGeometry = (params) => {
|
|
|
62
56
|
else centroidRadius = 2 / 3 * (Math.sin(half) / half) * ((R * R * R - r * r * r) / areaDenom);
|
|
63
57
|
const centroidLocal = [Math.cos(midRad) * centroidRadius, Math.sin(midRad) * centroidRadius];
|
|
64
58
|
const centroidOffset = [centroidLocal[0] - aabbCenter[0], centroidLocal[1] - aabbCenter[1]];
|
|
59
|
+
const boundaryOriginRadius = innerRadius > 0 ? (innerRadius + outerRadius) / 2 : centroidRadius;
|
|
60
|
+
const boundaryOriginLocal = [Math.cos(midRad) * boundaryOriginRadius, Math.sin(midRad) * boundaryOriginRadius];
|
|
61
|
+
const boundaryOriginOffset = [boundaryOriginLocal[0] - aabbCenter[0], boundaryOriginLocal[1] - aabbCenter[1]];
|
|
65
62
|
return {
|
|
66
63
|
range,
|
|
67
64
|
aabbHalfAxes: {
|
|
@@ -69,10 +66,11 @@ var sectorGeometry = (params) => {
|
|
|
69
66
|
halfHeight
|
|
70
67
|
},
|
|
71
68
|
apexOffset,
|
|
72
|
-
centroidOffset
|
|
69
|
+
centroidOffset,
|
|
70
|
+
boundaryOriginOffset
|
|
73
71
|
};
|
|
74
72
|
};
|
|
75
73
|
/** sector 局部系点(圆心为原点):极角(度) + 半径 → 直角坐标 */
|
|
76
74
|
var sectorPolarPoint = (radius, angleDeg) => arcEndPoint([0, 0], radius, angleDeg);
|
|
77
75
|
//#endregion
|
|
78
|
-
export {
|
|
76
|
+
export { normalizeAngularRange, sectorGeometry, sectorPolarPoint };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"star.d.ts","sourceRoot":"","sources":["../../../src/shapes/star.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"star.d.ts","sourceRoot":"","sources":["../../../src/shapes/star.ts"],"names":[],"mappings":"AAuFA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,mCAkFf,CAAC"}
|
package/dist/es/shapes/star.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { localToWorld } from "../geometry/
|
|
1
|
+
import { localToWorld } from "../geometry/transform.js";
|
|
2
2
|
import { defineShape } from "./define.js";
|
|
3
|
-
import { boundaryFromContour, contourCommands } from "../geometry/
|
|
4
|
-
import { contourToPathCommands, verticesToSegments } from "./
|
|
3
|
+
import { boundaryFromContour, contourCommands } from "../geometry/contour.js";
|
|
4
|
+
import { contourToPathCommands, contourToPathPrimitive, verticesToSegments } from "./contour.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/shapes/star.ts
|
|
7
7
|
var DEG_TO_RAD = Math.PI / 180;
|
|
8
|
+
var MAX_STAR_POINTS = 1024;
|
|
8
9
|
/**
|
|
9
10
|
* 计算 star 单一真源几何
|
|
10
11
|
* @description 局部系以中心为原点:顶点 k 角 = (rotate ?? 0) + k·(180/points) − 90,半径偶 outer / 奇 inner,
|
|
@@ -58,7 +59,7 @@ var worldVertices = (rect, geo) => geo.vertices.map((v) => toWorld(rect, v));
|
|
|
58
59
|
*/
|
|
59
60
|
var star = defineShape({
|
|
60
61
|
paramsSchema: z.strictObject({
|
|
61
|
-
points: z.number().int().min(3).describe(
|
|
62
|
+
points: z.number().int().min(3).max(MAX_STAR_POINTS).describe(`Number of star points (3..${MAX_STAR_POINTS}); capped to bound vertex count (mirrors polygon sides).`),
|
|
62
63
|
innerRadius: z.number().finite().positive().describe("Inner (notch) radius in user units."),
|
|
63
64
|
outerRadius: z.number().finite().positive().describe("Outer (tip) radius in user units; must be > innerRadius."),
|
|
64
65
|
rotate: z.number().finite().optional().describe("Shape self-rotation in degrees; default 0 = first tip points up (screen -y / top); positive rotates clockwise (screen). Composes with Node.rotate."),
|
|
@@ -87,17 +88,7 @@ var star = defineShape({
|
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
90
|
*emit(rect, style, round, params) {
|
|
90
|
-
yield
|
|
91
|
-
type: "path",
|
|
92
|
-
commands: contourToPathCommands(contourCommands(verticesToSegments(worldVertices(rect, starGeometry(params))), params.cornerRadius), round),
|
|
93
|
-
fill: style.fill ?? "transparent",
|
|
94
|
-
fillOpacity: style.fillOpacity,
|
|
95
|
-
stroke: style.stroke ?? "currentColor",
|
|
96
|
-
strokeOpacity: style.strokeOpacity,
|
|
97
|
-
strokeWidth: style.strokeWidth ?? 1,
|
|
98
|
-
dashPattern: style.dashPattern,
|
|
99
|
-
opacity: style.opacity
|
|
100
|
-
};
|
|
91
|
+
yield contourToPathPrimitive(contourToPathCommands(contourCommands(verticesToSegments(worldVertices(rect, starGeometry(params))), params.cornerRadius), round), style);
|
|
101
92
|
},
|
|
102
93
|
scaleParams: (params, sx, sy) => {
|
|
103
94
|
const factor = Math.sqrt(sx * sy);
|
|
@@ -21,7 +21,8 @@ export type ShapeStyle = {
|
|
|
21
21
|
/**
|
|
22
22
|
* 一个 shape 的参数化可注册定义(定义点 typed 形态)
|
|
23
23
|
* @description plain object(factory 友好:`createPolygonShape(6)` 这类普通函数返回它即可);含函数与
|
|
24
|
-
* `paramsSchema`,**不进 IR**,走 `CompileOptions.shapes` 运行时注入。内置
|
|
24
|
+
* `paramsSchema`,**不进 IR**,走 `CompileOptions.shapes` 运行时注入。内置 shape(rectangle / ellipse /
|
|
25
|
+
* sector / arc / polygon / star,circle / diamond 为 preset 别名)也是注册项(无内置特权)。
|
|
25
26
|
* 每个计算函数末位收 per-instance `params`(类型由 `paramsSchema.parse` 在编译期保证),无参形状用
|
|
26
27
|
* `z.strictObject({})` 并忽略 `params`。
|
|
27
28
|
*
|
|
@@ -55,11 +56,17 @@ export type ShapeDefinitionInput<TParams extends IRJsonObject> = {
|
|
|
55
56
|
circumscribeOffset?: (params: TParams) => Position;
|
|
56
57
|
/** 中心 → toward 射线 ∩ 边界(rect 带 rotate);params 喂参数化边界。 */
|
|
57
58
|
boundaryPoint: (rect: Rect, toward: Position, params: TParams) => Position;
|
|
58
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* 命名 anchor 世界坐标;shape 不认识的名字返回 `undefined`(调用方据此抛清晰错误)。
|
|
61
|
+
* @description compass 方位名(north / south / ... / center)的约定(与 TikZ 一致):默认连接面下 compile 先调本函数,
|
|
62
|
+
* shape 返回真实形状上的点即采用(如 ellipse 落真实周长、polygon 落外接 AABB);返回 `undefined` 则 compile
|
|
63
|
+
* 回退到外接 AABB 矩形。故 shape 作者可只实现 shape 专属命名 anchor(tip-N / apex 等),compass 名交回退即可;
|
|
64
|
+
* 要让 compass 贴真实形状边界(圆 / 椭圆类)才需自行处理 compass。
|
|
65
|
+
*/
|
|
59
66
|
anchor: (rect: Rect, name: string, params: TParams) => Position | undefined;
|
|
60
67
|
/**
|
|
61
68
|
* 边上比例点:side 真实边界从约定起点起 t∈[0,1] 处(轴对齐空间求出后由 layout 投回世界系)。
|
|
62
|
-
* @description
|
|
69
|
+
* @description 可选——目前仅 rectangle / ellipse 实现;未实现的 shape(polygon / sector / arc / star)收到 `{ side, t }` 时编译期(resolveEdgePoint)抛明确错。
|
|
63
70
|
* 与 `anchor` 同坐标语义:收**带 rotate 的 Rect**,自行用 worldToLocal/localToWorld 处理旋转。
|
|
64
71
|
*/
|
|
65
72
|
edgePoint?: (rect: Rect, side: 'north' | 'south' | 'east' | 'west', t: number, params: TParams) => Position;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shapes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shapes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,YAAY,IAAI;IAC/D,qEAAqE;IACrE,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC;;;;OAIG;IACH,YAAY,EAAE,CACZ,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,OAAO,KACZ;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,CAAC;IACnD,wDAAwD;IACxD,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,KAAK,QAAQ,CAAC;IAC3E;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC5E;;;;OAIG;IACH,SAAS,CAAC,EAAE,CACV,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,EACzC,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,OAAO,KACZ,QAAQ,CAAC;IACd,0EAA0E;IAC1E,IAAI,EAAE,CACJ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAC5B,MAAM,EAAE,OAAO,KACZ,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC9B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;CACpE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/es/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** 获取对象所有值的联合类型,等价于 (typeof T)[keyof typeof T] */
|
|
2
2
|
export type ValueOf<T extends object> = T[keyof T];
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 类型层等价检查工具(从包根导出,供各包字段表互锁复用)
|
|
5
5
|
* @description 当 A、B 完全等价时类型为 `true`,否则为 `false`——配合 `as const satisfies` 实现"字段表必须完备覆盖类型 key 集合"的互锁;漏字段或多字段 TS 编译期报错
|
|
6
6
|
* @example
|
|
7
7
|
* const NODE_FIELDS = ['id', 'shape'] as const satisfies ReadonlyArray<keyof IRNode>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/arrows/define.ts
|
|
2
|
+
/**
|
|
3
|
+
* 定义一个 arrow 注册项
|
|
4
|
+
* @description 与 `defineShape` / `definePathGenerator` 对齐的定义点 helper;当前不做额外运行时校验,
|
|
5
|
+
* 只保留 `ArrowDefinition` 形态并让第三方扩展面写法一致。
|
|
6
|
+
* @returns 原样返回的 def(便于 `export const bracket = defineArrow({ ... })`)
|
|
7
|
+
*/
|
|
8
|
+
var defineArrow = (def) => def;
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.defineArrow = defineArrow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrowDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 定义一个 arrow 注册项
|
|
4
|
+
* @description 与 `defineShape` / `definePathGenerator` 对齐的定义点 helper;当前不做额外运行时校验,
|
|
5
|
+
* 只保留 `ArrowDefinition` 形态并让第三方扩展面写法一致。
|
|
6
|
+
* @returns 原样返回的 def(便于 `export const bracket = defineArrow({ ... })`)
|
|
7
|
+
*/
|
|
8
|
+
export declare const defineArrow: (def: ArrowDefinition) => ArrowDefinition;
|
|
9
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/arrows/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,eAAe,KAAG,eAAsB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require("./define.cjs");
|
|
1
2
|
//#region src/arrows/index.ts
|
|
2
3
|
/** 实心闭合三角 / 菱形 / V 形的 path 工厂:填充走 ctx.fill(无 override = contextStroke) */
|
|
3
4
|
var filledPath = (ctx, points) => ({
|
|
@@ -34,9 +35,10 @@ var hollowPath = (ctx, points, strokeLinejoin) => ({
|
|
|
34
35
|
...strokeLinejoin ? { strokeLinejoin } : {}
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
|
-
* 内置
|
|
38
|
+
* 内置 8 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
38
39
|
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
39
40
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
41
|
+
* openStealth base=3 + tipX=9 + hollow;
|
|
40
42
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
41
43
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
42
44
|
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
@@ -69,6 +71,17 @@ var BUILTIN_ARROWS = {
|
|
|
69
71
|
[3, 5]
|
|
70
72
|
])]
|
|
71
73
|
},
|
|
74
|
+
openStealth: {
|
|
75
|
+
hollow: true,
|
|
76
|
+
lineContactX: 3,
|
|
77
|
+
tipX: 9,
|
|
78
|
+
emit: (ctx) => [hollowPath(ctx, [
|
|
79
|
+
[1, 1],
|
|
80
|
+
[9, 5],
|
|
81
|
+
[1, 9],
|
|
82
|
+
[3, 5]
|
|
83
|
+
], "miter")]
|
|
84
|
+
},
|
|
72
85
|
diamond: {
|
|
73
86
|
lineContactX: 0,
|
|
74
87
|
emit: (ctx) => [filledPath(ctx, [
|
|
@@ -109,7 +122,7 @@ var BUILTIN_ARROWS = {
|
|
|
109
122
|
cy: 5,
|
|
110
123
|
rx: 4.25,
|
|
111
124
|
ry: 4.25,
|
|
112
|
-
stroke: typeof ctx.stroke === "string" ? ctx.stroke : "
|
|
125
|
+
stroke: typeof ctx.stroke === "string" ? ctx.stroke : { kind: "contextStroke" },
|
|
113
126
|
strokeWidth: ctx.lineWidth
|
|
114
127
|
}]
|
|
115
128
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { BuiltinArrowName } from '../ir/path/arrow';
|
|
2
2
|
import { ArrowDefinition } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* 内置
|
|
4
|
+
* 内置 8 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
5
5
|
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
6
6
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
7
|
+
* openStealth base=3 + tipX=9 + hollow;
|
|
7
8
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
8
9
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
9
10
|
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
10
11
|
*/
|
|
11
12
|
export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
|
|
12
13
|
export type { ArrowDefinition, ArrowEmitContext } from './types';
|
|
14
|
+
export { defineArrow } from './define';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrows/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAiCjE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrows/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAiCjE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CA6DpE,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -18,10 +18,10 @@ export type ArrowEmitContext = {
|
|
|
18
18
|
/**
|
|
19
19
|
* 一个 arrow 的可注册定义:几何尺寸 + emit
|
|
20
20
|
* @description plain object(factory 友好),含函数、**不进 IR**,走 `CompileOptions.arrows` 运行时注入。
|
|
21
|
-
* 内置
|
|
21
|
+
* 内置 8 箭头也是注册项(无内置特权,对齐 `ShapeDefinition` / `BUILTIN_SHAPES`)。
|
|
22
22
|
*
|
|
23
23
|
* `lineContactX` 存**静态 base**(不含 lineWidth 调整):实心 normal/diamond/circle = 0、stealth = 3、
|
|
24
|
-
* open/openDiamond base = 1、openCircle base = 0.75。framework 对 `hollow: true` 的 def 统一减
|
|
24
|
+
* open/openDiamond base = 1、openStealth base = 3、openCircle base = 0.75。framework 对 `hollow: true` 的 def 统一减
|
|
25
25
|
* `lineWidth/2` 得到实际 refX / shrink 接触点(这条调整由编译器 / adapter 落,def 只声明静态 base)。
|
|
26
26
|
*/
|
|
27
27
|
export type ArrowDefinition = {
|
|
@@ -31,6 +31,8 @@ export type ArrowDefinition = {
|
|
|
31
31
|
hollow?: boolean;
|
|
32
32
|
/** 线接触点静态 base(决定 path shrink + marker refX);空心 def 由 framework 再减 lineWidth/2 */
|
|
33
33
|
lineContactX: number;
|
|
34
|
+
/** 外轮廓补偿量(marker 局部坐标);缺省时空心箭头用 lineWidth/2,实心箭头用 0 */
|
|
35
|
+
outerInset?: number;
|
|
34
36
|
/** 尖端 x(shrink 用);缺省 = baseSize */
|
|
35
37
|
tipX?: number;
|
|
36
38
|
/** 默认箭头长度(length fallback);缺省 6 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/arrows/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sEAAsE;IACtE,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;CAC5D,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/arrows/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sEAAsE;IACtE,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_anchor = require("../geometry/anchor.cjs");
|
|
1
2
|
const require_boundary = require("./boundary.cjs");
|
|
2
3
|
const require_node = require("./node.cjs");
|
|
3
4
|
//#region src/compile/anchor-cache.ts
|
|
@@ -8,19 +9,31 @@ const require_node = require("./node.cjs");
|
|
|
8
9
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
9
10
|
/** 角度字符串识别:可选负号 + 数字 + 可选小数;与 parseTarget.ts 的 ANGLE_RE 同语义 */
|
|
10
11
|
var ANGLE_RE = /^-?\d+(\.\d+)?$/;
|
|
12
|
+
/** 把 layout 的 rect 换成外边界 AABB(外扩 outerSep)——border 类 anchor(compass / 数字角度)在其上解析 */
|
|
13
|
+
var withOuterRect = (layout) => ({
|
|
14
|
+
...layout,
|
|
15
|
+
rect: require_node.outerRectOf(layout)
|
|
16
|
+
});
|
|
11
17
|
/**
|
|
12
18
|
* 把 anchorName 解析到对应 shape 的 anchor / boundaryPoint 上
|
|
13
|
-
* @description 数字字符串走 angleBoundaryOf
|
|
19
|
+
* @description 数字字符串走 angleBoundaryOf;其余按标准方位 / shape-specific anchor 走 anchorOf;boundary 透传给两者。
|
|
20
|
+
* border 类 anchor(数字角度 + compass 方位名)按 outerSep 外推:在外扩 margin 的 rect(`outerRectOf`)上解析。
|
|
21
|
+
* 形状专属命名 anchor(tip-N / apex 等)恒走视觉 rect、不外扩。`center` 在 inflate 下
|
|
22
|
+
* 中心不变,走哪条路结果一致。
|
|
14
23
|
*/
|
|
15
24
|
var computeAnchor = (layout, anchorName, boundary) => {
|
|
16
|
-
if (ANGLE_RE.test(anchorName))
|
|
25
|
+
if (ANGLE_RE.test(anchorName)) {
|
|
26
|
+
const angle = Number(anchorName);
|
|
27
|
+
return positionToIR(require_node.angleBoundaryOf(withOuterRect(layout), angle, boundary));
|
|
28
|
+
}
|
|
29
|
+
if (require_anchor.normalizeCompassAnchor(anchorName) !== void 0) return positionToIR(require_node.anchorOf(withOuterRect(layout), anchorName, boundary));
|
|
17
30
|
return positionToIR(require_node.anchorOf(layout, anchorName, boundary));
|
|
18
31
|
};
|
|
19
32
|
/** geometry Position(含 readonly 形态)转 IRPosition 元组(IRPosition === [number, number]) */
|
|
20
33
|
var positionToIR = (p) => [p[0], p[1]];
|
|
21
34
|
/**
|
|
22
35
|
* 取节点 anchor 的全局坐标,带 per-layout 缓存
|
|
23
|
-
* @description name
|
|
36
|
+
* @description name 接受方位 anchor 关键字(如 `'north'` / `'south-west'` / `'top-left'`)或数字角度字符串(如 `'30'` / `'-45'`);
|
|
24
37
|
* boundary 指定连接面(默认 `'shape'`,即节点自身视觉轮廓);不同 boundary 产生独立缓存条目,互不串扰;
|
|
25
38
|
* 同一 (layout, name, boundary) 组合第二次起返回首调用结果的**同一引用**——上游可用 `===` 判定 cache 命中
|
|
26
39
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
@@ -44,7 +57,7 @@ var resolveAnchor = (layout, anchorName, boundary = "shape") => {
|
|
|
44
57
|
/**
|
|
45
58
|
* 取节点边上比例点 `{ side, t }` 的全局坐标,带 per-layout 缓存
|
|
46
59
|
* @description 走 `layout.shapeDef.edgePoint`——shape 未实现(如自定义 shape)抛"does not support side anchors";
|
|
47
|
-
* 零尺寸 layout(Coordinate
|
|
60
|
+
* 零尺寸 layout(Coordinate)抛错(边上比例点对一个点无意义,报错比退化中心更可诊断)。
|
|
48
61
|
* 缓存 key = `${side}:${t}`,与命名 anchor(`'north'` / `'30'`)共用 layout 的 Map——key 含 `:` 故命名空间不冲突。
|
|
49
62
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
50
63
|
* @returns 全局坐标系下的 IRPosition `[x, y]`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Side } from '../geometry/
|
|
1
|
+
import { Side } from '../geometry/edge';
|
|
2
2
|
import { IRBoundary, IRPosition } from '../ir';
|
|
3
3
|
import { NodeLayout } from './node';
|
|
4
4
|
/**
|
|
5
5
|
* 取节点 anchor 的全局坐标,带 per-layout 缓存
|
|
6
|
-
* @description name
|
|
6
|
+
* @description name 接受方位 anchor 关键字(如 `'north'` / `'south-west'` / `'top-left'`)或数字角度字符串(如 `'30'` / `'-45'`);
|
|
7
7
|
* boundary 指定连接面(默认 `'shape'`,即节点自身视觉轮廓);不同 boundary 产生独立缓存条目,互不串扰;
|
|
8
8
|
* 同一 (layout, name, boundary) 组合第二次起返回首调用结果的**同一引用**——上游可用 `===` 判定 cache 命中
|
|
9
9
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
@@ -15,7 +15,7 @@ export declare const resolveAnchor: (layout: NodeLayout, anchorName: string, bou
|
|
|
15
15
|
/**
|
|
16
16
|
* 取节点边上比例点 `{ side, t }` 的全局坐标,带 per-layout 缓存
|
|
17
17
|
* @description 走 `layout.shapeDef.edgePoint`——shape 未实现(如自定义 shape)抛"does not support side anchors";
|
|
18
|
-
* 零尺寸 layout(Coordinate
|
|
18
|
+
* 零尺寸 layout(Coordinate)抛错(边上比例点对一个点无意义,报错比退化中心更可诊断)。
|
|
19
19
|
* 缓存 key = `${side}:${t}`,与命名 anchor(`'north'` / `'30'`)共用 layout 的 Map——key 含 `:` 故命名空间不冲突。
|
|
20
20
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
21
21
|
* @returns 全局坐标系下的 IRPosition `[x, y]`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-cache.d.ts","sourceRoot":"","sources":["../../../src/compile/anchor-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"anchor-cache.d.ts","sourceRoot":"","sources":["../../../src/compile/anchor-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AA8CzC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,UAAU,EAClB,YAAY,MAAM,EAClB,WAAU,UAAU,GAAG,SAAmB,KACzC,UAYF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,UAAU,EAClB,MAAM,IAAI,EACV,GAAG,MAAM,KACR,UAuBF,CAAC"}
|