@retikz/core 0.1.0-alpha.5 → 0.1.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/compile/compile.d.ts +20 -3
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +44 -19
- package/dist/es/compile/index.d.ts +2 -2
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/layout.d.ts +5 -0
- package/dist/es/compile/layout.d.ts.map +1 -0
- package/dist/es/compile/{view-box.js → layout.js} +4 -4
- package/dist/es/compile/node.d.ts +4 -4
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +7 -7
- package/dist/es/compile/path/anchor.d.ts +19 -0
- package/dist/es/compile/path/anchor.d.ts.map +1 -0
- package/dist/es/compile/path/anchor.js +54 -0
- package/dist/es/compile/path/arrow-geometry.d.ts +22 -0
- package/dist/es/compile/path/arrow-geometry.d.ts.map +1 -0
- package/dist/es/compile/path/arrow-geometry.js +40 -0
- package/dist/es/compile/{path.d.ts → path/index.d.ts} +18 -7
- package/dist/es/compile/path/index.d.ts.map +1 -0
- package/dist/es/compile/path/index.js +308 -0
- package/dist/es/compile/path/label.d.ts +18 -0
- package/dist/es/compile/path/label.d.ts.map +1 -0
- package/dist/es/compile/path/label.js +102 -0
- package/dist/es/compile/path/relative.d.ts +8 -0
- package/dist/es/compile/path/relative.d.ts.map +1 -0
- package/dist/es/compile/path/relative.js +48 -0
- package/dist/es/compile/path/shrink.d.ts +18 -0
- package/dist/es/compile/path/shrink.d.ts.map +1 -0
- package/dist/es/compile/path/shrink.js +126 -0
- package/dist/es/compile/path/split.d.ts +15 -0
- package/dist/es/compile/path/split.d.ts.map +1 -0
- package/dist/es/compile/path/split.js +46 -0
- package/dist/es/compile/text-metrics.d.ts +4 -1
- package/dist/es/compile/text-metrics.d.ts.map +1 -1
- package/dist/es/compile/text-metrics.js +11 -5
- package/dist/es/geometry/_transform.d.ts +21 -0
- package/dist/es/geometry/_transform.d.ts.map +1 -0
- package/dist/es/geometry/_transform.js +27 -0
- package/dist/es/geometry/bend.d.ts +1 -1
- package/dist/es/geometry/bend.js +1 -1
- package/dist/es/geometry/circle.d.ts +2 -3
- package/dist/es/geometry/circle.d.ts.map +1 -1
- package/dist/es/geometry/circle.js +1 -16
- package/dist/es/geometry/diamond.d.ts +2 -3
- package/dist/es/geometry/diamond.d.ts.map +1 -1
- package/dist/es/geometry/diamond.js +1 -16
- package/dist/es/geometry/ellipse.d.ts +2 -3
- package/dist/es/geometry/ellipse.d.ts.map +1 -1
- package/dist/es/geometry/ellipse.js +1 -16
- package/dist/es/geometry/polar.d.ts +2 -2
- package/dist/es/geometry/polar.d.ts.map +1 -1
- package/dist/es/geometry/polar.js +2 -6
- package/dist/es/geometry/rect.d.ts.map +1 -1
- package/dist/es/geometry/rect.js +1 -18
- package/dist/es/geometry/segment.d.ts +5 -1
- package/dist/es/geometry/segment.d.ts.map +1 -1
- package/dist/es/index.d.ts +11 -7
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +5 -2
- package/dist/es/ir/coordinate.d.ts +1 -1
- package/dist/es/ir/coordinate.js +1 -1
- package/dist/es/ir/font.d.ts +21 -0
- package/dist/es/ir/font.d.ts.map +1 -0
- package/dist/es/ir/font.js +15 -0
- package/dist/es/ir/index.d.ts +2 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/node.d.ts +32 -143
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +7 -31
- package/dist/es/ir/path/arrow.d.ts +14 -14
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +5 -5
- package/dist/es/ir/path/path.d.ts +19 -19
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +4 -4
- package/dist/es/ir/path/step.d.ts +1 -1
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +8 -8
- package/dist/es/ir/position/at-position.js +1 -1
- package/dist/es/ir/position/offset-position.js +1 -1
- package/dist/es/ir/position/polar-position.d.ts.map +1 -1
- package/dist/es/ir/position/polar-position.js +2 -2
- package/dist/es/ir/position/position.d.ts.map +1 -1
- package/dist/es/ir/position/position.js +1 -1
- package/dist/es/ir/scene.d.ts +128 -128
- package/dist/es/ir/text.d.ts +96 -0
- package/dist/es/ir/text.d.ts.map +1 -0
- package/dist/es/ir/text.js +20 -0
- package/dist/es/parsers/parseTargetSugar.d.ts +4 -0
- package/dist/es/parsers/parseTargetSugar.d.ts.map +1 -1
- package/dist/es/parsers/parseTargetSugar.js +3 -2
- package/dist/es/primitive/ellipse.d.ts +3 -3
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/group.d.ts +23 -7
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/index.d.ts +1 -1
- package/dist/es/primitive/index.d.ts.map +1 -1
- package/dist/es/primitive/layout.d.ts +12 -0
- package/dist/es/primitive/layout.d.ts.map +1 -0
- package/dist/es/primitive/path.d.ts +55 -15
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +3 -3
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +4 -4
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +10 -3
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/es/types.d.ts +8 -0
- package/dist/es/types.d.ts.map +1 -1
- package/dist/lib/compile/compile.cjs +44 -19
- package/dist/lib/compile/compile.d.ts +20 -3
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/index.d.ts +2 -2
- package/dist/lib/compile/index.d.ts.map +1 -1
- package/dist/lib/compile/{view-box.cjs → layout.cjs} +4 -4
- package/dist/lib/compile/layout.d.ts +5 -0
- package/dist/lib/compile/layout.d.ts.map +1 -0
- package/dist/lib/compile/node.cjs +7 -7
- package/dist/lib/compile/node.d.ts +4 -4
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/path/anchor.cjs +58 -0
- package/dist/lib/compile/path/anchor.d.ts +19 -0
- package/dist/lib/compile/path/anchor.d.ts.map +1 -0
- package/dist/lib/compile/path/arrow-geometry.cjs +41 -0
- package/dist/lib/compile/path/arrow-geometry.d.ts +22 -0
- package/dist/lib/compile/path/arrow-geometry.d.ts.map +1 -0
- package/dist/lib/compile/path/index.cjs +308 -0
- package/dist/lib/compile/{path.d.ts → path/index.d.ts} +18 -7
- package/dist/lib/compile/path/index.d.ts.map +1 -0
- package/dist/lib/compile/path/label.cjs +103 -0
- package/dist/lib/compile/path/label.d.ts +18 -0
- package/dist/lib/compile/path/label.d.ts.map +1 -0
- package/dist/lib/compile/path/relative.cjs +48 -0
- package/dist/lib/compile/path/relative.d.ts +8 -0
- package/dist/lib/compile/path/relative.d.ts.map +1 -0
- package/dist/lib/compile/path/shrink.cjs +128 -0
- package/dist/lib/compile/path/shrink.d.ts +18 -0
- package/dist/lib/compile/path/shrink.d.ts.map +1 -0
- package/dist/lib/compile/path/split.cjs +46 -0
- package/dist/lib/compile/path/split.d.ts +15 -0
- package/dist/lib/compile/path/split.d.ts.map +1 -0
- package/dist/lib/compile/text-metrics.cjs +11 -5
- package/dist/lib/compile/text-metrics.d.ts +4 -1
- package/dist/lib/compile/text-metrics.d.ts.map +1 -1
- package/dist/lib/geometry/_transform.cjs +28 -0
- package/dist/lib/geometry/_transform.d.ts +21 -0
- package/dist/lib/geometry/_transform.d.ts.map +1 -0
- package/dist/lib/geometry/bend.cjs +1 -1
- package/dist/lib/geometry/bend.d.ts +1 -1
- package/dist/lib/geometry/circle.cjs +5 -20
- package/dist/lib/geometry/circle.d.ts +2 -3
- package/dist/lib/geometry/circle.d.ts.map +1 -1
- package/dist/lib/geometry/diamond.cjs +5 -20
- package/dist/lib/geometry/diamond.d.ts +2 -3
- package/dist/lib/geometry/diamond.d.ts.map +1 -1
- package/dist/lib/geometry/ellipse.cjs +5 -20
- package/dist/lib/geometry/ellipse.d.ts +2 -3
- package/dist/lib/geometry/ellipse.d.ts.map +1 -1
- package/dist/lib/geometry/polar.cjs +2 -6
- package/dist/lib/geometry/polar.d.ts +2 -2
- package/dist/lib/geometry/polar.d.ts.map +1 -1
- package/dist/lib/geometry/rect.cjs +5 -22
- package/dist/lib/geometry/rect.d.ts.map +1 -1
- package/dist/lib/geometry/segment.d.ts +5 -1
- package/dist/lib/geometry/segment.d.ts.map +1 -1
- package/dist/lib/index.cjs +7 -3
- package/dist/lib/index.d.ts +11 -7
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/coordinate.cjs +1 -1
- package/dist/lib/ir/coordinate.d.ts +1 -1
- package/dist/lib/ir/font.cjs +15 -0
- package/dist/lib/ir/font.d.ts +21 -0
- package/dist/lib/ir/font.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +2 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +8 -35
- package/dist/lib/ir/node.d.ts +32 -143
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +5 -5
- package/dist/lib/ir/path/arrow.d.ts +14 -14
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +4 -4
- package/dist/lib/ir/path/path.d.ts +19 -19
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +8 -8
- package/dist/lib/ir/path/step.d.ts +1 -1
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/position/at-position.cjs +1 -1
- package/dist/lib/ir/position/offset-position.cjs +1 -1
- package/dist/lib/ir/position/polar-position.cjs +2 -2
- package/dist/lib/ir/position/polar-position.d.ts.map +1 -1
- package/dist/lib/ir/position/position.cjs +1 -1
- package/dist/lib/ir/position/position.d.ts.map +1 -1
- package/dist/lib/ir/scene.d.ts +128 -128
- package/dist/lib/ir/text.cjs +21 -0
- package/dist/lib/ir/text.d.ts +96 -0
- package/dist/lib/ir/text.d.ts.map +1 -0
- package/dist/lib/parsers/parseTargetSugar.cjs +3 -2
- package/dist/lib/parsers/parseTargetSugar.d.ts +4 -0
- package/dist/lib/parsers/parseTargetSugar.d.ts.map +1 -1
- package/dist/lib/primitive/ellipse.d.ts +3 -3
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/group.d.ts +23 -7
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/index.d.ts +1 -1
- package/dist/lib/primitive/index.d.ts.map +1 -1
- package/dist/lib/primitive/layout.d.ts +12 -0
- package/dist/lib/primitive/layout.d.ts.map +1 -0
- package/dist/lib/primitive/path.d.ts +55 -15
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +3 -3
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +4 -4
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +10 -3
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +12 -4
- package/dist/es/compile/path.d.ts.map +0 -1
- package/dist/es/compile/path.js +0 -636
- package/dist/es/compile/view-box.d.ts +0 -5
- package/dist/es/compile/view-box.d.ts.map +0 -1
- package/dist/es/primitive/view-box.d.ts +0 -12
- package/dist/es/primitive/view-box.d.ts.map +0 -1
- package/dist/lib/compile/path.cjs +0 -636
- package/dist/lib/compile/path.d.ts.map +0 -1
- package/dist/lib/compile/view-box.d.ts +0 -5
- package/dist/lib/compile/view-box.d.ts.map +0 -1
- package/dist/lib/primitive/view-box.d.ts +0 -12
- package/dist/lib/primitive/view-box.d.ts.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/compile/path/split.ts
|
|
2
|
+
/**
|
|
3
|
+
* 多 sub-path + 有端点箭头:按 sub-path split 成多个 PathPrim
|
|
4
|
+
* @description 端点箭头只属于整条 path 的首端和末端;单 sub-path 或无箭头时直接产一个 PathPrim。
|
|
5
|
+
*/
|
|
6
|
+
var splitSubPathsForEndpointArrows = (commands, baseProps, endpointArrows) => {
|
|
7
|
+
const hasArrows = !!endpointArrows.arrowStart || !!endpointArrows.arrowEnd;
|
|
8
|
+
const subPathStarts = [];
|
|
9
|
+
commands.forEach((cmd, idx) => {
|
|
10
|
+
if (cmd.kind === "move") subPathStarts.push(idx);
|
|
11
|
+
});
|
|
12
|
+
if (!hasArrows || subPathStarts.length <= 1) return {
|
|
13
|
+
primitive: {
|
|
14
|
+
type: "path",
|
|
15
|
+
commands,
|
|
16
|
+
...baseProps,
|
|
17
|
+
...endpointArrows
|
|
18
|
+
},
|
|
19
|
+
isGrouped: false
|
|
20
|
+
};
|
|
21
|
+
const subPathSlices = [];
|
|
22
|
+
for (let s = 0; s < subPathStarts.length; s++) {
|
|
23
|
+
const start = subPathStarts[s];
|
|
24
|
+
const end = s + 1 < subPathStarts.length ? subPathStarts[s + 1] : commands.length;
|
|
25
|
+
subPathSlices.push(commands.slice(start, end));
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
primitive: {
|
|
29
|
+
type: "group",
|
|
30
|
+
children: subPathSlices.map((sub, i) => {
|
|
31
|
+
const isFirst = i === 0;
|
|
32
|
+
const isLast = i === subPathSlices.length - 1;
|
|
33
|
+
return {
|
|
34
|
+
type: "path",
|
|
35
|
+
commands: sub,
|
|
36
|
+
...baseProps,
|
|
37
|
+
...isFirst && endpointArrows.arrowStart ? { arrowStart: endpointArrows.arrowStart } : {},
|
|
38
|
+
...isLast && endpointArrows.arrowEnd ? { arrowEnd: endpointArrows.arrowEnd } : {}
|
|
39
|
+
};
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
isGrouped: true
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { splitSubPathsForEndpointArrows };
|
|
@@ -25,6 +25,9 @@ export type TextMetrics = {
|
|
|
25
25
|
* @description @retikz/react: canvas measureText;@retikz/ssr: opentype.js/fontkit;@retikz/canvas: ctx.measureText
|
|
26
26
|
*/
|
|
27
27
|
export type TextMeasurer = (text: string, font: FontSpec) => TextMetrics;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* 默认 fallback 度量:基于平均字宽估算,不准但保证可运行
|
|
30
|
+
* @description size=0 → 退化返回 (0, 0)(与 text='' 一致);负 size 或 NaN size → throw(非法输入早 fail,避免 NaN 噪音传播到 Scene)
|
|
31
|
+
*/
|
|
29
32
|
export declare const fallbackMeasurer: TextMeasurer;
|
|
30
33
|
//# sourceMappingURL=text-metrics.d.ts.map
|
|
@@ -1 +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,mCAAmC;IACnC,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;CACzC,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;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,WAAW,CAAC;AAEzE
|
|
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,mCAAmC;IACnC,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;CACzC,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;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,WAAW,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAU9B,CAAC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
//#region src/compile/text-metrics.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 默认 fallback 度量:基于平均字宽估算,不准但保证可运行
|
|
4
|
+
* @description size=0 → 退化返回 (0, 0)(与 text='' 一致);负 size 或 NaN size → throw(非法输入早 fail,避免 NaN 噪音传播到 Scene)
|
|
5
|
+
*/
|
|
6
|
+
var fallbackMeasurer = (text, font) => {
|
|
7
|
+
if (Number.isNaN(font.size) || font.size < 0) throw new Error(`fallbackMeasurer: invalid font.size '${font.size}'; must be a non-negative finite number`);
|
|
8
|
+
return {
|
|
9
|
+
width: text.length * font.size * .55,
|
|
10
|
+
height: font.size * 1.2
|
|
11
|
+
};
|
|
12
|
+
};
|
|
7
13
|
//#endregion
|
|
8
14
|
export { fallbackMeasurer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Position } from './point';
|
|
2
|
+
/** 任何"中心 + 可选旋转"形状的几何契约(rect / circle / ellipse / diamond 共用) */
|
|
3
|
+
export type CenteredShape = {
|
|
4
|
+
/** 中心横坐标 */
|
|
5
|
+
x: number;
|
|
6
|
+
/** 中心纵坐标 */
|
|
7
|
+
y: number;
|
|
8
|
+
/** 绕中心旋转弧度(可选,0 / 缺省 = 不旋转) */
|
|
9
|
+
rotate?: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 本地坐标(以中心为原点)→ 世界坐标
|
|
13
|
+
* @description rotate=0 / 缺省时退化为平移;非零时按右手系绕中心旋转后再平移
|
|
14
|
+
*/
|
|
15
|
+
export declare const localToWorld: (s: CenteredShape, local: Position) => Position;
|
|
16
|
+
/**
|
|
17
|
+
* 世界坐标 → 本地坐标(`localToWorld` 逆变换)
|
|
18
|
+
* @description 先反平移到中心、再反旋转回本地基;旋转矩阵转置即逆
|
|
19
|
+
*/
|
|
20
|
+
export declare const worldToLocal: (s: CenteredShape, world: Position) => Position;
|
|
21
|
+
//# sourceMappingURL=_transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_transform.d.ts","sourceRoot":"","sources":["../../../src/geometry/_transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,aAAa,EAAE,OAAO,QAAQ,KAAG,QAShE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,aAAa,EAAE,OAAO,QAAQ,KAAG,QAQhE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/geometry/_transform.ts
|
|
2
|
+
/**
|
|
3
|
+
* 本地坐标(以中心为原点)→ 世界坐标
|
|
4
|
+
* @description rotate=0 / 缺省时退化为平移;非零时按右手系绕中心旋转后再平移
|
|
5
|
+
*/
|
|
6
|
+
var localToWorld = (s, local) => {
|
|
7
|
+
const angle = s.rotate ?? 0;
|
|
8
|
+
if (angle === 0) return [s.x + local[0], s.y + local[1]];
|
|
9
|
+
const cos = Math.cos(angle);
|
|
10
|
+
const sin = Math.sin(angle);
|
|
11
|
+
return [s.x + local[0] * cos - local[1] * sin, s.y + local[0] * sin + local[1] * cos];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 世界坐标 → 本地坐标(`localToWorld` 逆变换)
|
|
15
|
+
* @description 先反平移到中心、再反旋转回本地基;旋转矩阵转置即逆
|
|
16
|
+
*/
|
|
17
|
+
var worldToLocal = (s, world) => {
|
|
18
|
+
const tx = world[0] - s.x;
|
|
19
|
+
const ty = world[1] - s.y;
|
|
20
|
+
const angle = s.rotate ?? 0;
|
|
21
|
+
if (angle === 0) return [tx, ty];
|
|
22
|
+
const cos = Math.cos(angle);
|
|
23
|
+
const sin = Math.sin(angle);
|
|
24
|
+
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { localToWorld, worldToLocal };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
2
|
/**
|
|
3
3
|
* cubic Bezier 拟合 from→to 的弧形 bend
|
|
4
|
-
* @description apex offset = chord × tan(bendAngle/2);控制点取 chord 1/3 与 2/3 处沿法向偏移,让 cubic 在 t=0.5 穿过 apex 故 ctlOffset = 4/3 × apexOffset
|
|
4
|
+
* @description apex offset = chord × tan(bendAngle/2);控制点取 chord 1/3 与 2/3 处沿法向偏移,让 cubic 在 t=0.5 穿过 apex 故 ctlOffset = 4/3 × apexOffset。法向(screen y-down):visual-left=(dy,-dx)/|chord|,visual-right=(-dy,dx)/|chord|。chord=0 时两控制点都返回 from
|
|
5
5
|
*/
|
|
6
6
|
export declare const bendControlPoints: (from: Position, to: Position, direction: "left" | "right", bendAngle: number) => [Position, Position];
|
|
7
7
|
//# sourceMappingURL=bend.d.ts.map
|
package/dist/es/geometry/bend.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/geometry/bend.ts
|
|
2
2
|
/**
|
|
3
3
|
* cubic Bezier 拟合 from→to 的弧形 bend
|
|
4
|
-
* @description apex offset = chord × tan(bendAngle/2);控制点取 chord 1/3 与 2/3 处沿法向偏移,让 cubic 在 t=0.5 穿过 apex 故 ctlOffset = 4/3 × apexOffset
|
|
4
|
+
* @description apex offset = chord × tan(bendAngle/2);控制点取 chord 1/3 与 2/3 处沿法向偏移,让 cubic 在 t=0.5 穿过 apex 故 ctlOffset = 4/3 × apexOffset。法向(screen y-down):visual-left=(dy,-dx)/|chord|,visual-right=(-dy,dx)/|chord|。chord=0 时两控制点都返回 from
|
|
5
5
|
*/
|
|
6
6
|
var bendControlPoints = (from, to, direction, bendAngle) => {
|
|
7
7
|
const dx = to[0] - from[0];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
|
+
import { RectAnchor } from './rect';
|
|
2
3
|
/** 圆形:几何中心 + 半径,预留旋转字段保持与 Rect 同形 API */
|
|
3
4
|
export type Circle = {
|
|
4
5
|
x: number;
|
|
@@ -8,8 +9,6 @@ export type Circle = {
|
|
|
8
9
|
/** 绕中心旋转弧度(圆视觉不变,与 Rect 同形保留) */
|
|
9
10
|
rotate?: number;
|
|
10
11
|
};
|
|
11
|
-
/** 圆形 9 个标准 anchor(与 RECT_ANCHORS 同名同义,圆周每 45° 等距分布) */
|
|
12
|
-
export type CircleAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
|
|
13
12
|
/** 圆形相关基础工具 */
|
|
14
13
|
export declare const circle: {
|
|
15
14
|
/** 圆心 */
|
|
@@ -17,7 +16,7 @@ export declare const circle: {
|
|
|
17
16
|
/** 判断点是否在圆内(含边界) */
|
|
18
17
|
contains: (c: Circle, p: Position) => boolean;
|
|
19
18
|
/** 9 个标准 anchor 之一的世界坐标 */
|
|
20
|
-
anchor: (c: Circle, name:
|
|
19
|
+
anchor: (c: Circle, name: RectAnchor) => Position;
|
|
21
20
|
/** 从圆心向 toward 方向射线与圆周交点(Path 端点贴 Node 边界用) */
|
|
22
21
|
boundaryPoint: (c: Circle, toward: Position) => Position;
|
|
23
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/geometry/circle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/geometry/circle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,yCAAyC;AACzC,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS;IACT,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,eAAe;AACf,eAAO,MAAM,MAAM;IACjB,SAAS;gBACG,MAAM,KAAG,QAAQ;IAC7B,oBAAoB;kBACN,MAAM,KAAK,QAAQ,KAAG,OAAO;IAI3C,2BAA2B;gBACf,MAAM,QAAQ,UAAU,KAAG,QAAQ;IAsC/C,+CAA+C;uBAC5B,MAAM,UAAU,QAAQ,KAAG,QAAQ;CAOvD,CAAC"}
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
+
import { localToWorld, worldToLocal } from "./_transform.js";
|
|
1
2
|
//#region src/geometry/circle.ts
|
|
2
3
|
var SQRT_HALF = Math.SQRT1_2;
|
|
3
|
-
var localToWorld = (c, local) => {
|
|
4
|
-
const angle = c.rotate ?? 0;
|
|
5
|
-
if (angle === 0) return [c.x + local[0], c.y + local[1]];
|
|
6
|
-
const cos = Math.cos(angle);
|
|
7
|
-
const sin = Math.sin(angle);
|
|
8
|
-
return [c.x + local[0] * cos - local[1] * sin, c.y + local[0] * sin + local[1] * cos];
|
|
9
|
-
};
|
|
10
|
-
var worldToLocal = (c, world) => {
|
|
11
|
-
const tx = world[0] - c.x;
|
|
12
|
-
const ty = world[1] - c.y;
|
|
13
|
-
const angle = c.rotate ?? 0;
|
|
14
|
-
if (angle === 0) return [tx, ty];
|
|
15
|
-
const cos = Math.cos(angle);
|
|
16
|
-
const sin = Math.sin(angle);
|
|
17
|
-
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
18
|
-
};
|
|
19
4
|
/** 圆形相关基础工具 */
|
|
20
5
|
var circle = {
|
|
21
6
|
/** 圆心 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
|
+
import { RectAnchor } from './rect';
|
|
2
3
|
/** 菱形:中心 + halfA/halfB 半轴长 + 可选旋转;顶点在 (±halfA,0) 与 (0,±halfB) */
|
|
3
4
|
export type Diamond = {
|
|
4
5
|
x: number;
|
|
@@ -10,8 +11,6 @@ export type Diamond = {
|
|
|
10
11
|
/** 绕中心旋转弧度 */
|
|
11
12
|
rotate?: number;
|
|
12
13
|
};
|
|
13
|
-
/** 菱形 9 个标准 anchor(4 顶点 + 4 边中点 + 中心) */
|
|
14
|
-
export type DiamondAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
|
|
15
14
|
/** 菱形相关基础工具 */
|
|
16
15
|
export declare const diamond: {
|
|
17
16
|
/** 中心 */
|
|
@@ -19,7 +18,7 @@ export declare const diamond: {
|
|
|
19
18
|
/** 点是否在菱形内(含边界,含旋转);方程 |x|/halfA + |y|/halfB ≤ 1 */
|
|
20
19
|
contains: (d: Diamond, p: Position) => boolean;
|
|
21
20
|
/** 9 个 anchor:N/S/E/W=顶点,NE/NW/SE/SW=边中点,center=中心 */
|
|
22
|
-
anchor: (d: Diamond, name:
|
|
21
|
+
anchor: (d: Diamond, name: RectAnchor) => Position;
|
|
23
22
|
/**
|
|
24
23
|
* 从中心向 toward 方向射线与菱形 4 边的交点
|
|
25
24
|
* @description 菱形方程 |x|/halfA + |y|/halfB = 1;沿方向 (lx,ly) 缩放 t 倍命中:t = 1 / (|lx|/halfA + |ly|/halfB)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diamond.d.ts","sourceRoot":"","sources":["../../../src/geometry/diamond.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diamond.d.ts","sourceRoot":"","sources":["../../../src/geometry/diamond.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,iEAAiE;AACjE,MAAM,MAAM,OAAO,GAAG;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAe;AACf,eAAO,MAAM,OAAO;IAClB,SAAS;gBACG,OAAO,KAAG,QAAQ;IAC9B,oDAAoD;kBACtC,OAAO,KAAK,QAAQ,KAAG,OAAO;IAI5C,sDAAsD;gBAC1C,OAAO,QAAQ,UAAU,KAAG,QAAQ;IAqClD;;;OAGG;uBACkB,OAAO,UAAU,QAAQ,KAAG,QAAQ;CAOxD,CAAC"}
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
+
import { localToWorld, worldToLocal } from "./_transform.js";
|
|
1
2
|
//#region src/geometry/diamond.ts
|
|
2
|
-
var localToWorld = (d, local) => {
|
|
3
|
-
const angle = d.rotate ?? 0;
|
|
4
|
-
if (angle === 0) return [d.x + local[0], d.y + local[1]];
|
|
5
|
-
const cos = Math.cos(angle);
|
|
6
|
-
const sin = Math.sin(angle);
|
|
7
|
-
return [d.x + local[0] * cos - local[1] * sin, d.y + local[0] * sin + local[1] * cos];
|
|
8
|
-
};
|
|
9
|
-
var worldToLocal = (d, world) => {
|
|
10
|
-
const tx = world[0] - d.x;
|
|
11
|
-
const ty = world[1] - d.y;
|
|
12
|
-
const angle = d.rotate ?? 0;
|
|
13
|
-
if (angle === 0) return [tx, ty];
|
|
14
|
-
const cos = Math.cos(angle);
|
|
15
|
-
const sin = Math.sin(angle);
|
|
16
|
-
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
17
|
-
};
|
|
18
3
|
/** 菱形相关基础工具 */
|
|
19
4
|
var diamond = {
|
|
20
5
|
/** 中心 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
|
+
import { RectAnchor } from './rect';
|
|
2
3
|
/** 椭圆:中心 + 半长轴 rx / 半短轴 ry + 可选旋转 */
|
|
3
4
|
export type Ellipse = {
|
|
4
5
|
x: number;
|
|
@@ -10,8 +11,6 @@ export type Ellipse = {
|
|
|
10
11
|
/** 绕中心旋转弧度 */
|
|
11
12
|
rotate?: number;
|
|
12
13
|
};
|
|
13
|
-
/** 椭圆 9 个标准 anchor(与 RECT_ANCHORS 同名同义) */
|
|
14
|
-
export type EllipseAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
|
|
15
14
|
/** 椭圆相关基础工具 */
|
|
16
15
|
export declare const ellipse: {
|
|
17
16
|
/** 中心 */
|
|
@@ -22,7 +21,7 @@ export declare const ellipse: {
|
|
|
22
21
|
* 9 个 anchor 的世界坐标
|
|
23
22
|
* @description 对角(NE/NW/SE/SW)取参数曲线 t=π/4 处 (rx/√2, ry/√2),与 TikZ 椭圆 anchor 参数等分约定一致
|
|
24
23
|
*/
|
|
25
|
-
anchor: (e: Ellipse, name:
|
|
24
|
+
anchor: (e: Ellipse, name: RectAnchor) => Position;
|
|
26
25
|
/**
|
|
27
26
|
* 从中心向 toward 方向射线与椭圆交点
|
|
28
27
|
* @description 椭圆方程 (x/rx)² + (y/ry)² = 1;沿 (lx,ly) 缩放 t 倍命中 t = 1 / √((lx/rx)² + (ly/ry)²)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/geometry/ellipse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/geometry/ellipse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,qCAAqC;AACrC,MAAM,MAAM,OAAO,GAAG;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,aAAa;IACb,EAAE,EAAE,MAAM,CAAC;IACX,aAAa;IACb,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,eAAe;AACf,eAAO,MAAM,OAAO;IAClB,SAAS;gBACG,OAAO,KAAG,QAAQ;IAC9B,0BAA0B;kBACZ,OAAO,KAAK,QAAQ,KAAG,OAAO;IAI9C;;;OAGG;gBACW,OAAO,QAAQ,UAAU,KAAG,QAAQ;IAqClD;;;OAGG;uBACkB,OAAO,UAAU,QAAQ,KAAG,QAAQ;CAQxD,CAAC"}
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
+
import { localToWorld, worldToLocal } from "./_transform.js";
|
|
1
2
|
//#region src/geometry/ellipse.ts
|
|
2
3
|
var SQRT_HALF = Math.SQRT1_2;
|
|
3
|
-
var localToWorld = (e, local) => {
|
|
4
|
-
const angle = e.rotate ?? 0;
|
|
5
|
-
if (angle === 0) return [e.x + local[0], e.y + local[1]];
|
|
6
|
-
const cos = Math.cos(angle);
|
|
7
|
-
const sin = Math.sin(angle);
|
|
8
|
-
return [e.x + local[0] * cos - local[1] * sin, e.y + local[0] * sin + local[1] * cos];
|
|
9
|
-
};
|
|
10
|
-
var worldToLocal = (e, world) => {
|
|
11
|
-
const tx = world[0] - e.x;
|
|
12
|
-
const ty = world[1] - e.y;
|
|
13
|
-
const angle = e.rotate ?? 0;
|
|
14
|
-
if (angle === 0) return [tx, ty];
|
|
15
|
-
const cos = Math.cos(angle);
|
|
16
|
-
const sin = Math.sin(angle);
|
|
17
|
-
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
18
|
-
};
|
|
19
4
|
/** 椭圆相关基础工具 */
|
|
20
5
|
var ellipse = {
|
|
21
6
|
/** 中心 */
|
|
@@ -6,7 +6,7 @@ import { Position } from './point';
|
|
|
6
6
|
export type PolarPosition = {
|
|
7
7
|
/** 极坐标原点:节点 id / 笛卡尔 / 嵌套极坐标;省略表示 [0,0] */
|
|
8
8
|
origin?: string | Position | PolarPosition;
|
|
9
|
-
/**
|
|
9
|
+
/** 角度(度数):从 +x 轴量起,90° 朝 +y(屏幕下方),与 ArcStep / Node label 角度约定一致 */
|
|
10
10
|
angle: number;
|
|
11
11
|
/** 半径(非负) */
|
|
12
12
|
radius: number;
|
|
@@ -18,7 +18,7 @@ export declare const polar: {
|
|
|
18
18
|
* @description origin 为字符串(节点 id)时抛错——字符串解析依赖 Scene 编译器 nodeIndex
|
|
19
19
|
*/
|
|
20
20
|
toPosition: (p: PolarPosition) => Position;
|
|
21
|
-
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
21
|
+
/** 笛卡尔 → 极坐标(point.toPolar 别名,angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
22
22
|
fromPosition: (p: Position) => PolarPosition;
|
|
23
23
|
/** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
|
|
24
24
|
offsetFrom: (origin: Position, offset: {
|
|
@@ -1 +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;AAS/C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC3C,
|
|
1
|
+
{"version":3,"file":"polar.d.ts","sourceRoot":"","sources":["../../../src/geometry/polar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAS,MAAM,SAAS,CAAC;AAS/C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC3C,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,oDAAoD;AACpD,eAAO,MAAM,KAAK;IAChB;;;OAGG;oBACa,aAAa,KAAG,QAAQ;IAmBxC,qEAAqE;sBACnD,QAAQ,KAAG,aAAa;IAC1C,gCAAgC;yBAEtB,QAAQ,UACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KACxC,QAAQ;IAOb;;;;OAIG;eAEI,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CACX,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { point } from "./point.js";
|
|
2
2
|
//#region src/geometry/polar.ts
|
|
3
3
|
var DEG_TO_RAD = Math.PI / 180;
|
|
4
|
-
var RAD_TO_DEG = 180 / Math.PI;
|
|
5
4
|
/** 极坐标 ↔ 笛卡尔转换工具集(polar 不参与几何计算,参与时先 toPosition) */
|
|
6
5
|
var polar = {
|
|
7
6
|
/**
|
|
@@ -17,11 +16,8 @@ var polar = {
|
|
|
17
16
|
const rad = p.angle * DEG_TO_RAD;
|
|
18
17
|
return [origin[0] + Math.cos(rad) * p.radius, origin[1] + Math.sin(rad) * p.radius];
|
|
19
18
|
},
|
|
20
|
-
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
21
|
-
fromPosition: (p) => (
|
|
22
|
-
angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
|
|
23
|
-
radius: Math.hypot(p[0], p[1])
|
|
24
|
-
}),
|
|
19
|
+
/** 笛卡尔 → 极坐标(point.toPolar 别名,angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
20
|
+
fromPosition: (p) => point.toPolar(p),
|
|
25
21
|
/** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
|
|
26
22
|
offsetFrom: (origin, offset) => {
|
|
27
23
|
const rad = offset.angle * DEG_TO_RAD;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/geometry/rect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/geometry/rect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,gCAAgC;AAChC,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,YAAY;;;;;;;;;;CAUf,CAAC;AAEX,+BAA+B;AAC/B,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE1E,eAAO,MAAM,IAAI;IACf,WAAW;gBACC,IAAI,KAAG,QAAQ;IAC3B,uBAAuB;kBACT,IAAI,KAAK,QAAQ,KAAG,OAAO;IAMzC,sCAAsC;gBAC1B,IAAI,QAAQ,UAAU,KAAG,QAAQ;IAuC7C,qDAAqD;uBAClC,IAAI,UAAU,QAAQ,KAAG,QAAQ;CAUrD,CAAC"}
|
package/dist/es/geometry/rect.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { localToWorld, worldToLocal } from "./_transform.js";
|
|
1
2
|
//#region src/geometry/rect.ts
|
|
2
3
|
/** 矩形 9 个标准 anchor 名常量(与 RectAnchor 配对,用 RECT_ANCHORS.NORTH 避免拼错) */
|
|
3
4
|
var RECT_ANCHORS = {
|
|
@@ -11,24 +12,6 @@ var RECT_ANCHORS = {
|
|
|
11
12
|
SOUTH_EAST: "south-east",
|
|
12
13
|
SOUTH_WEST: "south-west"
|
|
13
14
|
};
|
|
14
|
-
/** 本地坐标(以中心为原点)→ 世界坐标,考虑 rect.rotate */
|
|
15
|
-
var localToWorld = (r, local) => {
|
|
16
|
-
const angle = r.rotate ?? 0;
|
|
17
|
-
if (angle === 0) return [r.x + local[0], r.y + local[1]];
|
|
18
|
-
const cos = Math.cos(angle);
|
|
19
|
-
const sin = Math.sin(angle);
|
|
20
|
-
return [r.x + local[0] * cos - local[1] * sin, r.y + local[0] * sin + local[1] * cos];
|
|
21
|
-
};
|
|
22
|
-
/** 世界坐标 → 本地坐标(localToWorld 逆变换) */
|
|
23
|
-
var worldToLocal = (r, world) => {
|
|
24
|
-
const tx = world[0] - r.x;
|
|
25
|
-
const ty = world[1] - r.y;
|
|
26
|
-
const angle = r.rotate ?? 0;
|
|
27
|
-
if (angle === 0) return [tx, ty];
|
|
28
|
-
const cos = Math.cos(angle);
|
|
29
|
-
const sin = Math.sin(angle);
|
|
30
|
-
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
31
|
-
};
|
|
32
15
|
var rect = {
|
|
33
16
|
/** 几何中心 */
|
|
34
17
|
center: (r) => [r.x, r.y],
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
|
+
/**
|
|
3
|
+
* 段几何采样结果:t 处坐标点 + 归一化切线向量
|
|
4
|
+
* @description 各 `*SegmentSample` 函数(line / quad / cubic / fold / arc / circle / ellipse)的统一返回形态;供 step.label emit 算位置 / 切线 / sloped 旋转角
|
|
5
|
+
*/
|
|
2
6
|
export type SegmentSample = {
|
|
3
|
-
/** t
|
|
7
|
+
/** t 处的点(user units) */
|
|
4
8
|
point: Position;
|
|
5
9
|
/** t 处的切线(单位向量;零向量时回退 [1, 0]) */
|
|
6
10
|
tangent: Position;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBxC,MAAM,MAAM,aAAa,GAAG;IAC1B,
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBxC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,wBAAwB;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,iCAAiC;IACjC,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AAQF,oBAAoB;AACpB,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,SAAS,QAAQ,EACjB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aASF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAqBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,QAAQ,QAAQ,EAChB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGF,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,eAAe,MAAM,EACrB,aAAa,MAAM,EACnB,GAAG,MAAM,KACR,aAUF,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,GAAG,MAAM,KACR,aASF,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,QAAQ,EAChB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,GAAG,MAAM,KACR,aASF,CAAC"}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
* @retikz/core 公开 API
|
|
3
3
|
* @description 任何 framework adapter(@retikz/react、@retikz/vue、@retikz/canvas、@retikz/ssr)只能 import 本文件导出内容,不准走子路径。本包零 React/零 DOM 依赖
|
|
4
4
|
*/
|
|
5
|
-
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema,
|
|
6
|
-
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRPath, IRChild, IR, ArrowShape, IRArrowDetail, IRArrowEndDetail, NodeShape, NodeTextAlign, } from './ir';
|
|
5
|
+
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
6
|
+
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRChild, IR, ArrowShape, IRArrowDetail, IRArrowEndDetail, NodeShape, NodeTextAlign, } from './ir';
|
|
7
7
|
export { ARROW_SHAPES, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, } from './ir';
|
|
8
|
-
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
|
|
9
|
+
/** 7 个 named PathCommand 分支(便于 wrapper / Pick<>) */
|
|
10
|
+
MovePathCommand, LinePathCommand, QuadPathCommand, CubicPathCommand, ArcPathCommand, EllipseArcPathCommand, ClosePathCommand, ArrowEndSpec, GroupPrim, Transform,
|
|
11
|
+
/** 3 个 named Transform 分支 */
|
|
12
|
+
TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, } from './primitive';
|
|
13
|
+
export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, CompileWarning, } from './compile';
|
|
14
|
+
export { computeLayout, fallbackMeasurer, compileToScene } from './compile';
|
|
11
15
|
export type { WayItem, WayDSL, WayCycle, WayVia, WayRelativeItem, WayLabel, WayLabelOp, } from './parsers';
|
|
12
16
|
export { parseWay, DrawWay, parseTargetSugar } from './parsers';
|
|
13
|
-
export type { Position, Rect, RectAnchor, Circle,
|
|
17
|
+
export type { Position, Rect, RectAnchor, Circle, Ellipse, Diamond, PolarPosition, } from './geometry';
|
|
14
18
|
export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
|
|
15
|
-
export type { ValueOf } from './types';
|
|
19
|
+
export type { ValueOf, AssertEqual } from './types';
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,0BAA0B,EAC1B,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,MAAM,EACN,MAAM,EACN,WAAW,EACX,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,MAAM,EACN,OAAO,EACP,EAAE,EACF,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,aAAa,GACd,MAAM,MAAM,CAAC;AACd,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,sCAAsC,EACtC,WAAW,EACX,gBAAgB,GACjB,MAAM,MAAM,CAAC;AAGd,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,WAAW;AACX,oDAAoD;AACpD,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,SAAS;AACT,6BAA6B;AAC7B,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,MAAM,EACN,KAAK,GACN,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG5E,YAAY,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,eAAe,EACf,QAAQ,EACR,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIhE,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxF,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/es/index.js
CHANGED
|
@@ -2,11 +2,13 @@ import { PositionSchema } from "./ir/position/position.js";
|
|
|
2
2
|
import { PolarPositionSchema } from "./ir/position/polar-position.js";
|
|
3
3
|
import { AT_DIRECTIONS, AtPositionSchema } from "./ir/position/at-position.js";
|
|
4
4
|
import { OffsetPositionSchema } from "./ir/position/offset-position.js";
|
|
5
|
+
import { FontSchema } from "./ir/font.js";
|
|
6
|
+
import { LineSpecSchema, TextBlockSchema } from "./ir/text.js";
|
|
5
7
|
import { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, ArrowDetailSchema, ArrowEndDetailSchema, HOLLOW_ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
6
8
|
import { RelativeAccumulateTargetSchema, RelativeTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
7
9
|
import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepLabelSchema, StepSchema } from "./ir/path/step.js";
|
|
8
10
|
import { PathSchema } from "./ir/path/path.js";
|
|
9
|
-
import {
|
|
11
|
+
import { NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema } from "./ir/node.js";
|
|
10
12
|
import { CoordinateSchema } from "./ir/coordinate.js";
|
|
11
13
|
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema } from "./ir/scene.js";
|
|
12
14
|
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
@@ -14,9 +16,10 @@ import { circle } from "./geometry/circle.js";
|
|
|
14
16
|
import { diamond } from "./geometry/diamond.js";
|
|
15
17
|
import { ellipse } from "./geometry/ellipse.js";
|
|
16
18
|
import { fallbackMeasurer } from "./compile/text-metrics.js";
|
|
19
|
+
import { computeLayout } from "./compile/layout.js";
|
|
17
20
|
import { compileToScene } from "./compile/compile.js";
|
|
18
21
|
import { parseTargetSugar } from "./parsers/parseTargetSugar.js";
|
|
19
22
|
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
20
23
|
import { polar } from "./geometry/polar.js";
|
|
21
24
|
import { point } from "./geometry/point.js";
|
|
22
|
-
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, ArcStepSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, HOLLOW_ARROW_SHAPES, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema,
|
|
25
|
+
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, ArcStepSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, HOLLOW_ARROW_SHAPES, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema, OffsetPositionSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, circle, compileToScene, computeLayout, diamond, ellipse, fallbackMeasurer, parseTargetSugar, parseWay, point, polar, rect };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Coordinate 占位节点(TikZ `\coordinate (m) at (3,2);` 同义)
|
|
4
|
-
* @description 命名一个点供 path/at 引用,不绘制任何图形;支持笛卡尔/极坐标/相对定位三种 position 形态。必须有 id,不参与
|
|
4
|
+
* @description 命名一个点供 path/at 引用,不绘制任何图形;支持笛卡尔/极坐标/相对定位三种 position 形态。必须有 id,不参与 layout 扩展,与 Node 在同一 nodeIndex 注册
|
|
5
5
|
*/
|
|
6
6
|
export declare const CoordinateSchema: z.ZodObject<{
|
|
7
7
|
type: z.ZodLiteral<"coordinate">;
|
package/dist/es/ir/coordinate.js
CHANGED
|
@@ -6,7 +6,7 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/ir/coordinate.ts
|
|
7
7
|
/**
|
|
8
8
|
* Coordinate 占位节点(TikZ `\coordinate (m) at (3,2);` 同义)
|
|
9
|
-
* @description 命名一个点供 path/at 引用,不绘制任何图形;支持笛卡尔/极坐标/相对定位三种 position 形态。必须有 id,不参与
|
|
9
|
+
* @description 命名一个点供 path/at 引用,不绘制任何图形;支持笛卡尔/极坐标/相对定位三种 position 形态。必须有 id,不参与 layout 扩展,与 Node 在同一 nodeIndex 注册
|
|
10
10
|
*/
|
|
11
11
|
var CoordinateSchema = z.object({
|
|
12
12
|
type: z.literal("coordinate").describe("Discriminator marking this child as a coordinate placeholder"),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** 字体规格:family/size/weight/style 全部可选 */
|
|
3
|
+
export declare const FontSchema: z.ZodObject<{
|
|
4
|
+
family: z.ZodOptional<z.ZodString>;
|
|
5
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
7
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
family?: string | undefined;
|
|
10
|
+
size?: number | undefined;
|
|
11
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
12
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
family?: string | undefined;
|
|
15
|
+
size?: number | undefined;
|
|
16
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
17
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/** 字体规格 IR 类型(所有字段可选,编译期解析默认值) */
|
|
20
|
+
export type IRFont = z.infer<typeof FontSchema>;
|
|
21
|
+
//# sourceMappingURL=font.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../../src/ir/font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yCAAyC;AACzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAyBpB,CAAC;AAEJ,kCAAkC;AAClC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/ir/font.ts
|
|
3
|
+
/** 字体规格:family/size/weight/style 全部可选 */
|
|
4
|
+
var FontSchema = z.object({
|
|
5
|
+
family: z.string().optional().describe("CSS font-family string, e.g. \"serif\", \"monospace\", \"Inter, sans-serif\""),
|
|
6
|
+
size: z.number().positive().finite().optional().describe("Font size in user units; falls back to the renderer default when omitted"),
|
|
7
|
+
weight: z.union([z.enum(["normal", "bold"]), z.number().finite()]).optional().describe("CSS font-weight: keyword `normal` / `bold` or numeric 100..900"),
|
|
8
|
+
style: z.enum([
|
|
9
|
+
"normal",
|
|
10
|
+
"italic",
|
|
11
|
+
"oblique"
|
|
12
|
+
]).optional().describe("CSS font-style")
|
|
13
|
+
}).describe("Font properties (family / size / weight / style). All fields optional; consumed by Node text / Node label / LineSpec / future TikZ / Scope font defaults.");
|
|
14
|
+
//#endregion
|
|
15
|
+
export { FontSchema };
|
package/dist/es/ir/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|