@retikz/core 0.3.0-alpha.2 → 0.3.0-alpha.4
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/README.md +41 -41
- package/dist/es/compile/anchor-cache.d.ts +5 -3
- package/dist/es/compile/anchor-cache.d.ts.map +1 -1
- package/dist/es/compile/anchor-cache.js +14 -10
- package/dist/es/compile/boundary.d.ts +19 -0
- package/dist/es/compile/boundary.d.ts.map +1 -0
- package/dist/es/compile/boundary.js +64 -0
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +15 -2
- package/dist/es/compile/node.d.ts +24 -8
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +106 -17
- package/dist/es/compile/path/anchor.d.ts.map +1 -1
- package/dist/es/compile/path/anchor.js +7 -6
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +7 -3
- package/dist/es/compile/path/relative.js +1 -1
- package/dist/es/compile/scope.d.ts.map +1 -1
- package/dist/es/compile/scope.js +2 -1
- package/dist/es/geometry/arc.d.ts +14 -0
- package/dist/es/geometry/arc.d.ts.map +1 -1
- package/dist/es/geometry/arc.js +65 -9
- package/dist/es/geometry/index.d.ts +1 -0
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/geometry/rect.d.ts +2 -2
- package/dist/es/geometry/rect.d.ts.map +1 -1
- package/dist/es/geometry/rect.js +3 -3
- package/dist/es/geometry/roundedContour.d.ts +88 -0
- package/dist/es/geometry/roundedContour.d.ts.map +1 -0
- package/dist/es/geometry/roundedContour.js +417 -0
- package/dist/es/index.d.ts +6 -5
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +9 -6
- package/dist/es/ir/boundary.d.ts +25 -0
- package/dist/es/ir/boundary.d.ts.map +1 -0
- package/dist/es/ir/boundary.js +14 -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 +43 -7
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +8 -3
- package/dist/es/ir/path/arrow.d.ts +12 -12
- package/dist/es/ir/path/path.d.ts +493 -147
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +3 -0
- package/dist/es/ir/path/step.d.ts +674 -154
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +2 -2
- package/dist/es/ir/path/target.d.ts +43 -8
- package/dist/es/ir/path/target.d.ts.map +1 -1
- package/dist/es/ir/path/target.js +4 -5
- package/dist/es/ir/scope.d.ts +851 -234
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +6 -2
- package/dist/es/ir/shape.d.ts +14 -0
- package/dist/es/ir/shape.d.ts.map +1 -0
- package/dist/es/ir/shape.js +9 -0
- package/dist/es/parsers/parseNodeTarget.d.ts.map +1 -1
- package/dist/es/parsers/parseNodeTarget.js +4 -2
- package/dist/es/primitive/ellipse.d.ts +5 -0
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/group.d.ts +5 -0
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +5 -0
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +5 -0
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +5 -0
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/es/shapes/_contour.d.ts +19 -0
- package/dist/es/shapes/_contour.d.ts.map +1 -0
- package/dist/es/shapes/_contour.js +60 -0
- package/dist/es/shapes/_shared.d.ts +54 -0
- package/dist/es/shapes/_shared.d.ts.map +1 -1
- package/dist/es/shapes/_shared.js +68 -1
- package/dist/es/shapes/arc.d.ts +8 -0
- package/dist/es/shapes/arc.d.ts.map +1 -0
- package/dist/es/shapes/arc.js +104 -0
- package/dist/es/shapes/define.d.ts +13 -0
- package/dist/es/shapes/define.d.ts.map +1 -0
- package/dist/es/shapes/define.js +13 -0
- package/dist/es/shapes/ellipse.d.ts +5 -4
- package/dist/es/shapes/ellipse.d.ts.map +1 -1
- package/dist/es/shapes/ellipse.js +15 -7
- package/dist/es/shapes/index.d.ts +9 -6
- package/dist/es/shapes/index.d.ts.map +1 -1
- package/dist/es/shapes/index.js +10 -5
- package/dist/es/shapes/polygon.d.ts +13 -0
- package/dist/es/shapes/polygon.d.ts.map +1 -0
- package/dist/es/shapes/polygon.js +104 -0
- package/dist/es/shapes/rectangle.d.ts +7 -5
- package/dist/es/shapes/rectangle.d.ts.map +1 -1
- package/dist/es/shapes/rectangle.js +37 -8
- package/dist/es/shapes/sector.d.ts +9 -0
- package/dist/es/shapes/sector.d.ts.map +1 -0
- package/dist/es/shapes/sector.js +143 -0
- package/dist/es/shapes/star.d.ts +15 -0
- package/dist/es/shapes/star.d.ts.map +1 -0
- package/dist/es/shapes/star.js +113 -0
- package/dist/es/shapes/types.d.ts +47 -14
- package/dist/es/shapes/types.d.ts.map +1 -1
- package/dist/lib/compile/anchor-cache.cjs +14 -10
- package/dist/lib/compile/anchor-cache.d.ts +5 -3
- package/dist/lib/compile/anchor-cache.d.ts.map +1 -1
- package/dist/lib/compile/boundary.cjs +65 -0
- package/dist/lib/compile/boundary.d.ts +19 -0
- package/dist/lib/compile/boundary.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +15 -2
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +106 -17
- package/dist/lib/compile/node.d.ts +24 -8
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/path/anchor.cjs +7 -6
- package/dist/lib/compile/path/anchor.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +7 -3
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/compile/path/relative.cjs +1 -1
- package/dist/lib/compile/scope.cjs +2 -1
- package/dist/lib/compile/scope.d.ts.map +1 -1
- package/dist/lib/geometry/arc.cjs +66 -8
- package/dist/lib/geometry/arc.d.ts +14 -0
- package/dist/lib/geometry/arc.d.ts.map +1 -1
- package/dist/lib/geometry/index.d.ts +1 -0
- package/dist/lib/geometry/index.d.ts.map +1 -1
- package/dist/lib/geometry/rect.cjs +3 -3
- package/dist/lib/geometry/rect.d.ts +2 -2
- package/dist/lib/geometry/rect.d.ts.map +1 -1
- package/dist/lib/geometry/roundedContour.cjs +418 -0
- package/dist/lib/geometry/roundedContour.d.ts +88 -0
- package/dist/lib/geometry/roundedContour.d.ts.map +1 -0
- package/dist/lib/index.cjs +14 -7
- package/dist/lib/index.d.ts +6 -5
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/boundary.cjs +15 -0
- package/dist/lib/ir/boundary.d.ts +25 -0
- package/dist/lib/ir/boundary.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 -3
- package/dist/lib/ir/node.d.ts +43 -7
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.d.ts +12 -12
- package/dist/lib/ir/path/path.cjs +3 -0
- package/dist/lib/ir/path/path.d.ts +493 -147
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +2 -2
- package/dist/lib/ir/path/step.d.ts +674 -154
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +4 -5
- package/dist/lib/ir/path/target.d.ts +43 -8
- package/dist/lib/ir/path/target.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +6 -2
- package/dist/lib/ir/scope.d.ts +851 -234
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/ir/shape.cjs +9 -0
- package/dist/lib/ir/shape.d.ts +14 -0
- package/dist/lib/ir/shape.d.ts.map +1 -0
- package/dist/lib/parsers/parseNodeTarget.cjs +4 -2
- package/dist/lib/parsers/parseNodeTarget.d.ts.map +1 -1
- package/dist/lib/primitive/ellipse.d.ts +5 -0
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/group.d.ts +5 -0
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +5 -0
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +5 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +5 -0
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/dist/lib/shapes/_contour.cjs +61 -0
- package/dist/lib/shapes/_contour.d.ts +19 -0
- package/dist/lib/shapes/_contour.d.ts.map +1 -0
- package/dist/lib/shapes/_shared.cjs +70 -0
- package/dist/lib/shapes/_shared.d.ts +54 -0
- package/dist/lib/shapes/_shared.d.ts.map +1 -1
- package/dist/lib/shapes/arc.cjs +104 -0
- package/dist/lib/shapes/arc.d.ts +8 -0
- package/dist/lib/shapes/arc.d.ts.map +1 -0
- package/dist/lib/shapes/define.cjs +13 -0
- package/dist/lib/shapes/define.d.ts +13 -0
- package/dist/lib/shapes/define.d.ts.map +1 -0
- package/dist/lib/shapes/ellipse.cjs +15 -7
- package/dist/lib/shapes/ellipse.d.ts +5 -4
- package/dist/lib/shapes/ellipse.d.ts.map +1 -1
- package/dist/lib/shapes/index.cjs +12 -6
- package/dist/lib/shapes/index.d.ts +9 -6
- package/dist/lib/shapes/index.d.ts.map +1 -1
- package/dist/lib/shapes/polygon.cjs +104 -0
- package/dist/lib/shapes/polygon.d.ts +13 -0
- package/dist/lib/shapes/polygon.d.ts.map +1 -0
- package/dist/lib/shapes/rectangle.cjs +37 -8
- package/dist/lib/shapes/rectangle.d.ts +7 -5
- package/dist/lib/shapes/rectangle.d.ts.map +1 -1
- package/dist/lib/shapes/sector.cjs +143 -0
- package/dist/lib/shapes/sector.d.ts +9 -0
- package/dist/lib/shapes/sector.d.ts.map +1 -0
- package/dist/lib/shapes/star.cjs +113 -0
- package/dist/lib/shapes/star.d.ts +15 -0
- package/dist/lib/shapes/star.d.ts.map +1 -0
- package/dist/lib/shapes/types.d.ts +47 -14
- package/dist/lib/shapes/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/es/shapes/circle.d.ts +0 -8
- package/dist/es/shapes/circle.d.ts.map +0 -1
- package/dist/es/shapes/circle.js +0 -34
- package/dist/es/shapes/diamond.d.ts +0 -8
- package/dist/es/shapes/diamond.d.ts.map +0 -1
- package/dist/es/shapes/diamond.js +0 -66
- package/dist/lib/shapes/circle.cjs +0 -34
- package/dist/lib/shapes/circle.d.ts +0 -8
- package/dist/lib/shapes/circle.d.ts.map +0 -1
- package/dist/lib/shapes/diamond.cjs +0 -66
- package/dist/lib/shapes/diamond.d.ts +0 -8
- package/dist/lib/shapes/diamond.d.ts.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Position } from '../geometry/point';
|
|
2
3
|
import { Rect } from '../geometry/rect';
|
|
4
|
+
import { IRJsonObject } from '../ir/json';
|
|
3
5
|
import { PaintValue, ScenePrimitive } from '../primitive';
|
|
4
6
|
/**
|
|
5
7
|
* emit 需要的视觉样式子集
|
|
@@ -13,38 +15,69 @@ export type ShapeStyle = {
|
|
|
13
15
|
strokeOpacity?: number;
|
|
14
16
|
strokeWidth?: number;
|
|
15
17
|
dashPattern?: Array<number>;
|
|
16
|
-
|
|
18
|
+
cornerRadius?: number;
|
|
17
19
|
opacity?: number;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
|
-
* 一个 shape
|
|
21
|
-
* @description plain object(factory 友好:`createPolygonShape(6)`
|
|
22
|
-
*
|
|
22
|
+
* 一个 shape 的参数化可注册定义(定义点 typed 形态)
|
|
23
|
+
* @description plain object(factory 友好:`createPolygonShape(6)` 这类普通函数返回它即可);含函数与
|
|
24
|
+
* `paramsSchema`,**不进 IR**,走 `CompileOptions.shapes` 运行时注入。内置 4 shape 也是注册项(无内置特权)。
|
|
25
|
+
* 每个计算函数末位收 per-instance `params`(类型由 `paramsSchema.parse` 在编译期保证),无参形状用
|
|
26
|
+
* `z.strictObject({})` 并忽略 `params`。
|
|
27
|
+
*
|
|
28
|
+
* - `paramsSchema`:类型约束输出 JSON-safe(`z.ZodType<TParams>`)。这是类型层约束,不是运行时唯一保证——
|
|
29
|
+
* compile 在 `paramsSchema.parse(params)` 之后还会对结果跑一次 `JsonObjectSchema.parse`,拦下宽松
|
|
30
|
+
* schema 放过的非 JSON 输出(function / undefined 等)。
|
|
23
31
|
*
|
|
24
32
|
* 坐标语义两套,第三方最易写错:
|
|
25
33
|
* - `boundaryPoint` / `anchor` 收**带 `rotate` 的 Rect**——用 re-export 的 `worldToLocal` / `localToWorld` 写局部系几何。
|
|
26
34
|
* - `emit` 收**轴对齐 Rect(rotate=0)**——旋转由编译器在外层 `GroupPrim` 统一施加。
|
|
27
35
|
*/
|
|
28
|
-
export type
|
|
36
|
+
export type ShapeDefinitionInput<TParams extends IRJsonObject> = {
|
|
37
|
+
/** params 的 zod schema;类型约束输出 JSON-safe(运行时双 parse 才是真正护栏,见编译期桥接) */
|
|
38
|
+
paramsSchema: z.ZodType<TParams>;
|
|
29
39
|
/**
|
|
30
|
-
* 外接:内容半轴(text + padding
|
|
31
|
-
* @description
|
|
40
|
+
* 外接:内容半轴(text + padding)+ params → 外接框半轴。
|
|
41
|
+
* @description 必返回**包含完整 shape 的精确 AABB 半轴**(compile 的 viewBox / scope bbox 只累积该 AABB
|
|
42
|
+
* 四角)。rectangle: identity;circle: √(hw²+hh²) 两轴相等;ellipse: ×√2;diamond: ×2;参数化形状据 params 算。
|
|
32
43
|
*/
|
|
33
|
-
circumscribe: (innerHalfWidth: number, innerHalfHeight: number) => {
|
|
44
|
+
circumscribe: (innerHalfWidth: number, innerHalfHeight: number, params: TParams) => {
|
|
34
45
|
halfWidth: number;
|
|
35
46
|
halfHeight: number;
|
|
36
47
|
};
|
|
37
|
-
/**
|
|
38
|
-
|
|
48
|
+
/**
|
|
49
|
+
* AABB 中心相对 node `position` 的偏移(可选;缺省 `[0, 0]` = AABB 中心即 position)。
|
|
50
|
+
* @description 多数 shape 的视觉 AABB 以 position 为中心(rectangle / ellipse / diamond);但 sector 等
|
|
51
|
+
* 形状的语义锚点(圆心 apex)才是 position,其外接 AABB 中心偏在一侧——此 hook 让 compile 把
|
|
52
|
+
* `rect.center` 放到 `position + offset`,使 bbox / viewBox 罩住完整形状、anchor 以 AABB 中心 rect 计算时
|
|
53
|
+
* apex 落回 position。返回**未旋转**局部偏移(compile 在施加 node rotate 前用于定位 rect 中心)。
|
|
54
|
+
*/
|
|
55
|
+
circumscribeOffset?: (params: TParams) => Position;
|
|
56
|
+
/** 中心 → toward 射线 ∩ 边界(rect 带 rotate);params 喂参数化边界。 */
|
|
57
|
+
boundaryPoint: (rect: Rect, toward: Position, params: TParams) => Position;
|
|
39
58
|
/** 命名 anchor 世界坐标;shape 不认识的名字返回 `undefined`(调用方据此抛清晰错误)。 */
|
|
40
|
-
anchor: (rect: Rect, name: string) => Position | undefined;
|
|
59
|
+
anchor: (rect: Rect, name: string, params: TParams) => Position | undefined;
|
|
41
60
|
/**
|
|
42
61
|
* 边上比例点:side 真实边界从约定起点起 t∈[0,1] 处(轴对齐空间求出后由 layout 投回世界系)。
|
|
43
62
|
* @description 可选——内置 4 shape 必实现,不实现的 shape 收到 `{ side, t }` 时编译期(resolveEdgePoint)抛明确错。
|
|
44
63
|
* 与 `anchor` 同坐标语义:收**带 rotate 的 Rect**,自行用 worldToLocal/localToWorld 处理旋转。
|
|
45
64
|
*/
|
|
46
|
-
edgePoint?: (rect: Rect, side: 'north' | 'south' | 'east' | 'west', t: number) => Position;
|
|
47
|
-
/** 视觉 primitive,**轴对齐空间**(rotate 由编译器外层 GroupPrim
|
|
48
|
-
emit: (rect: Rect, style: ShapeStyle, round: (n: number) => number) => Iterable<ScenePrimitive>;
|
|
65
|
+
edgePoint?: (rect: Rect, side: 'north' | 'south' | 'east' | 'west', t: number, params: TParams) => Position;
|
|
66
|
+
/** 视觉 primitive,**轴对齐空间**(rotate 由编译器外层 GroupPrim 统一施加);params 喂参数化几何。 */
|
|
67
|
+
emit: (rect: Rect, style: ShapeStyle, round: (n: number) => number, params: TParams) => Iterable<ScenePrimitive>;
|
|
68
|
+
/**
|
|
69
|
+
* node scale 作用于 params 的方式(可选)。
|
|
70
|
+
* @description 给定原始 params 与水平 / 垂直缩放因子 `sx` / `sy`,返回缩放后的 params。
|
|
71
|
+
* 缺省时编译器沿用默认行为——深度缩放 params 里所有数值叶子(uniform 几何均值因子)。
|
|
72
|
+
* 适用于 params 含「非长度」语义字段(如角度)的形状:sector / arc 只缩半径、不缩角度,
|
|
73
|
+
* 通过本 hook 把 startAngle / endAngle 排除在缩放外。不缩放任何 params 的形状不必实现。
|
|
74
|
+
*/
|
|
75
|
+
scaleParams?: (params: TParams, sx: number, sy: number) => TParams;
|
|
49
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* shape 定义的擦除形态:registry 存这个
|
|
79
|
+
* @description 所有函数收 `IRJsonObject`(实际类型由 `paramsSchema.parse` 在编译期保证);registry 同构
|
|
80
|
+
* `Record<string, ShapeDefinition>`、不泛型化(避免逆变 / 落 any)。定义点用 `defineShape<TParams>` 拿类型安全。
|
|
81
|
+
*/
|
|
82
|
+
export type ShapeDefinition = ShapeDefinitionInput<IRJsonObject>;
|
|
50
83
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +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,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,M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"retikz v0.1 core: framework-agnostic IR, scene compiler, and pure parsers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pionpill",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/Pionpill/retikz.git",
|
|
17
|
-
"directory": "packages/core"
|
|
17
|
+
"directory": "packages/core/core"
|
|
18
18
|
},
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/Pionpill/retikz/issues"
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,eAYpB,CAAC"}
|
package/dist/es/shapes/circle.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { circle as circle$1 } from "../geometry/circle.js";
|
|
2
|
-
import { asRectAnchor } from "./_shared.js";
|
|
3
|
-
import { ellipse } from "./ellipse.js";
|
|
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) => circle$1.boundaryPoint(toCircle(r), toward),
|
|
26
|
-
anchor: (r, name) => {
|
|
27
|
-
const a = asRectAnchor(name);
|
|
28
|
-
return a ? circle$1.anchor(toCircle(r), a) : void 0;
|
|
29
|
-
},
|
|
30
|
-
edgePoint: (r, side, t) => circle$1.edgePoint(toCircle(r), side, t),
|
|
31
|
-
emit: (r, style, round) => ellipse.emit(r, style, round)
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
|
-
export { circle };
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,eAgCrB,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { asRectAnchor } from "./_shared.js";
|
|
2
|
-
import { diamond as diamond$1 } from "../geometry/diamond.js";
|
|
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) => diamond$1.boundaryPoint(toDiamond(r), toward),
|
|
23
|
-
anchor: (r, name) => {
|
|
24
|
-
const a = asRectAnchor(name);
|
|
25
|
-
return a ? diamond$1.anchor(toDiamond(r), a) : void 0;
|
|
26
|
-
},
|
|
27
|
-
edgePoint: (r, side, t) => diamond$1.edgePoint(toDiamond(r), side, t),
|
|
28
|
-
*emit(r, style, round) {
|
|
29
|
-
const d = toDiamond(r);
|
|
30
|
-
const e = diamond$1.anchor(d, "east");
|
|
31
|
-
const n = diamond$1.anchor(d, "north");
|
|
32
|
-
const w = diamond$1.anchor(d, "west");
|
|
33
|
-
const s = diamond$1.anchor(d, "south");
|
|
34
|
-
yield {
|
|
35
|
-
type: "path",
|
|
36
|
-
commands: [
|
|
37
|
-
{
|
|
38
|
-
kind: "move",
|
|
39
|
-
to: [round(e[0]), round(e[1])]
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
kind: "line",
|
|
43
|
-
to: [round(n[0]), round(n[1])]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
kind: "line",
|
|
47
|
-
to: [round(w[0]), round(w[1])]
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
kind: "line",
|
|
51
|
-
to: [round(s[0]), round(s[1])]
|
|
52
|
-
},
|
|
53
|
-
{ kind: "close" }
|
|
54
|
-
],
|
|
55
|
-
fill: style.fill ?? "transparent",
|
|
56
|
-
fillOpacity: style.fillOpacity,
|
|
57
|
-
stroke: style.stroke ?? "currentColor",
|
|
58
|
-
strokeOpacity: style.strokeOpacity,
|
|
59
|
-
strokeWidth: style.strokeWidth ?? 1,
|
|
60
|
-
dashPattern: style.dashPattern,
|
|
61
|
-
opacity: style.opacity
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
//#endregion
|
|
66
|
-
export { diamond };
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
edgePoint: (r, side, t) => require_circle.circle.edgePoint(toCircle(r), side, t),
|
|
31
|
-
emit: (r, style, round) => require_ellipse.ellipse.emit(r, style, round)
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
|
-
exports.circle = circle;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,eAYpB,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
edgePoint: (r, side, t) => require_diamond.diamond.edgePoint(toDiamond(r), side, t),
|
|
28
|
-
*emit(r, style, round) {
|
|
29
|
-
const d = toDiamond(r);
|
|
30
|
-
const e = require_diamond.diamond.anchor(d, "east");
|
|
31
|
-
const n = require_diamond.diamond.anchor(d, "north");
|
|
32
|
-
const w = require_diamond.diamond.anchor(d, "west");
|
|
33
|
-
const s = require_diamond.diamond.anchor(d, "south");
|
|
34
|
-
yield {
|
|
35
|
-
type: "path",
|
|
36
|
-
commands: [
|
|
37
|
-
{
|
|
38
|
-
kind: "move",
|
|
39
|
-
to: [round(e[0]), round(e[1])]
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
kind: "line",
|
|
43
|
-
to: [round(n[0]), round(n[1])]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
kind: "line",
|
|
47
|
-
to: [round(w[0]), round(w[1])]
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
kind: "line",
|
|
51
|
-
to: [round(s[0]), round(s[1])]
|
|
52
|
-
},
|
|
53
|
-
{ kind: "close" }
|
|
54
|
-
],
|
|
55
|
-
fill: style.fill ?? "transparent",
|
|
56
|
-
fillOpacity: style.fillOpacity,
|
|
57
|
-
stroke: style.stroke ?? "currentColor",
|
|
58
|
-
strokeOpacity: style.strokeOpacity,
|
|
59
|
-
strokeWidth: style.strokeWidth ?? 1,
|
|
60
|
-
dashPattern: style.dashPattern,
|
|
61
|
-
opacity: style.opacity
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
//#endregion
|
|
66
|
-
exports.diamond = diamond;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,eAgCrB,CAAC"}
|