@retikz/core 0.1.0-alpha.4 → 0.1.0-beta.1

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.
Files changed (275) hide show
  1. package/dist/es/compile/compile.d.ts +23 -13
  2. package/dist/es/compile/compile.d.ts.map +1 -1
  3. package/dist/es/compile/compile.js +44 -25
  4. package/dist/es/compile/index.d.ts +1 -1
  5. package/dist/es/compile/index.d.ts.map +1 -1
  6. package/dist/es/compile/node.d.ts +40 -59
  7. package/dist/es/compile/node.d.ts.map +1 -1
  8. package/dist/es/compile/node.js +51 -43
  9. package/dist/es/compile/parseTarget.d.ts +3 -8
  10. package/dist/es/compile/parseTarget.d.ts.map +1 -1
  11. package/dist/es/compile/parseTarget.js +7 -19
  12. package/dist/es/compile/path/anchor.d.ts +19 -0
  13. package/dist/es/compile/path/anchor.d.ts.map +1 -0
  14. package/dist/es/compile/path/anchor.js +54 -0
  15. package/dist/es/compile/path/index.d.ts +24 -0
  16. package/dist/es/compile/path/index.d.ts.map +1 -0
  17. package/dist/es/compile/path/index.js +308 -0
  18. package/dist/es/compile/path/label.d.ts +18 -0
  19. package/dist/es/compile/path/label.d.ts.map +1 -0
  20. package/dist/es/compile/path/label.js +102 -0
  21. package/dist/es/compile/path/relative.d.ts +8 -0
  22. package/dist/es/compile/path/relative.d.ts.map +1 -0
  23. package/dist/es/compile/path/relative.js +48 -0
  24. package/dist/es/compile/path/shrink.d.ts +24 -0
  25. package/dist/es/compile/path/shrink.d.ts.map +1 -0
  26. package/dist/es/compile/path/shrink.js +136 -0
  27. package/dist/es/compile/path/split.d.ts +15 -0
  28. package/dist/es/compile/path/split.d.ts.map +1 -0
  29. package/dist/es/compile/path/split.js +46 -0
  30. package/dist/es/compile/position.d.ts +4 -8
  31. package/dist/es/compile/position.d.ts.map +1 -1
  32. package/dist/es/compile/position.js +10 -10
  33. package/dist/es/compile/text-metrics.d.ts +6 -5
  34. package/dist/es/compile/text-metrics.d.ts.map +1 -1
  35. package/dist/es/compile/text-metrics.js +11 -5
  36. package/dist/es/compile/view-box.d.ts +1 -4
  37. package/dist/es/compile/view-box.d.ts.map +1 -1
  38. package/dist/es/compile/view-box.js +1 -4
  39. package/dist/es/geometry/_transform.d.ts +21 -0
  40. package/dist/es/geometry/_transform.d.ts.map +1 -0
  41. package/dist/es/geometry/_transform.js +27 -0
  42. package/dist/es/geometry/arc.d.ts +3 -28
  43. package/dist/es/geometry/arc.d.ts.map +1 -1
  44. package/dist/es/geometry/arc.js +4 -31
  45. package/dist/es/geometry/bend.d.ts +2 -13
  46. package/dist/es/geometry/bend.d.ts.map +1 -1
  47. package/dist/es/geometry/bend.js +2 -13
  48. package/dist/es/geometry/circle.d.ts +6 -15
  49. package/dist/es/geometry/circle.d.ts.map +1 -1
  50. package/dist/es/geometry/circle.js +2 -20
  51. package/dist/es/geometry/diamond.d.ts +10 -26
  52. package/dist/es/geometry/diamond.d.ts.map +1 -1
  53. package/dist/es/geometry/diamond.js +5 -30
  54. package/dist/es/geometry/ellipse.d.ts +10 -17
  55. package/dist/es/geometry/ellipse.d.ts.map +1 -1
  56. package/dist/es/geometry/ellipse.js +5 -24
  57. package/dist/es/geometry/point.d.ts +8 -9
  58. package/dist/es/geometry/point.d.ts.map +1 -1
  59. package/dist/es/geometry/point.js +8 -9
  60. package/dist/es/geometry/polar.d.ts +12 -21
  61. package/dist/es/geometry/polar.d.ts.map +1 -1
  62. package/dist/es/geometry/polar.js +8 -19
  63. package/dist/es/geometry/rect.d.ts +8 -32
  64. package/dist/es/geometry/rect.d.ts.map +1 -1
  65. package/dist/es/geometry/rect.js +6 -49
  66. package/dist/es/geometry/segment.d.ts +15 -18
  67. package/dist/es/geometry/segment.d.ts.map +1 -1
  68. package/dist/es/geometry/segment.js +9 -16
  69. package/dist/es/index.d.ts +13 -13
  70. package/dist/es/index.d.ts.map +1 -1
  71. package/dist/es/index.js +7 -4
  72. package/dist/es/ir/coordinate.d.ts +18 -10
  73. package/dist/es/ir/coordinate.d.ts.map +1 -1
  74. package/dist/es/ir/coordinate.js +6 -11
  75. package/dist/es/ir/font.d.ts +21 -0
  76. package/dist/es/ir/font.d.ts.map +1 -0
  77. package/dist/es/ir/font.js +15 -0
  78. package/dist/es/ir/index.d.ts +2 -0
  79. package/dist/es/ir/index.d.ts.map +1 -1
  80. package/dist/es/ir/node.d.ts +51 -181
  81. package/dist/es/ir/node.d.ts.map +1 -1
  82. package/dist/es/ir/node.js +15 -70
  83. package/dist/es/ir/path/arrow.d.ts +210 -12
  84. package/dist/es/ir/path/arrow.d.ts.map +1 -1
  85. package/dist/es/ir/path/arrow.js +39 -12
  86. package/dist/es/ir/path/path.d.ts +477 -153
  87. package/dist/es/ir/path/path.d.ts.map +1 -1
  88. package/dist/es/ir/path/path.js +6 -6
  89. package/dist/es/ir/path/step.d.ts +395 -223
  90. package/dist/es/ir/path/step.d.ts.map +1 -1
  91. package/dist/es/ir/path/step.js +21 -22
  92. package/dist/es/ir/path/target.d.ts +25 -16
  93. package/dist/es/ir/path/target.d.ts.map +1 -1
  94. package/dist/es/ir/path/target.js +8 -6
  95. package/dist/es/ir/position/at-position.d.ts +4 -11
  96. package/dist/es/ir/position/at-position.d.ts.map +1 -1
  97. package/dist/es/ir/position/at-position.js +2 -9
  98. package/dist/es/ir/position/index.d.ts +1 -0
  99. package/dist/es/ir/position/index.d.ts.map +1 -1
  100. package/dist/es/ir/position/offset-position.d.ts +14 -0
  101. package/dist/es/ir/position/offset-position.d.ts.map +1 -0
  102. package/dist/es/ir/position/offset-position.js +14 -0
  103. package/dist/es/ir/position/polar-position.d.ts +1 -4
  104. package/dist/es/ir/position/polar-position.d.ts.map +1 -1
  105. package/dist/es/ir/position/polar-position.js +3 -6
  106. package/dist/es/ir/position/position.d.ts.map +1 -1
  107. package/dist/es/ir/position/position.js +1 -1
  108. package/dist/es/ir/scene.d.ts +1236 -422
  109. package/dist/es/ir/scene.d.ts.map +1 -1
  110. package/dist/es/ir/text.d.ts +96 -0
  111. package/dist/es/ir/text.d.ts.map +1 -0
  112. package/dist/es/ir/text.js +20 -0
  113. package/dist/es/parsers/parseTargetSugar.d.ts +4 -0
  114. package/dist/es/parsers/parseTargetSugar.d.ts.map +1 -1
  115. package/dist/es/parsers/parseTargetSugar.js +7 -19
  116. package/dist/es/parsers/parseWay.d.ts +26 -118
  117. package/dist/es/parsers/parseWay.d.ts.map +1 -1
  118. package/dist/es/parsers/parseWay.js +19 -61
  119. package/dist/es/primitive/ellipse.d.ts +4 -14
  120. package/dist/es/primitive/ellipse.d.ts.map +1 -1
  121. package/dist/es/primitive/group.d.ts +37 -3
  122. package/dist/es/primitive/group.d.ts.map +1 -1
  123. package/dist/es/primitive/path.d.ts +107 -7
  124. package/dist/es/primitive/path.d.ts.map +1 -1
  125. package/dist/es/primitive/rect.d.ts +2 -2
  126. package/dist/es/primitive/rect.d.ts.map +1 -1
  127. package/dist/es/primitive/scene.d.ts +2 -4
  128. package/dist/es/primitive/scene.d.ts.map +1 -1
  129. package/dist/es/primitive/text.d.ts +16 -32
  130. package/dist/es/primitive/text.d.ts.map +1 -1
  131. package/dist/es/primitive/view-box.d.ts +1 -1
  132. package/dist/es/primitive/view-box.d.ts.map +1 -1
  133. package/dist/es/types.d.ts +8 -0
  134. package/dist/es/types.d.ts.map +1 -1
  135. package/dist/lib/compile/compile.cjs +44 -25
  136. package/dist/lib/compile/compile.d.ts +23 -13
  137. package/dist/lib/compile/compile.d.ts.map +1 -1
  138. package/dist/lib/compile/index.d.ts +1 -1
  139. package/dist/lib/compile/index.d.ts.map +1 -1
  140. package/dist/lib/compile/node.cjs +51 -43
  141. package/dist/lib/compile/node.d.ts +40 -59
  142. package/dist/lib/compile/node.d.ts.map +1 -1
  143. package/dist/lib/compile/parseTarget.cjs +7 -19
  144. package/dist/lib/compile/parseTarget.d.ts +3 -8
  145. package/dist/lib/compile/parseTarget.d.ts.map +1 -1
  146. package/dist/lib/compile/path/anchor.cjs +58 -0
  147. package/dist/lib/compile/path/anchor.d.ts +19 -0
  148. package/dist/lib/compile/path/anchor.d.ts.map +1 -0
  149. package/dist/lib/compile/path/index.cjs +308 -0
  150. package/dist/lib/compile/path/index.d.ts +24 -0
  151. package/dist/lib/compile/path/index.d.ts.map +1 -0
  152. package/dist/lib/compile/path/label.cjs +103 -0
  153. package/dist/lib/compile/path/label.d.ts +18 -0
  154. package/dist/lib/compile/path/label.d.ts.map +1 -0
  155. package/dist/lib/compile/path/relative.cjs +48 -0
  156. package/dist/lib/compile/path/relative.d.ts +8 -0
  157. package/dist/lib/compile/path/relative.d.ts.map +1 -0
  158. package/dist/lib/compile/path/shrink.cjs +138 -0
  159. package/dist/lib/compile/path/shrink.d.ts +24 -0
  160. package/dist/lib/compile/path/shrink.d.ts.map +1 -0
  161. package/dist/lib/compile/path/split.cjs +46 -0
  162. package/dist/lib/compile/path/split.d.ts +15 -0
  163. package/dist/lib/compile/path/split.d.ts.map +1 -0
  164. package/dist/lib/compile/position.cjs +10 -10
  165. package/dist/lib/compile/position.d.ts +4 -8
  166. package/dist/lib/compile/position.d.ts.map +1 -1
  167. package/dist/lib/compile/text-metrics.cjs +11 -5
  168. package/dist/lib/compile/text-metrics.d.ts +6 -5
  169. package/dist/lib/compile/text-metrics.d.ts.map +1 -1
  170. package/dist/lib/compile/view-box.cjs +1 -4
  171. package/dist/lib/compile/view-box.d.ts +1 -4
  172. package/dist/lib/compile/view-box.d.ts.map +1 -1
  173. package/dist/lib/geometry/_transform.cjs +28 -0
  174. package/dist/lib/geometry/_transform.d.ts +21 -0
  175. package/dist/lib/geometry/_transform.d.ts.map +1 -0
  176. package/dist/lib/geometry/arc.cjs +3 -31
  177. package/dist/lib/geometry/arc.d.ts +3 -28
  178. package/dist/lib/geometry/arc.d.ts.map +1 -1
  179. package/dist/lib/geometry/bend.cjs +2 -13
  180. package/dist/lib/geometry/bend.d.ts +2 -13
  181. package/dist/lib/geometry/bend.d.ts.map +1 -1
  182. package/dist/lib/geometry/circle.cjs +6 -24
  183. package/dist/lib/geometry/circle.d.ts +6 -15
  184. package/dist/lib/geometry/circle.d.ts.map +1 -1
  185. package/dist/lib/geometry/diamond.cjs +9 -34
  186. package/dist/lib/geometry/diamond.d.ts +10 -26
  187. package/dist/lib/geometry/diamond.d.ts.map +1 -1
  188. package/dist/lib/geometry/ellipse.cjs +9 -28
  189. package/dist/lib/geometry/ellipse.d.ts +10 -17
  190. package/dist/lib/geometry/ellipse.d.ts.map +1 -1
  191. package/dist/lib/geometry/point.cjs +8 -9
  192. package/dist/lib/geometry/point.d.ts +8 -9
  193. package/dist/lib/geometry/point.d.ts.map +1 -1
  194. package/dist/lib/geometry/polar.cjs +8 -19
  195. package/dist/lib/geometry/polar.d.ts +12 -21
  196. package/dist/lib/geometry/polar.d.ts.map +1 -1
  197. package/dist/lib/geometry/rect.cjs +10 -53
  198. package/dist/lib/geometry/rect.d.ts +8 -32
  199. package/dist/lib/geometry/rect.d.ts.map +1 -1
  200. package/dist/lib/geometry/segment.cjs +9 -16
  201. package/dist/lib/geometry/segment.d.ts +15 -18
  202. package/dist/lib/geometry/segment.d.ts.map +1 -1
  203. package/dist/lib/index.cjs +14 -5
  204. package/dist/lib/index.d.ts +13 -13
  205. package/dist/lib/index.d.ts.map +1 -1
  206. package/dist/lib/ir/coordinate.cjs +6 -11
  207. package/dist/lib/ir/coordinate.d.ts +18 -10
  208. package/dist/lib/ir/coordinate.d.ts.map +1 -1
  209. package/dist/lib/ir/font.cjs +15 -0
  210. package/dist/lib/ir/font.d.ts +21 -0
  211. package/dist/lib/ir/font.d.ts.map +1 -0
  212. package/dist/lib/ir/index.d.ts +2 -0
  213. package/dist/lib/ir/index.d.ts.map +1 -1
  214. package/dist/lib/ir/node.cjs +16 -74
  215. package/dist/lib/ir/node.d.ts +51 -181
  216. package/dist/lib/ir/node.d.ts.map +1 -1
  217. package/dist/lib/ir/path/arrow.cjs +43 -11
  218. package/dist/lib/ir/path/arrow.d.ts +210 -12
  219. package/dist/lib/ir/path/arrow.d.ts.map +1 -1
  220. package/dist/lib/ir/path/path.cjs +5 -5
  221. package/dist/lib/ir/path/path.d.ts +477 -153
  222. package/dist/lib/ir/path/path.d.ts.map +1 -1
  223. package/dist/lib/ir/path/step.cjs +21 -22
  224. package/dist/lib/ir/path/step.d.ts +395 -223
  225. package/dist/lib/ir/path/step.d.ts.map +1 -1
  226. package/dist/lib/ir/path/target.cjs +9 -7
  227. package/dist/lib/ir/path/target.d.ts +25 -16
  228. package/dist/lib/ir/path/target.d.ts.map +1 -1
  229. package/dist/lib/ir/position/at-position.cjs +2 -9
  230. package/dist/lib/ir/position/at-position.d.ts +4 -11
  231. package/dist/lib/ir/position/at-position.d.ts.map +1 -1
  232. package/dist/lib/ir/position/index.d.ts +1 -0
  233. package/dist/lib/ir/position/index.d.ts.map +1 -1
  234. package/dist/lib/ir/position/offset-position.cjs +14 -0
  235. package/dist/lib/ir/position/offset-position.d.ts +14 -0
  236. package/dist/lib/ir/position/offset-position.d.ts.map +1 -0
  237. package/dist/lib/ir/position/polar-position.cjs +3 -6
  238. package/dist/lib/ir/position/polar-position.d.ts +1 -4
  239. package/dist/lib/ir/position/polar-position.d.ts.map +1 -1
  240. package/dist/lib/ir/position/position.cjs +1 -1
  241. package/dist/lib/ir/position/position.d.ts.map +1 -1
  242. package/dist/lib/ir/scene.d.ts +1236 -422
  243. package/dist/lib/ir/scene.d.ts.map +1 -1
  244. package/dist/lib/ir/text.cjs +21 -0
  245. package/dist/lib/ir/text.d.ts +96 -0
  246. package/dist/lib/ir/text.d.ts.map +1 -0
  247. package/dist/lib/parsers/parseTargetSugar.cjs +7 -19
  248. package/dist/lib/parsers/parseTargetSugar.d.ts +4 -0
  249. package/dist/lib/parsers/parseTargetSugar.d.ts.map +1 -1
  250. package/dist/lib/parsers/parseWay.cjs +19 -61
  251. package/dist/lib/parsers/parseWay.d.ts +26 -118
  252. package/dist/lib/parsers/parseWay.d.ts.map +1 -1
  253. package/dist/lib/primitive/ellipse.d.ts +4 -14
  254. package/dist/lib/primitive/ellipse.d.ts.map +1 -1
  255. package/dist/lib/primitive/group.d.ts +37 -3
  256. package/dist/lib/primitive/group.d.ts.map +1 -1
  257. package/dist/lib/primitive/path.d.ts +107 -7
  258. package/dist/lib/primitive/path.d.ts.map +1 -1
  259. package/dist/lib/primitive/rect.d.ts +2 -2
  260. package/dist/lib/primitive/rect.d.ts.map +1 -1
  261. package/dist/lib/primitive/scene.d.ts +2 -4
  262. package/dist/lib/primitive/scene.d.ts.map +1 -1
  263. package/dist/lib/primitive/text.d.ts +16 -32
  264. package/dist/lib/primitive/text.d.ts.map +1 -1
  265. package/dist/lib/primitive/view-box.d.ts +1 -1
  266. package/dist/lib/primitive/view-box.d.ts.map +1 -1
  267. package/dist/lib/types.d.ts +8 -0
  268. package/dist/lib/types.d.ts.map +1 -1
  269. package/package.json +13 -4
  270. package/dist/es/compile/path.d.ts +0 -30
  271. package/dist/es/compile/path.d.ts.map +0 -1
  272. package/dist/es/compile/path.js +0 -617
  273. package/dist/lib/compile/path.cjs +0 -617
  274. package/dist/lib/compile/path.d.ts +0 -30
  275. package/dist/lib/compile/path.d.ts.map +0 -1
@@ -1,43 +1,27 @@
1
1
  import { Position } from './point';
2
- /**
3
- * 菱形:几何中心 (x, y) + 半轴长 halfA(水平)/ halfB(垂直)+ 可选旋转。
4
- * 4 个顶点位于 (±halfA, 0) 与 (0, ±halfB),4 条边界线把这些顶点两两相连。
5
- */
2
+ import { RectAnchor } from './rect';
3
+ /** 菱形:中心 + halfA/halfB 半轴长 + 可选旋转;顶点在 halfA,0) 与 (0,±halfB) */
6
4
  export type Diamond = {
7
- /** 中心横坐标 */
8
5
  x: number;
9
- /** 中心纵坐标 */
10
6
  y: number;
11
- /** 水平半轴长(中心到 east/west 顶点的距离) */
7
+ /** 中心到 east/west 顶点距离 */
12
8
  halfA: number;
13
- /** 垂直半轴长(中心到 north/south 顶点的距离) */
9
+ /** 中心到 north/south 顶点距离 */
14
10
  halfB: number;
15
- /** 绕几何中心旋转弧度;省略或 0 表示不旋转 */
11
+ /** 绕中心旋转弧度 */
16
12
  rotate?: number;
17
13
  };
18
- /** 菱形 9 个标准 anchor 名(4 顶点 + 4 边中点 + 中心) */
19
- export type DiamondAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
20
14
  /** 菱形相关基础工具 */
21
15
  export declare const diamond: {
22
16
  /** 中心 */
23
17
  center: (d: Diamond) => Position;
24
- /**
25
- * 判断点是否在菱形内(含边界,考虑旋转)。
26
- * 菱形方程:|x|/halfA + |y|/halfB ≤ 1。
27
- */
18
+ /** 点是否在菱形内(含边界,含旋转);方程 |x|/halfA + |y|/halfB ≤ 1 */
28
19
  contains: (d: Diamond, p: Position) => boolean;
20
+ /** 9 个 anchor:N/S/E/W=顶点,NE/NW/SE/SW=边中点,center=中心 */
21
+ anchor: (d: Diamond, name: RectAnchor) => Position;
29
22
  /**
30
- * 9 个标准 anchor 的世界坐标。
31
- * - N/S/E/W:四个顶点
32
- * - NE/NW/SE/SW:四条边的中点
33
- * - center:几何中心
34
- */
35
- anchor: (d: Diamond, name: DiamondAnchor) => Position;
36
- /**
37
- * 从中心向 toward 方向画射线,求与菱形 4 条边之一的交点。
38
- * 菱形方程:|x|/halfA + |y|/halfB = 1。
39
- * 沿方向 (lx, ly) 缩放 t 倍命中:t × (|lx|/halfA + |ly|/halfB) = 1
40
- * → t = 1 / (|lx|/halfA + |ly|/halfB)。
23
+ * 从中心向 toward 方向射线与菱形 4 边的交点
24
+ * @description 菱形方程 |x|/halfA + |y|/halfB = 1;沿方向 (lx,ly) 缩放 t 倍命中:t = 1 / (|lx|/halfA + |ly|/halfB)
41
25
  */
42
26
  boundaryPoint: (d: Diamond, toward: Position) => Position;
43
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"diamond.d.ts","sourceRoot":"","sources":["../../../src/geometry/diamond.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAoBjB,eAAe;AACf,eAAO,MAAM,OAAO;IAClB,SAAS;gBACG,OAAO,KAAG,QAAQ;IAC9B;;;OAGG;kBACW,OAAO,KAAK,QAAQ,KAAG,OAAO;IAI5C;;;;;OAKG;gBACS,OAAO,QAAQ,aAAa,KAAG,QAAQ;IAqCnD;;;;;OAKG;uBACgB,OAAO,UAAU,QAAQ,KAAG,QAAQ;CAOxD,CAAC"}
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,35 +1,18 @@
1
+ const require__transform = require("./_transform.cjs");
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
  /** 中心 */
22
7
  center: (e) => [e.x, e.y],
23
8
  /** 判断点是否在椭圆内(含边界,考虑旋转) */
24
9
  contains: (e, p) => {
25
- const [lx, ly] = worldToLocal(e, p);
10
+ const [lx, ly] = require__transform.worldToLocal(e, p);
26
11
  return lx * lx / (e.rx * e.rx) + ly * ly / (e.ry * e.ry) <= 1;
27
12
  },
28
13
  /**
29
- * 9 个标准 anchor 的世界坐标。
30
- * 对角 anchor(NE/NW/SE/SW)取参数曲线 t=π/4 处的点:
31
- * (rx·cos(π/4), ry·sin(π/4)) = (rx/√2, ry/√2)。
32
- * 这与 TikZ 椭圆对角 anchor 的"参数等分"约定一致。
14
+ * 9 anchor 的世界坐标
15
+ * @description 对角(NE/NW/SE/SW)取参数曲线 t=π/4 处 (rx/√2, ry/√2),与 TikZ 椭圆 anchor 参数等分约定一致
33
16
  */
34
17
  anchor: (e, name) => {
35
18
  let lx = 0;
@@ -65,21 +48,19 @@ var ellipse = {
65
48
  ly = e.ry * SQRT_HALF;
66
49
  break;
67
50
  }
68
- return localToWorld(e, [lx, ly]);
51
+ return require__transform.localToWorld(e, [lx, ly]);
69
52
  },
70
53
  /**
71
- * 从中心向 toward 方向画射线,求与椭圆的交点。
72
- * 椭圆方程:(x/rx)² + (y/ry)² = 1
73
- * 沿方向 (lx, ly) 缩放 t 倍命中:t² × ((lx/rx)² + (ly/ry)²) = 1
74
- * → t = 1 / √((lx/rx)² + (ly/ry)²)。
54
+ * 从中心向 toward 方向射线与椭圆交点
55
+ * @description 椭圆方程 (x/rx)² + (y/ry)² = 1;沿 (lx,ly) 缩放 t 倍命中 t = 1 / √((lx/rx)² + (ly/ry)²)
75
56
  */
76
57
  boundaryPoint: (e, toward) => {
77
- const [lx, ly] = worldToLocal(e, toward);
58
+ const [lx, ly] = require__transform.worldToLocal(e, toward);
78
59
  if (lx === 0 && ly === 0) return [e.x, e.y];
79
60
  const a = lx / e.rx;
80
61
  const b = ly / e.ry;
81
62
  const t = 1 / Math.sqrt(a * a + b * b);
82
- return localToWorld(e, [lx * t, ly * t]);
63
+ return require__transform.localToWorld(e, [lx * t, ly * t]);
83
64
  }
84
65
  };
85
66
  //#endregion
@@ -1,19 +1,16 @@
1
1
  import { Position } from './point';
2
- /** 椭圆:几何中心 (x, y) + 半长轴 rx / 半短轴 ry + 可选旋转(弧度) */
2
+ import { RectAnchor } from './rect';
3
+ /** 椭圆:中心 + 半长轴 rx / 半短轴 ry + 可选旋转 */
3
4
  export type Ellipse = {
4
- /** 中心横坐标 */
5
5
  x: number;
6
- /** 中心纵坐标 */
7
6
  y: number;
8
- /** 半长轴(沿本地 +x 方向) */
7
+ /** 沿本地 +x */
9
8
  rx: number;
10
- /** 半短轴(沿本地 +y 方向) */
9
+ /** 沿本地 +y */
11
10
  ry: number;
12
- /** 绕几何中心旋转弧度;省略或 0 表示不旋转 */
11
+ /** 绕中心旋转弧度 */
13
12
  rotate?: number;
14
13
  };
15
- /** 椭圆 9 个标准 anchor 名(含义与 RECT_ANCHORS 一致) */
16
- export type EllipseAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
17
14
  /** 椭圆相关基础工具 */
18
15
  export declare const ellipse: {
19
16
  /** 中心 */
@@ -21,17 +18,13 @@ export declare const ellipse: {
21
18
  /** 判断点是否在椭圆内(含边界,考虑旋转) */
22
19
  contains: (e: Ellipse, p: Position) => boolean;
23
20
  /**
24
- * 9 个标准 anchor 的世界坐标。
25
- * 对角 anchor(NE/NW/SE/SW)取参数曲线 t=π/4 处的点:
26
- * (rx·cos(π/4), ry·sin(π/4)) = (rx/√2, ry/√2)。
27
- * 这与 TikZ 椭圆对角 anchor 的"参数等分"约定一致。
21
+ * 9 anchor 的世界坐标
22
+ * @description 对角(NE/NW/SE/SW)取参数曲线 t=π/4 处 (rx/√2, ry/√2),与 TikZ 椭圆 anchor 参数等分约定一致
28
23
  */
29
- anchor: (e: Ellipse, name: EllipseAnchor) => Position;
24
+ anchor: (e: Ellipse, name: RectAnchor) => Position;
30
25
  /**
31
- * 从中心向 toward 方向画射线,求与椭圆的交点。
32
- * 椭圆方程:(x/rx)² + (y/ry)² = 1
33
- * 沿方向 (lx, ly) 缩放 t 倍命中:t² × ((lx/rx)² + (ly/ry)²) = 1
34
- * → t = 1 / √((lx/rx)² + (ly/ry)²)。
26
+ * 从中心向 toward 方向射线与椭圆交点
27
+ * @description 椭圆方程 (x/rx)² + (y/ry)² = 1;沿 (lx,ly) 缩放 t 倍命中 t = 1 / √((lx/rx)² + (ly/ry)²)
35
28
  */
36
29
  boundaryPoint: (e: Ellipse, toward: Position) => Position;
37
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/geometry/ellipse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,kDAAkD;AAClD,MAAM,MAAM,OAAO,GAAG;IACpB,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAoBjB,eAAe;AACf,eAAO,MAAM,OAAO;IAClB,SAAS;gBACG,OAAO,KAAG,QAAQ;IAC9B,0BAA0B;kBACZ,OAAO,KAAK,QAAQ,KAAG,OAAO;IAI5C;;;;;OAKG;gBACS,OAAO,QAAQ,aAAa,KAAG,QAAQ;IAqCnD;;;;;OAKG;uBACgB,OAAO,UAAU,QAAQ,KAAG,QAAQ;CAQxD,CAAC"}
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"}
@@ -3,25 +3,24 @@ const require_polar = require("./polar.cjs");
3
3
  var RAD_TO_DEG = 180 / Math.PI;
4
4
  /** 二维向量 / 坐标的基础运算工具集 */
5
5
  var point = {
6
- /** 两点相加(向量加法):a + b */
6
+ /** 向量加 a + b */
7
7
  add: (a, b) => [a[0] + b[0], a[1] + b[1]],
8
- /** 两点相减(向量减法):a - b */
8
+ /** 向量减 a - b */
9
9
  sub: (a, b) => [a[0] - b[0], a[1] - b[1]],
10
- /** 等比缩放:a * k */
10
+ /** 等比缩放 a * k */
11
11
  scale: (a, k) => [a[0] * k, a[1] * k],
12
- /** 判断两点坐标是否完全相等(精确比较,不带容差) */
12
+ /** 两点精确相等(不带容差) */
13
13
  equal: (a, b) => a[0] === b[0] && a[1] === b[1],
14
- /** 笛卡尔点 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
14
+ /** 笛卡尔 → 极坐标(angle (-180,180],origin 默认 [0,0]) */
15
15
  toPolar: (p) => ({
16
16
  angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
17
17
  radius: Math.hypot(p[0], p[1])
18
18
  }),
19
19
  /**
20
- * 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition
21
- * 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
22
- * `polar.equal` 委托到本方法。
20
+ * 跨坐标系两点相同判断(笛卡尔或 PolarPosition
21
+ * @description 极坐标先转笛卡尔再按 precision 四舍五入比较;polar.equal 委托到本方法
23
22
  * @param precision 小数点后位数;默认 2
24
- * @throws 当 PolarPositionorigin 是节点 id 字符串时——字符串解析需 Scene 上下文
23
+ * @throws 当 PolarPosition.origin 是节点 id 字符串时(需 Scene 上下文)
25
24
  */
26
25
  equalPolar: (a, b, precision = 2) => {
27
26
  const aCart = Array.isArray(a) ? a : require_polar.polar.toPosition(a);
@@ -3,22 +3,21 @@ import { PolarPosition } from './polar';
3
3
  export type Position = [number, number];
4
4
  /** 二维向量 / 坐标的基础运算工具集 */
5
5
  export declare const point: {
6
- /** 两点相加(向量加法):a + b */
6
+ /** 向量加 a + b */
7
7
  add: (a: Position, b: Position) => Position;
8
- /** 两点相减(向量减法):a - b */
8
+ /** 向量减 a - b */
9
9
  sub: (a: Position, b: Position) => Position;
10
- /** 等比缩放:a * k */
10
+ /** 等比缩放 a * k */
11
11
  scale: (a: Position, k: number) => Position;
12
- /** 判断两点坐标是否完全相等(精确比较,不带容差) */
12
+ /** 两点精确相等(不带容差) */
13
13
  equal: (a: Position, b: Position) => boolean;
14
- /** 笛卡尔点 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
14
+ /** 笛卡尔 → 极坐标(angle (-180,180],origin 默认 [0,0]) */
15
15
  toPolar: (p: Position) => PolarPosition;
16
16
  /**
17
- * 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition
18
- * 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
19
- * `polar.equal` 委托到本方法。
17
+ * 跨坐标系两点相同判断(笛卡尔或 PolarPosition
18
+ * @description 极坐标先转笛卡尔再按 precision 四舍五入比较;polar.equal 委托到本方法
20
19
  * @param precision 小数点后位数;默认 2
21
- * @throws 当 PolarPositionorigin 是节点 id 字符串时——字符串解析需 Scene 上下文
20
+ * @throws 当 PolarPosition.origin 是节点 id 字符串时(需 Scene 上下文)
22
21
  */
23
22
  equalPolar: (a: Position | PolarPosition, b: Position | PolarPosition, precision?: number) => boolean;
24
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAS,MAAM,SAAS,CAAC;AAEpD,oBAAoB;AACpB,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAIxC,wBAAwB;AACxB,eAAO,MAAM,KAAK;IAChB,uBAAuB;aACd,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,uBAAuB;aACd,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,iBAAiB;eACN,QAAQ,KAAK,MAAM,KAAG,QAAQ;IACzC,8BAA8B;eACnB,QAAQ,KAAK,QAAQ,KAAG,OAAO;IAC1C,yDAAyD;iBAC5C,QAAQ,KAAG,aAAa;IAIrC;;;;;;OAMG;oBAEE,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CASX,CAAC"}
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAS,MAAM,SAAS,CAAC;AAEpD,oBAAoB;AACpB,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAIxC,wBAAwB;AACxB,eAAO,MAAM,KAAK;IAChB,gBAAgB;aACP,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,gBAAgB;aACP,QAAQ,KAAK,QAAQ,KAAG,QAAQ;IACzC,iBAAiB;eACN,QAAQ,KAAK,MAAM,KAAG,QAAQ;IACzC,mBAAmB;eACR,QAAQ,KAAK,QAAQ,KAAG,OAAO;IAC1C,oDAAoD;iBACvC,QAAQ,KAAG,aAAa;IAIrC;;;;;OAKG;oBAEE,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CASX,CAAC"}
@@ -1,18 +1,11 @@
1
1
  const require_point = require("./point.cjs");
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
- /**
6
- * 极坐标 ↔ 笛卡尔坐标 转换工具集。
7
- *
8
- * 注意 polar 不参与几何计算——参与计算时一律先用 `polar.toPosition` 转成 Position。
9
- * 详见本文件顶部的整体说明。
10
- */
4
+ /** 极坐标 笛卡尔转换工具集(polar 不参与几何计算,参与时先 toPosition) */
11
5
  var polar = {
12
6
  /**
13
- * 极坐标 → 笛卡尔位置(递归处理 origin)。
14
- * **限制**:origin 为字符串(节点 id)时本方法无法解析,会抛错——
15
- * 字符串解析依赖 Scene 编译器的 nodeIndex 上下文。
7
+ * 极坐标 → 笛卡尔位置(递归处理 origin
8
+ * @description origin 为字符串(节点 id)时抛错——字符串解析依赖 Scene 编译器 nodeIndex
16
9
  */
17
10
  toPosition: (p) => {
18
11
  let origin;
@@ -23,20 +16,16 @@ var polar = {
23
16
  const rad = p.angle * DEG_TO_RAD;
24
17
  return [origin[0] + Math.cos(rad) * p.radius, origin[1] + Math.sin(rad) * p.radius];
25
18
  },
26
- /** 笛卡尔位置 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
27
- fromPosition: (p) => ({
28
- angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
29
- radius: Math.hypot(p[0], p[1])
30
- }),
31
- /** 在某个原点附近按极坐标偏移;返回结果点的世界笛卡尔坐标 */
19
+ /** 笛卡尔 → 极坐标(point.toPolar 别名,angle (-180,180],origin 默认 [0,0]) */
20
+ fromPosition: (p) => require_point.point.toPolar(p),
21
+ /** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
32
22
  offsetFrom: (origin, offset) => {
33
23
  const rad = offset.angle * DEG_TO_RAD;
34
24
  return [origin[0] + Math.cos(rad) * offset.radius, origin[1] + Math.sin(rad) * offset.radius];
35
25
  },
36
26
  /**
37
- * 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition;
38
- * 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
39
- * 实际是 `point.equalPolar` 的别名(同一份实现,两处可发现)。
27
+ * 跨坐标系两点相同判断(point.equalPolar 别名)
28
+ * @description 极坐标先转笛卡尔再按 precision 四舍五入比较
40
29
  * @param precision 小数点后位数;默认 2
41
30
  */
42
31
  equal: (a, b, precision = 2) => require_point.point.equalPolar(a, b, precision)
@@ -1,42 +1,33 @@
1
1
  import { Position } from './point';
2
2
  /**
3
- * 极坐标点:相对 origin 的角度 + 半径偏移。
4
- * - 可进 IR;Scene 编译时统一解析为笛卡尔
5
- * - 不直接参与几何计算,参与时先转为 Position(见本文件顶部说明)
6
- * - origin 可嵌套(PolarPosition),可引用节点 id(string),可直接给坐标(Position),省略表示原点 [0, 0]
3
+ * 极坐标点:相对 origin 的角度 + 半径偏移
4
+ * @description IR 保留 polar 形态,Scene 编译时统一解析为笛卡尔;origin 可嵌套/节点 id/坐标,省略表示 [0,0]
7
5
  */
8
6
  export type PolarPosition = {
9
- /** 极坐标原点:节点 id / 笛卡尔位置 / 嵌套极坐标;省略表示 [0, 0] */
7
+ /** 极坐标原点:节点 id / 笛卡尔 / 嵌套极坐标;省略表示 [0,0] */
10
8
  origin?: string | Position | PolarPosition;
11
- /** 角度(度数,逆时针为正,与 TikZ / 数学习惯一致) */
9
+ /** 角度(度数):从 +x 轴量起,90° 朝 +y(屏幕下方),与 ArcStep / Node label 角度约定一致 */
12
10
  angle: number;
13
- /** 半径(user units,应为非负) */
11
+ /** 半径(非负) */
14
12
  radius: number;
15
13
  };
16
- /**
17
- * 极坐标 ↔ 笛卡尔坐标 转换工具集。
18
- *
19
- * 注意 polar 不参与几何计算——参与计算时一律先用 `polar.toPosition` 转成 Position。
20
- * 详见本文件顶部的整体说明。
21
- */
14
+ /** 极坐标 ↔ 笛卡尔转换工具集(polar 不参与几何计算,参与时先 toPosition) */
22
15
  export declare const polar: {
23
16
  /**
24
- * 极坐标 → 笛卡尔位置(递归处理 origin)。
25
- * **限制**:origin 为字符串(节点 id)时本方法无法解析,会抛错——
26
- * 字符串解析依赖 Scene 编译器的 nodeIndex 上下文。
17
+ * 极坐标 → 笛卡尔位置(递归处理 origin
18
+ * @description origin 为字符串(节点 id)时抛错——字符串解析依赖 Scene 编译器 nodeIndex
27
19
  */
28
20
  toPosition: (p: PolarPosition) => Position;
29
- /** 笛卡尔位置 → 极坐标(angle 落在 (-180, 180],origin 取默认 [0, 0]) */
21
+ /** 笛卡尔 → 极坐标(point.toPolar 别名,angle (-180,180],origin 默认 [0,0]) */
30
22
  fromPosition: (p: Position) => PolarPosition;
31
- /** 在某个原点附近按极坐标偏移;返回结果点的世界笛卡尔坐标 */
23
+ /** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
32
24
  offsetFrom: (origin: Position, offset: {
33
25
  angle: number;
34
26
  radius: number;
35
27
  }) => Position;
36
28
  /**
37
- * 判断两个点是否相同(跨坐标系)。每个参数可以是笛卡尔 [x, y] 或 PolarPosition;
38
- * 极坐标先转为笛卡尔,再按 precision 指定的小数位数四舍五入比较。
39
- * 实际是 `point.equalPolar` 的别名(同一份实现,两处可发现)。
29
+ * 跨坐标系两点相同判断(point.equalPolar 别名)
30
+ * @description 极坐标先转笛卡尔再按 precision 四舍五入比较
40
31
  * @param precision 小数点后位数;默认 2
41
32
  */
42
33
  equal: (a: Position | PolarPosition, b: Position | PolarPosition, precision?: number) => boolean;
@@ -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;AAkB/C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC3C,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;OAIG;oBACa,aAAa,KAAG,QAAQ;IAmBxC,0DAA0D;sBACxC,QAAQ,KAAG,aAAa;IAI1C,kCAAkC;yBAExB,QAAQ,UACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KACxC,QAAQ;IAOX;;;;;OAKG;eAEE,QAAQ,GAAG,aAAa,KACxB,QAAQ,GAAG,aAAa,yBAE1B,OAAO;CACX,CAAC"}
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,68 +1,28 @@
1
+ const require__transform = require("./_transform.cjs");
1
2
  //#region src/geometry/rect.ts
2
- /**
3
- * 矩形 9 个标准 anchor 名常量集合,对应 TikZ 节点的 9 个标准 anchor。
4
- * 与 `RectAnchor` 类型配对使用——值用 `RECT_ANCHORS.NORTH` 避免拼错,
5
- * 类型位置用 `RectAnchor`。
6
- */
3
+ /** 矩形 9 个标准 anchor 名常量(与 RectAnchor 配对,用 RECT_ANCHORS.NORTH 避免拼错) */
7
4
  var RECT_ANCHORS = {
8
- /** 几何中心 */
9
5
  CENTER: "center",
10
- /** 上边中点 */
11
6
  NORTH: "north",
12
- /** 下边中点 */
13
7
  SOUTH: "south",
14
- /** 右边中点 */
15
8
  EAST: "east",
16
- /** 左边中点 */
17
9
  WEST: "west",
18
- /** 右上角 */
19
10
  NORTH_EAST: "north-east",
20
- /** 左上角 */
21
11
  NORTH_WEST: "north-west",
22
- /** 右下角 */
23
12
  SOUTH_EAST: "south-east",
24
- /** 左下角 */
25
13
  SOUTH_WEST: "south-west"
26
14
  };
27
- /**
28
- * 把"以矩形中心为原点的本地坐标"转换为世界坐标。
29
- * 考虑 rect.rotate(弧度)的旋转。
30
- */
31
- var localToWorld = (r, local) => {
32
- const angle = r.rotate ?? 0;
33
- if (angle === 0) return [r.x + local[0], r.y + local[1]];
34
- const cos = Math.cos(angle);
35
- const sin = Math.sin(angle);
36
- return [r.x + local[0] * cos - local[1] * sin, r.y + local[0] * sin + local[1] * cos];
37
- };
38
- /**
39
- * 把世界坐标转换为"以矩形中心为原点的本地坐标"。
40
- * 与 localToWorld 互为逆变换。
41
- */
42
- var worldToLocal = (r, world) => {
43
- const tx = world[0] - r.x;
44
- const ty = world[1] - r.y;
45
- const angle = r.rotate ?? 0;
46
- if (angle === 0) return [tx, ty];
47
- const cos = Math.cos(angle);
48
- const sin = Math.sin(angle);
49
- return [tx * cos + ty * sin, -tx * sin + ty * cos];
50
- };
51
- /** 矩形相关基础工具 */
52
15
  var rect = {
53
- /** 矩形几何中心点 */
16
+ /** 几何中心 */
54
17
  center: (r) => [r.x, r.y],
55
- /** 判断点是否落在矩形范围内(含边界,考虑旋转) */
18
+ /** 点是否在矩形内(含边界,含旋转) */
56
19
  contains: (r, p) => {
57
- const [lx, ly] = worldToLocal(r, p);
20
+ const [lx, ly] = require__transform.worldToLocal(r, p);
58
21
  const halfW = r.width / 2;
59
22
  const halfH = r.height / 2;
60
23
  return lx >= -halfW && lx <= halfW && ly >= -halfH && ly <= halfH;
61
24
  },
62
- /**
63
- * 取矩形 9 个标准 anchor 之一的世界坐标,考虑旋转。
64
- * 名字与 TikZ 节点 anchor 一致(north / south / east / west / north-east / ... / center)。
65
- */
25
+ /** 9 个 anchor 之一的世界坐标(含旋转),TikZ 命名 */
66
26
  anchor: (r, name) => {
67
27
  const halfW = r.width / 2;
68
28
  const halfH = r.height / 2;
@@ -99,21 +59,18 @@ var rect = {
99
59
  ly = halfH;
100
60
  break;
101
61
  }
102
- return localToWorld(r, [lx, ly]);
62
+ return require__transform.localToWorld(r, [lx, ly]);
103
63
  },
104
- /**
105
- * 从矩形中心向 toward 方向画射线,求与矩形边界的交点(考虑旋转)。
106
- * 用于把 Path 端点贴到 Node 边界(避免线段穿过节点内部)。
107
- */
64
+ /** 从中心向 toward 方向射线与矩形边界交点(含旋转),Path 端点贴 Node 边界用 */
108
65
  boundaryPoint: (r, toward) => {
109
- const [localX, localY] = worldToLocal(r, toward);
66
+ const [localX, localY] = require__transform.worldToLocal(r, toward);
110
67
  if (localX === 0 && localY === 0) return [r.x, r.y];
111
68
  const halfW = r.width / 2;
112
69
  const halfH = r.height / 2;
113
70
  const tx = localX === 0 ? Infinity : halfW / Math.abs(localX);
114
71
  const ty = localY === 0 ? Infinity : halfH / Math.abs(localY);
115
72
  const t = Math.min(tx, ty);
116
- return localToWorld(r, [localX * t, localY * t]);
73
+ return require__transform.localToWorld(r, [localX * t, localY * t]);
117
74
  }
118
75
  };
119
76
  //#endregion
@@ -1,59 +1,35 @@
1
1
  import { Position } from './point';
2
- /** 轴对齐矩形:几何中心 (x, y) + 宽高 + 可选绕中心旋转 */
2
+ /** 轴对齐矩形:几何中心 + 宽高 + 可选绕中心旋转 */
3
3
  export type Rect = {
4
- /** 矩形几何中心横坐标 */
5
4
  x: number;
6
- /** 矩形几何中心纵坐标 */
7
5
  y: number;
8
- /** 矩形宽度(user units) */
9
6
  width: number;
10
- /** 矩形高度(user units) */
11
7
  height: number;
12
- /** 绕几何中心的旋转角(弧度);省略或 0 表示不旋转 */
8
+ /** 绕中心旋转弧度 */
13
9
  rotate?: number;
14
10
  };
15
- /**
16
- * 矩形 9 个标准 anchor 名常量集合,对应 TikZ 节点的 9 个标准 anchor。
17
- * 与 `RectAnchor` 类型配对使用——值用 `RECT_ANCHORS.NORTH` 避免拼错,
18
- * 类型位置用 `RectAnchor`。
19
- */
11
+ /** 矩形 9 个标准 anchor 名常量(与 RectAnchor 配对,用 RECT_ANCHORS.NORTH 避免拼错) */
20
12
  export declare const RECT_ANCHORS: {
21
- /** 几何中心 */
22
13
  readonly CENTER: "center";
23
- /** 上边中点 */
24
14
  readonly NORTH: "north";
25
- /** 下边中点 */
26
15
  readonly SOUTH: "south";
27
- /** 右边中点 */
28
16
  readonly EAST: "east";
29
- /** 左边中点 */
30
17
  readonly WEST: "west";
31
- /** 右上角 */
32
18
  readonly NORTH_EAST: "north-east";
33
- /** 左上角 */
34
19
  readonly NORTH_WEST: "north-west";
35
- /** 右下角 */
36
20
  readonly SOUTH_EAST: "south-east";
37
- /** 左下角 */
38
21
  readonly SOUTH_WEST: "south-west";
39
22
  };
40
- /** 矩形 anchor 名(与 TikZ 命名约定一致),由 `RECT_ANCHORS` 常量集合派生 */
23
+ /** 矩形 anchor 名(与 TikZ 命名一致) */
41
24
  export type RectAnchor = (typeof RECT_ANCHORS)[keyof typeof RECT_ANCHORS];
42
- /** 矩形相关基础工具 */
43
25
  export declare const rect: {
44
- /** 矩形几何中心点 */
26
+ /** 几何中心 */
45
27
  center: (r: Rect) => Position;
46
- /** 判断点是否落在矩形范围内(含边界,考虑旋转) */
28
+ /** 点是否在矩形内(含边界,含旋转) */
47
29
  contains: (r: Rect, p: Position) => boolean;
48
- /**
49
- * 取矩形 9 个标准 anchor 之一的世界坐标,考虑旋转。
50
- * 名字与 TikZ 节点 anchor 一致(north / south / east / west / north-east / ... / center)。
51
- */
30
+ /** 9 个 anchor 之一的世界坐标(含旋转),TikZ 命名 */
52
31
  anchor: (r: Rect, name: RectAnchor) => Position;
53
- /**
54
- * 从矩形中心向 toward 方向画射线,求与矩形边界的交点(考虑旋转)。
55
- * 用于把 Path 端点贴到 Node 边界(避免线段穿过节点内部)。
56
- */
32
+ /** 从中心向 toward 方向射线与矩形边界交点(含旋转),Path 端点贴 Node 边界用 */
57
33
  boundaryPoint: (r: Rect, toward: Position) => Position;
58
34
  };
59
35
  //# sourceMappingURL=rect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/geometry/rect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,uCAAuC;AACvC,MAAM,MAAM,IAAI,GAAG;IACjB,gBAAgB;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,gBAAgB;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY;IACvB,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,UAAU;;IAEV,UAAU;;IAEV,UAAU;;IAEV,UAAU;;CAEF,CAAC;AAEX,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAgC1E,eAAe;AACf,eAAO,MAAM,IAAI;IACf,cAAc;gBACF,IAAI,KAAG,QAAQ;IAC3B,6BAA6B;kBACf,IAAI,KAAK,QAAQ,KAAG,OAAO;IAMzC;;;OAGG;gBACS,IAAI,QAAQ,UAAU,KAAG,QAAQ;IAuC7C;;;OAGG;uBACgB,IAAI,UAAU,QAAQ,KAAG,QAAQ;CAUrD,CAAC"}
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"}
@@ -11,9 +11,8 @@ var lineSegmentSample = (from, to, t) => ({
11
11
  tangent: normalize([to[0] - from[0], to[1] - from[1]])
12
12
  });
13
13
  /**
14
- * 二次贝塞尔 from → control → to
15
- * P(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
16
- * P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
14
+ * 二次贝塞尔 from → control → to
15
+ * @description P(t) = (1-t)²P0 + 2(1-t)t·P1 + t²P2;P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
17
16
  */
18
17
  var quadSegmentSample = (from, control, to, t) => {
19
18
  const u = 1 - t;
@@ -23,8 +22,8 @@ var quadSegmentSample = (from, control, to, t) => {
23
22
  };
24
23
  };
25
24
  /**
26
- * 三次贝塞尔 from → c1 → c2 → to
27
- * P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
25
+ * 三次贝塞尔 from → c1 → c2 → to
26
+ * @description P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
28
27
  */
29
28
  var cubicSegmentSample = (from, c1, c2, to, t) => {
30
29
  const u = 1 - t;
@@ -34,18 +33,14 @@ var cubicSegmentSample = (from, c1, c2, to, t) => {
34
33
  };
35
34
  };
36
35
  /**
37
- * 折角段 from → corner → to
38
- * t∈[0, 0.5] 走第一段(参数 2t);t∈(0.5, 1] 走第二段(参数 2t-1)。
39
- * t=0.5 落在 corner,切线取第一段方向(与"靠近 prev 一侧"一致)。
36
+ * 折角段 from → corner → to
37
+ * @description t∈[0,0.5] 走第一段(参数 2t);t∈(0.5,1] 走第二段(参数 2t-1);t=0.5 落 corner 切线取第一段方向
40
38
  */
41
39
  var foldSegmentSample = (from, corner, to, t) => {
42
40
  if (t <= .5) return lineSegmentSample(from, corner, t * 2);
43
41
  return lineSegmentSample(corner, to, t * 2 - 1);
44
42
  };
45
- /**
46
- * 弧段(与 ir/path arc 同约定,角度单位为度)。
47
- * 切线沿"扫描方向"——endAngle ≥ startAngle 时为 (-sin, cos),否则反向。
48
- */
43
+ /** 弧段(角度度数,与 ir/path arc 同约定);切线沿扫描方向:endAngle ≥ start 取 (-sin,cos),否则反向 */
49
44
  var arcSegmentSample = (center, radius, startAngleDeg, endAngleDeg, t) => {
50
45
  const rad = (startAngleDeg + t * (endAngleDeg - startAngleDeg)) * DEG_TO_RAD;
51
46
  const cos = Math.cos(rad);
@@ -56,9 +51,7 @@ var arcSegmentSample = (center, radius, startAngleDeg, endAngleDeg, t) => {
56
51
  tangent: normalize([-sin * sweepSign, cos * sweepSign])
57
52
  };
58
53
  };
59
- /**
60
- * 整圆——从 0°(east)开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致。
61
- */
54
+ /** 整圆,从 0°(east) 开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致 */
62
55
  var circleSegmentSample = (center, radius, t) => {
63
56
  const rad = t * 360 * DEG_TO_RAD;
64
57
  const cos = Math.cos(rad);
@@ -68,7 +61,7 @@ var circleSegmentSample = (center, radius, t) => {
68
61
  tangent: normalize([-sin, cos])
69
62
  };
70
63
  };
71
- /** 整椭圆——参数化 (rx·cos(2πt), ry·sin(2πt)) */
64
+ /** 整椭圆,参数化 (rx·cos(2πt), ry·sin(2πt)) */
72
65
  var ellipseSegmentSample = (center, rx, ry, t) => {
73
66
  const rad = t * 360 * DEG_TO_RAD;
74
67
  const cos = Math.cos(rad);