@retikz/core 0.2.0-alpha.1 → 0.2.0-alpha.3
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 +8 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +21 -6
- package/dist/es/compile/node.d.ts +15 -10
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +44 -181
- package/dist/es/compile/path/index.js +1 -1
- package/dist/es/compile/path/label.d.ts +1 -1
- package/dist/es/compile/path/label.d.ts.map +1 -1
- package/dist/es/compile/path/label.js +17 -4
- package/dist/es/compile/scope.d.ts.map +1 -1
- package/dist/es/compile/scope.js +3 -1
- package/dist/es/compile/style.d.ts +46 -0
- package/dist/es/compile/style.d.ts.map +1 -0
- package/dist/es/compile/style.js +259 -0
- package/dist/es/index.d.ts +4 -2
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +5 -3
- package/dist/es/ir/node.d.ts +19 -12
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +2 -1
- package/dist/es/ir/path/path.d.ts +531 -0
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +1 -0
- package/dist/es/ir/path/step.d.ts +834 -0
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +5 -1
- package/dist/es/ir/scope.d.ts +3493 -3
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +64 -4
- package/dist/es/shapes/_shared.d.ts +7 -0
- package/dist/es/shapes/_shared.d.ts.map +1 -0
- package/dist/es/shapes/_shared.js +11 -0
- package/dist/es/shapes/circle.d.ts +8 -0
- package/dist/es/shapes/circle.d.ts.map +1 -0
- package/dist/es/shapes/circle.js +33 -0
- package/dist/es/shapes/diamond.d.ts +8 -0
- package/dist/es/shapes/diamond.d.ts.map +1 -0
- package/dist/es/shapes/diamond.js +65 -0
- package/dist/es/shapes/ellipse.d.ts +8 -0
- package/dist/es/shapes/ellipse.d.ts.map +1 -0
- package/dist/es/shapes/ellipse.js +45 -0
- package/dist/es/shapes/index.d.ts +14 -0
- package/dist/es/shapes/index.d.ts.map +1 -0
- package/dist/es/shapes/index.js +15 -0
- package/dist/es/shapes/rectangle.d.ts +8 -0
- package/dist/es/shapes/rectangle.d.ts.map +1 -0
- package/dist/es/shapes/rectangle.js +40 -0
- package/dist/es/shapes/types.d.ts +44 -0
- package/dist/es/shapes/types.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +23 -8
- package/dist/lib/compile/compile.d.ts +8 -1
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +44 -181
- package/dist/lib/compile/node.d.ts +15 -10
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +1 -1
- package/dist/lib/compile/path/label.cjs +17 -4
- package/dist/lib/compile/path/label.d.ts +1 -1
- package/dist/lib/compile/path/label.d.ts.map +1 -1
- package/dist/lib/compile/scope.cjs +3 -1
- package/dist/lib/compile/scope.d.ts.map +1 -1
- package/dist/lib/compile/style.cjs +262 -0
- package/dist/lib/compile/style.d.ts +46 -0
- package/dist/lib/compile/style.d.ts.map +1 -0
- package/dist/lib/index.cjs +10 -1
- package/dist/lib/index.d.ts +4 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +2 -1
- package/dist/lib/ir/node.d.ts +19 -12
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +1 -0
- package/dist/lib/ir/path/path.d.ts +531 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +5 -1
- package/dist/lib/ir/path/step.d.ts +834 -0
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +67 -3
- package/dist/lib/ir/scope.d.ts +3493 -3
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/shapes/_shared.cjs +11 -0
- package/dist/lib/shapes/_shared.d.ts +7 -0
- package/dist/lib/shapes/_shared.d.ts.map +1 -0
- package/dist/lib/shapes/circle.cjs +33 -0
- package/dist/lib/shapes/circle.d.ts +8 -0
- package/dist/lib/shapes/circle.d.ts.map +1 -0
- package/dist/lib/shapes/diamond.cjs +65 -0
- package/dist/lib/shapes/diamond.d.ts +8 -0
- package/dist/lib/shapes/diamond.d.ts.map +1 -0
- package/dist/lib/shapes/ellipse.cjs +45 -0
- package/dist/lib/shapes/ellipse.d.ts +8 -0
- package/dist/lib/shapes/ellipse.d.ts.map +1 -0
- package/dist/lib/shapes/index.cjs +14 -0
- package/dist/lib/shapes/index.d.ts +14 -0
- package/dist/lib/shapes/index.d.ts.map +1 -0
- package/dist/lib/shapes/rectangle.cjs +40 -0
- package/dist/lib/shapes/rectangle.d.ts +8 -0
- package/dist/lib/shapes/rectangle.d.ts.map +1 -0
- package/dist/lib/shapes/types.d.ts +44 -0
- package/dist/lib/shapes/types.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/ir/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/ir/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,aAAa,CAAC;A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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmGrB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_rect = require("../geometry/rect.cjs");
|
|
2
|
+
//#region src/shapes/_shared.ts
|
|
3
|
+
/** RECT_ANCHORS 的 9 个合法 anchor 名集合(成员校验用) */
|
|
4
|
+
var RECT_ANCHOR_SET = new Set(Object.values(require_rect.RECT_ANCHORS));
|
|
5
|
+
/**
|
|
6
|
+
* 把任意字符串收窄为合法 RectAnchor,否则 undefined
|
|
7
|
+
* @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
|
|
8
|
+
*/
|
|
9
|
+
var asRectAnchor = (name) => RECT_ANCHOR_SET.has(name) ? name : void 0;
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.asRectAnchor = asRectAnchor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RectAnchor } from '../geometry/rect';
|
|
2
|
+
/**
|
|
3
|
+
* 把任意字符串收窄为合法 RectAnchor,否则 undefined
|
|
4
|
+
* @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
|
|
5
|
+
*/
|
|
6
|
+
export declare const asRectAnchor: (name: string) => RectAnchor | undefined;
|
|
7
|
+
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../../src/shapes/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKjE;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,UAAU,GAAG,SACK,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const require_circle = require("../geometry/circle.cjs");
|
|
2
|
+
const require__shared = require("./_shared.cjs");
|
|
3
|
+
const require_ellipse = require("./ellipse.cjs");
|
|
4
|
+
//#region src/shapes/circle.ts
|
|
5
|
+
/** 外接框 Rect → Circle(radius = 半宽;circle 外接框宽=高) */
|
|
6
|
+
var toCircle = (r) => ({
|
|
7
|
+
x: r.x,
|
|
8
|
+
y: r.y,
|
|
9
|
+
radius: r.width / 2,
|
|
10
|
+
rotate: r.rotate
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* circle 注册项
|
|
14
|
+
* @description circumscribe = 内框对角线/2(两轴相等);几何走 circle 数学层;
|
|
15
|
+
* emit 复用 `ellipse.emit`(circle = rx=ry 的 ellipse),与旧 circle→`emitEllipseShape` 等价
|
|
16
|
+
*/
|
|
17
|
+
var circle = {
|
|
18
|
+
circumscribe: (hw, hh) => {
|
|
19
|
+
const r = Math.sqrt(hw * hw + hh * hh);
|
|
20
|
+
return {
|
|
21
|
+
halfWidth: r,
|
|
22
|
+
halfHeight: r
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
boundaryPoint: (r, toward) => require_circle.circle.boundaryPoint(toCircle(r), toward),
|
|
26
|
+
anchor: (r, name) => {
|
|
27
|
+
const a = require__shared.asRectAnchor(name);
|
|
28
|
+
return a ? require_circle.circle.anchor(toCircle(r), a) : void 0;
|
|
29
|
+
},
|
|
30
|
+
emit: (r, style, round) => require_ellipse.ellipse.emit(r, style, round)
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.circle = circle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShapeDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* circle 注册项
|
|
4
|
+
* @description circumscribe = 内框对角线/2(两轴相等);几何走 circle 数学层;
|
|
5
|
+
* emit 复用 `ellipse.emit`(circle = rx=ry 的 ellipse),与旧 circle→`emitEllipseShape` 等价
|
|
6
|
+
*/
|
|
7
|
+
export declare const circle: ShapeDefinition;
|
|
8
|
+
//# sourceMappingURL=circle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/shapes/circle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,eAWpB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const require__shared = require("./_shared.cjs");
|
|
2
|
+
const require_diamond = require("../geometry/diamond.cjs");
|
|
3
|
+
//#region src/shapes/diamond.ts
|
|
4
|
+
/** 外接框 Rect → Diamond(halfA/halfB = 半宽/半高;顶点在 ±halfA / ±halfB) */
|
|
5
|
+
var toDiamond = (r) => ({
|
|
6
|
+
x: r.x,
|
|
7
|
+
y: r.y,
|
|
8
|
+
halfA: r.width / 2,
|
|
9
|
+
halfB: r.height / 2,
|
|
10
|
+
rotate: r.rotate
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* diamond 注册项
|
|
14
|
+
* @description circumscribe = 内框 ×2(内框 4 顶点落在菱形 4 边上);几何由外接框半轴派生;
|
|
15
|
+
* emit 在**轴对齐空间**取 4 顶点出 PathPrim(rotate 由外层 group 施加),与旧 `emitDiamondShape(unrotated(...))` 等价
|
|
16
|
+
*/
|
|
17
|
+
var diamond = {
|
|
18
|
+
circumscribe: (hw, hh) => ({
|
|
19
|
+
halfWidth: hw * 2,
|
|
20
|
+
halfHeight: hh * 2
|
|
21
|
+
}),
|
|
22
|
+
boundaryPoint: (r, toward) => require_diamond.diamond.boundaryPoint(toDiamond(r), toward),
|
|
23
|
+
anchor: (r, name) => {
|
|
24
|
+
const a = require__shared.asRectAnchor(name);
|
|
25
|
+
return a ? require_diamond.diamond.anchor(toDiamond(r), a) : void 0;
|
|
26
|
+
},
|
|
27
|
+
*emit(r, style, round) {
|
|
28
|
+
const d = toDiamond(r);
|
|
29
|
+
const e = require_diamond.diamond.anchor(d, "east");
|
|
30
|
+
const n = require_diamond.diamond.anchor(d, "north");
|
|
31
|
+
const w = require_diamond.diamond.anchor(d, "west");
|
|
32
|
+
const s = require_diamond.diamond.anchor(d, "south");
|
|
33
|
+
yield {
|
|
34
|
+
type: "path",
|
|
35
|
+
commands: [
|
|
36
|
+
{
|
|
37
|
+
kind: "move",
|
|
38
|
+
to: [round(e[0]), round(e[1])]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
kind: "line",
|
|
42
|
+
to: [round(n[0]), round(n[1])]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
kind: "line",
|
|
46
|
+
to: [round(w[0]), round(w[1])]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
kind: "line",
|
|
50
|
+
to: [round(s[0]), round(s[1])]
|
|
51
|
+
},
|
|
52
|
+
{ kind: "close" }
|
|
53
|
+
],
|
|
54
|
+
fill: style.fill ?? "transparent",
|
|
55
|
+
fillOpacity: style.fillOpacity,
|
|
56
|
+
stroke: style.stroke ?? "currentColor",
|
|
57
|
+
strokeOpacity: style.strokeOpacity,
|
|
58
|
+
strokeWidth: style.strokeWidth ?? 1,
|
|
59
|
+
dashPattern: style.dashPattern,
|
|
60
|
+
opacity: style.opacity
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.diamond = diamond;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShapeDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* diamond 注册项
|
|
4
|
+
* @description circumscribe = 内框 ×2(内框 4 顶点落在菱形 4 边上);几何由外接框半轴派生;
|
|
5
|
+
* emit 在**轴对齐空间**取 4 顶点出 PathPrim(rotate 由外层 group 施加),与旧 `emitDiamondShape(unrotated(...))` 等价
|
|
6
|
+
*/
|
|
7
|
+
export declare const diamond: ShapeDefinition;
|
|
8
|
+
//# sourceMappingURL=diamond.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diamond.d.ts","sourceRoot":"","sources":["../../../src/shapes/diamond.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,eA+BrB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const require_ellipse = require("../geometry/ellipse.cjs");
|
|
2
|
+
const require__shared = require("./_shared.cjs");
|
|
3
|
+
//#region src/shapes/ellipse.ts
|
|
4
|
+
/** 外接框 Rect → Ellipse(rx/ry = 半宽/半高) */
|
|
5
|
+
var toEllipse = (r) => ({
|
|
6
|
+
x: r.x,
|
|
7
|
+
y: r.y,
|
|
8
|
+
rx: r.width / 2,
|
|
9
|
+
ry: r.height / 2,
|
|
10
|
+
rotate: r.rotate
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* ellipse 注册项
|
|
14
|
+
* @description circumscribe = 内框 ×√2(内框 4 顶点落在椭圆周上);几何由外接框半轴派生;
|
|
15
|
+
* emit 出 EllipsePrim,与旧 `emitEllipseShape` 逐字段等价
|
|
16
|
+
*/
|
|
17
|
+
var ellipse = {
|
|
18
|
+
circumscribe: (hw, hh) => ({
|
|
19
|
+
halfWidth: hw * Math.SQRT2,
|
|
20
|
+
halfHeight: hh * Math.SQRT2
|
|
21
|
+
}),
|
|
22
|
+
boundaryPoint: (r, toward) => require_ellipse.ellipse.boundaryPoint(toEllipse(r), toward),
|
|
23
|
+
anchor: (r, name) => {
|
|
24
|
+
const a = require__shared.asRectAnchor(name);
|
|
25
|
+
return a ? require_ellipse.ellipse.anchor(toEllipse(r), a) : void 0;
|
|
26
|
+
},
|
|
27
|
+
*emit(r, style, round) {
|
|
28
|
+
yield {
|
|
29
|
+
type: "ellipse",
|
|
30
|
+
cx: round(r.x),
|
|
31
|
+
cy: round(r.y),
|
|
32
|
+
rx: round(r.width / 2),
|
|
33
|
+
ry: round(r.height / 2),
|
|
34
|
+
fill: style.fill ?? "transparent",
|
|
35
|
+
fillOpacity: style.fillOpacity,
|
|
36
|
+
stroke: style.stroke ?? "currentColor",
|
|
37
|
+
strokeOpacity: style.strokeOpacity,
|
|
38
|
+
strokeWidth: style.strokeWidth ?? 1,
|
|
39
|
+
dashPattern: style.dashPattern,
|
|
40
|
+
opacity: style.opacity
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.ellipse = ellipse;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShapeDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* ellipse 注册项
|
|
4
|
+
* @description circumscribe = 内框 ×√2(内框 4 顶点落在椭圆周上);几何由外接框半轴派生;
|
|
5
|
+
* emit 出 EllipsePrim,与旧 `emitEllipseShape` 逐字段等价
|
|
6
|
+
*/
|
|
7
|
+
export declare const ellipse: ShapeDefinition;
|
|
8
|
+
//# sourceMappingURL=ellipse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/shapes/ellipse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,eAuBrB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require("../geometry/_transform.cjs");
|
|
2
|
+
const require_ellipse = require("./ellipse.cjs");
|
|
3
|
+
const require_circle = require("./circle.cjs");
|
|
4
|
+
const require_diamond = require("./diamond.cjs");
|
|
5
|
+
//#region src/shapes/index.ts
|
|
6
|
+
/** 内置 4 shape 注册项;与 `CompileOptions.shapes` 合并时被同名注入覆盖 */
|
|
7
|
+
var BUILTIN_SHAPES = {
|
|
8
|
+
rectangle: require("./rectangle.cjs").rectangle,
|
|
9
|
+
circle: require_circle.circle,
|
|
10
|
+
ellipse: require_ellipse.ellipse,
|
|
11
|
+
diamond: require_diamond.diamond
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.BUILTIN_SHAPES = BUILTIN_SHAPES;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BuiltinShapeName } from '../ir/node';
|
|
2
|
+
import { circle } from './circle';
|
|
3
|
+
import { diamond } from './diamond';
|
|
4
|
+
import { ellipse } from './ellipse';
|
|
5
|
+
import { rectangle } from './rectangle';
|
|
6
|
+
import { ShapeDefinition } from './types';
|
|
7
|
+
/** 内置 4 shape 注册项;与 `CompileOptions.shapes` 合并时被同名注入覆盖 */
|
|
8
|
+
export declare const BUILTIN_SHAPES: Record<BuiltinShapeName, ShapeDefinition>;
|
|
9
|
+
export { rectangle, circle, ellipse, diamond };
|
|
10
|
+
export type { ShapeDefinition, ShapeStyle } from './types';
|
|
11
|
+
export type { Rect } from '../geometry/rect';
|
|
12
|
+
export type { Position } from '../geometry/point';
|
|
13
|
+
export { worldToLocal, localToWorld } from '../geometry/_transform';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CAKpE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_rect = require("../geometry/rect.cjs");
|
|
2
|
+
const require__shared = require("./_shared.cjs");
|
|
3
|
+
//#region src/shapes/rectangle.ts
|
|
4
|
+
/**
|
|
5
|
+
* rectangle 注册项
|
|
6
|
+
* @description circumscribe = identity(视觉边界 = 内框);boundaryPoint / anchor 直接走 rect 数学层;
|
|
7
|
+
* emit 出 RectPrim(圆角走 cornerRadius),与旧 `emitRectShape` 逐字段等价
|
|
8
|
+
*/
|
|
9
|
+
var rectangle = {
|
|
10
|
+
circumscribe: (hw, hh) => ({
|
|
11
|
+
halfWidth: hw,
|
|
12
|
+
halfHeight: hh
|
|
13
|
+
}),
|
|
14
|
+
boundaryPoint: (r, toward) => require_rect.rect.boundaryPoint(r, toward),
|
|
15
|
+
anchor: (r, name) => {
|
|
16
|
+
const a = require__shared.asRectAnchor(name);
|
|
17
|
+
return a ? require_rect.rect.anchor(r, a) : void 0;
|
|
18
|
+
},
|
|
19
|
+
*emit(r, style, round) {
|
|
20
|
+
const halfW = r.width / 2;
|
|
21
|
+
const halfH = r.height / 2;
|
|
22
|
+
yield {
|
|
23
|
+
type: "rect",
|
|
24
|
+
x: round(r.x - halfW),
|
|
25
|
+
y: round(r.y - halfH),
|
|
26
|
+
width: round(r.width),
|
|
27
|
+
height: round(r.height),
|
|
28
|
+
fill: style.fill ?? "transparent",
|
|
29
|
+
fillOpacity: style.fillOpacity,
|
|
30
|
+
stroke: style.stroke ?? "currentColor",
|
|
31
|
+
strokeOpacity: style.strokeOpacity,
|
|
32
|
+
strokeWidth: style.strokeWidth ?? 1,
|
|
33
|
+
dashPattern: style.dashPattern,
|
|
34
|
+
cornerRadius: style.roundedCorners,
|
|
35
|
+
opacity: style.opacity
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.rectangle = rectangle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShapeDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* rectangle 注册项
|
|
4
|
+
* @description circumscribe = identity(视觉边界 = 内框);boundaryPoint / anchor 直接走 rect 数学层;
|
|
5
|
+
* emit 出 RectPrim(圆角走 cornerRadius),与旧 `emitRectShape` 逐字段等价
|
|
6
|
+
*/
|
|
7
|
+
export declare const rectangle: ShapeDefinition;
|
|
8
|
+
//# sourceMappingURL=rectangle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rectangle.d.ts","sourceRoot":"","sources":["../../../src/shapes/rectangle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,eA0BvB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Position } from '../geometry/point';
|
|
2
|
+
import { Rect } from '../geometry/rect';
|
|
3
|
+
import { ScenePrimitive } from '../primitive';
|
|
4
|
+
/**
|
|
5
|
+
* emit 需要的视觉样式子集
|
|
6
|
+
* @description 从 NodeLayout 的样式字段收敛(不含几何 / 文本);独立 type,不耦合内部 NodeLayout。
|
|
7
|
+
* 字段名与 NodeLayout 样式字段一致(单一词汇表)。
|
|
8
|
+
*/
|
|
9
|
+
export type ShapeStyle = {
|
|
10
|
+
fill?: string;
|
|
11
|
+
fillOpacity?: number;
|
|
12
|
+
stroke?: string;
|
|
13
|
+
strokeOpacity?: number;
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
dashPattern?: Array<number>;
|
|
16
|
+
roundedCorners?: number;
|
|
17
|
+
opacity?: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 一个 shape 的可注册定义:外接 / 边界 / anchor / emit 四件事
|
|
21
|
+
* @description plain object(factory 友好:`createPolygonShape(6)` 这类普通函数返回它即可);含函数、
|
|
22
|
+
* **不进 IR**,走 `CompileOptions.shapes` 运行时注入。内置 4 shape 也是注册项(无内置特权)。
|
|
23
|
+
*
|
|
24
|
+
* 坐标语义两套,第三方最易写错:
|
|
25
|
+
* - `boundaryPoint` / `anchor` 收**带 `rotate` 的 Rect**——用 re-export 的 `worldToLocal` / `localToWorld` 写局部系几何。
|
|
26
|
+
* - `emit` 收**轴对齐 Rect(rotate=0)**——旋转由编译器在外层 `GroupPrim` 统一施加。
|
|
27
|
+
*/
|
|
28
|
+
export type ShapeDefinition = {
|
|
29
|
+
/**
|
|
30
|
+
* 外接:内容半轴(text + padding)→ 外接框半轴。
|
|
31
|
+
* @description rectangle: identity;circle: √(hw²+hh²) 两轴相等;ellipse: ×√2;diamond: ×2。
|
|
32
|
+
*/
|
|
33
|
+
circumscribe: (innerHalfWidth: number, innerHalfHeight: number) => {
|
|
34
|
+
halfWidth: number;
|
|
35
|
+
halfHeight: number;
|
|
36
|
+
};
|
|
37
|
+
/** 中心 → toward 射线 ∩ 边界(rect 带 rotate)。 */
|
|
38
|
+
boundaryPoint: (rect: Rect, toward: Position) => Position;
|
|
39
|
+
/** 命名 anchor 世界坐标;shape 不认识的名字返回 `undefined`(调用方据此抛清晰错误)。 */
|
|
40
|
+
anchor: (rect: Rect, name: string) => Position | undefined;
|
|
41
|
+
/** 视觉 primitive,**轴对齐空间**(rotate 由编译器外层 GroupPrim 统一施加)。 */
|
|
42
|
+
emit: (rect: Rect, style: ShapeStyle, round: (n: number) => number) => Iterable<ScenePrimitive>;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shapes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,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