@retikz/core 0.3.0-beta.2 → 0.4.0-alpha.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.
- package/dist/es/compile/node.js +1 -1
- package/dist/es/compile/path/anchor.js +1 -1
- package/dist/es/compile/path/index.js +1 -1
- package/dist/es/compile/path/relative.js +1 -1
- package/dist/es/compile/path/shrink.js +1 -1
- package/dist/es/compile/position.js +1 -1
- package/dist/es/geometry/contour.d.ts +1 -1
- package/dist/es/geometry/contour.d.ts.map +1 -1
- package/dist/es/geometry/contour.js +5 -45
- package/dist/es/geometry/edge.d.ts +1 -2
- package/dist/es/geometry/edge.d.ts.map +1 -1
- package/dist/es/geometry/edge.js +2 -3
- package/dist/es/geometry/index.d.ts +0 -1
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/geometry/point.d.ts +1 -29
- package/dist/es/geometry/point.d.ts.map +1 -1
- package/dist/es/geometry/point.js +2 -50
- 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 +13 -5
- package/dist/es/geometry/rect.d.ts +1 -1
- package/dist/es/geometry/rect.js +1 -1
- package/dist/es/geometry/transform.d.ts +1 -20
- package/dist/es/geometry/transform.d.ts.map +1 -1
- package/dist/es/geometry/transform.js +1 -26
- package/dist/es/index.js +2 -2
- package/dist/es/shapes/arc.js +1 -1
- package/dist/es/shapes/shared.js +1 -1
- package/dist/lib/compile/node.cjs +2 -2
- package/dist/lib/compile/path/anchor.cjs +4 -5
- package/dist/lib/compile/path/index.cjs +17 -17
- package/dist/lib/compile/path/relative.cjs +2 -2
- package/dist/lib/compile/path/shrink.cjs +3 -3
- package/dist/lib/compile/position.cjs +2 -2
- package/dist/lib/geometry/circle.cjs +6 -6
- package/dist/lib/geometry/contour.cjs +12 -52
- package/dist/lib/geometry/contour.d.ts +1 -1
- package/dist/lib/geometry/contour.d.ts.map +1 -1
- package/dist/lib/geometry/diamond.cjs +5 -5
- package/dist/lib/geometry/edge.cjs +2 -4
- package/dist/lib/geometry/edge.d.ts +1 -2
- package/dist/lib/geometry/edge.d.ts.map +1 -1
- package/dist/lib/geometry/ellipse.cjs +6 -6
- package/dist/lib/geometry/index.d.ts +0 -1
- package/dist/lib/geometry/index.d.ts.map +1 -1
- package/dist/lib/geometry/point.d.ts +1 -29
- package/dist/lib/geometry/point.d.ts.map +1 -1
- package/dist/lib/geometry/polar.cjs +13 -5
- 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 +7 -7
- package/dist/lib/geometry/rect.d.ts +1 -1
- package/dist/lib/geometry/segment.cjs +9 -9
- package/dist/lib/geometry/transform.d.ts +1 -20
- package/dist/lib/geometry/transform.d.ts.map +1 -1
- package/dist/lib/index.cjs +20 -6
- package/dist/lib/shapes/arc.cjs +7 -8
- package/dist/lib/shapes/index.cjs +1 -1
- package/dist/lib/shapes/polygon.cjs +2 -2
- package/dist/lib/shapes/rectangle.cjs +5 -5
- package/dist/lib/shapes/sector.cjs +4 -4
- package/dist/lib/shapes/shared.cjs +4 -4
- package/dist/lib/shapes/star.cjs +2 -2
- package/package.json +3 -2
- package/dist/es/geometry/arc.d.ts +0 -34
- package/dist/es/geometry/arc.d.ts.map +0 -1
- package/dist/es/geometry/arc.js +0 -108
- package/dist/lib/geometry/arc.cjs +0 -113
- package/dist/lib/geometry/arc.d.ts +0 -34
- package/dist/lib/geometry/arc.d.ts.map +0 -1
- package/dist/lib/geometry/point.cjs +0 -50
- package/dist/lib/geometry/transform.cjs +0 -28
package/dist/es/compile/node.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JsonObjectSchema } from "../ir/json.js";
|
|
2
|
-
import { arcEndPoint } from "../geometry/arc.js";
|
|
3
2
|
import { normalizeCompassAnchor } from "../geometry/anchor.js";
|
|
4
3
|
import { BUILTIN_SHAPES } from "../shapes/index.js";
|
|
5
4
|
import { DirectionVectorByAtDirection, LabelAnchorByAtDirection } from "./direction.js";
|
|
6
5
|
import { resolvePosition } from "./position.js";
|
|
7
6
|
import { toAlphabeticBaselineY } from "./text-baseline.js";
|
|
8
7
|
import { resolveBoundary } from "./boundary.js";
|
|
8
|
+
import { arcEndPoint } from "@retikz/math";
|
|
9
9
|
//#region src/compile/node.ts
|
|
10
10
|
var DEFAULT_FONT_SIZE = 14;
|
|
11
11
|
var DEFAULT_PADDING = 8;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FoldStepVia } from "../../ir/path/step.js";
|
|
2
2
|
import { lerpPoint } from "../../geometry/edge.js";
|
|
3
|
-
import { point } from "../../geometry/point.js";
|
|
4
3
|
import { applyTransformChain } from "../scope.js";
|
|
5
4
|
import { resolvePosition } from "../position.js";
|
|
6
5
|
import { boundaryPointOf } from "../node.js";
|
|
6
|
+
import { point } from "../../geometry/point.js";
|
|
7
7
|
import { resolveAnchor, resolveEdgePoint } from "../anchor-cache.js";
|
|
8
8
|
//#region src/compile/path/anchor.ts
|
|
9
9
|
/** target 是否对象形态 NodeTarget(`{ id, anchor?, offset? }`);与 Position(array) / Polar / Offset(of) / Relative 区分(独有 `id`) */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JsonObjectSchema } from "../../ir/json.js";
|
|
2
2
|
import { rectOutline } from "../../geometry/rect.js";
|
|
3
|
-
import { arcBoundingPoints, arcEndPoint, ellipseArcBoundingPoints, ellipseArcPoint } from "../../geometry/arc.js";
|
|
4
3
|
import { BUILTIN_ARROWS } from "../../arrows/index.js";
|
|
5
4
|
import { CompileWarningCode } from "../constant.js";
|
|
6
5
|
import { applyTransformChain } from "../scope.js";
|
|
@@ -12,6 +11,7 @@ import { emitLabelPrimitive, tForLabelPosition } from "./label.js";
|
|
|
12
11
|
import { normalizeRelativeTargets } from "./relative.js";
|
|
13
12
|
import { applyArrowShrinks, endpointArrows, resolveMarkArrowSpec } from "./shrink.js";
|
|
14
13
|
import { splitSubPathsForEndpointArrows } from "./split.js";
|
|
14
|
+
import { arcBoundingPoints, arcEndPoint, ellipseArcBoundingPoints, ellipseArcPoint } from "@retikz/math";
|
|
15
15
|
//#region src/compile/path/index.ts
|
|
16
16
|
/**
|
|
17
17
|
* referent(offset.of / polar.origin 的并集形态:节点 id 字符串 / `[x, y]` 字面量 / 嵌套 PolarPosition)里挖节点 id
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { arcEndPoint } from "../../geometry/arc.js";
|
|
2
1
|
import { inverseTransformChain } from "../scope.js";
|
|
3
2
|
import { refPointOfTarget } from "./anchor.js";
|
|
3
|
+
import { arcEndPoint } from "@retikz/math";
|
|
4
4
|
//#region src/compile/path/relative.ts
|
|
5
5
|
/**
|
|
6
6
|
* relative/relativeAccumulate 目标解析为绝对 Position(step kind 不变,to 为局部坐标 tuple)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_ARROW_SHAPE } from "../../ir/path/arrow.js";
|
|
2
|
-
import { arcEndPoint, ellipseArcPoint } from "../../geometry/arc.js";
|
|
3
2
|
import { validateMarkerPrimitives } from "../marker-prim.js";
|
|
4
3
|
import { shiftToward } from "./anchor.js";
|
|
4
|
+
import { arcEndPoint, ellipseArcPoint } from "@retikz/math";
|
|
5
5
|
//#region src/compile/path/shrink.ts
|
|
6
6
|
/** 默认 baseSize(marker 局部基准边长,viewBox `0 0 baseSize baseSize`) */
|
|
7
7
|
var ARROW_GEOMETRY_BASE_SIZE = 10;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { arcEndPoint } from "../geometry/arc.js";
|
|
2
1
|
import { DirectionVectorByAtDirection } from "./direction.js";
|
|
3
2
|
import { inverseTransformChain } from "./scope.js";
|
|
3
|
+
import { arcEndPoint } from "@retikz/math";
|
|
4
4
|
//#region src/compile/position.ts
|
|
5
5
|
/** 默认相对定位距离(CompileOptions.nodeDistance 未配时使用) */
|
|
6
6
|
var DEFAULT_NODE_DISTANCE = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contour.d.ts","sourceRoot":"","sources":["../../../src/geometry/contour.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contour.d.ts","sourceRoot":"","sources":["../../../src/geometry/contour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA0D,MAAM,cAAc,CAAC;AAkBrG,4BAA4B;AAC5B,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,gBAAgB;IAChB,EAAE,EAAE,QAAQ,CAAC;CACd,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY;IACZ,IAAI,EAAE,KAAK,CAAC;IACZ,gBAAgB;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,6BAA6B;AAC7B,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD,qFAAqF;AACrF,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,CAAA;CAAE,GAC9B;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GACD;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AA6BtB;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,kBAAkB;IAClB,cAAc,EAAE,QAAQ,CAAC;IACzB,kBAAkB;IAClB,eAAe,EAAE,QAAQ,CAAC;IAC1B,gBAAgB;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8BAA8B;IAC9B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AA8PF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,KAAK,CAAC,cAAc,CAAC,EAC/B,eAAe,MAAM,KACpB,KAAK,CAAC,cAAc,CAUtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,KAAK,CAAC,cAAc,CAAC,EAC/B,eAAe,MAAM,EACrB,UAAS,KAAK,CAAC,cAAc,CAAyC,KACrE,KAAK,CAAC,cAAc,CAsCtB,CAAC;AA2BF,iEAAiE;AACjE,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAUjG,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,KAAK,CAAC,cAAc,CAAC,EAC/B,cAAc,MAAM,GAAG,SAAS,EAChC,WAAW,QAAQ,EACnB,QAAQ,QAAQ,EAChB,UAAS,KAAK,CAAC,cAAc,CAAyC,KACrE,QAAQ,GAAG,SA0Eb,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { arcAngleInRange, arcEndPoint, rayArc } from "
|
|
2
|
-
import { point } from "./point.js";
|
|
1
|
+
import { arcAngleInRange, arcEndPoint, intersect, point, rayArc } from "@retikz/math";
|
|
3
2
|
//#region src/geometry/contour.ts
|
|
4
3
|
var DEG_TO_RAD = Math.PI / 180;
|
|
5
4
|
var RAD_TO_DEG = 180 / Math.PI;
|
|
@@ -76,45 +75,6 @@ var offsetSegmentAlt = (seg, r) => ({
|
|
|
76
75
|
center: seg.center,
|
|
77
76
|
radius: seg.radius + r
|
|
78
77
|
});
|
|
79
|
-
/** 直线 ∩ 直线(各以 point + dir 表示),返回交点或 undefined(平行) */
|
|
80
|
-
var intersectLineLine = (a, b) => {
|
|
81
|
-
const det = cross(a.dir, b.dir);
|
|
82
|
-
if (Math.abs(det) < EPSILON) return void 0;
|
|
83
|
-
const dx = b.point[0] - a.point[0];
|
|
84
|
-
const dy = b.point[1] - a.point[1];
|
|
85
|
-
const t = (dx * b.dir[1] - dy * b.dir[0]) / det;
|
|
86
|
-
return [a.point[0] + a.dir[0] * t, a.point[1] + a.dir[1] * t];
|
|
87
|
-
};
|
|
88
|
-
/** 直线(point+dir)∩ 圆(center,radius),返回交点列(0/1/2 个) */
|
|
89
|
-
var intersectLineCircle = (line, circle) => {
|
|
90
|
-
const ox = line.point[0] - circle.center[0];
|
|
91
|
-
const oy = line.point[1] - circle.center[1];
|
|
92
|
-
const ux = line.dir[0];
|
|
93
|
-
const uy = line.dir[1];
|
|
94
|
-
const b = 2 * (ox * ux + oy * uy);
|
|
95
|
-
const c = ox * ox + oy * oy - circle.radius * circle.radius;
|
|
96
|
-
const disc = b * b - 4 * c;
|
|
97
|
-
if (disc < 0) return [];
|
|
98
|
-
const sq = Math.sqrt(disc);
|
|
99
|
-
const out = [];
|
|
100
|
-
for (const t of [(-b - sq) / 2, (-b + sq) / 2]) out.push([line.point[0] + ux * t, line.point[1] + uy * t]);
|
|
101
|
-
return out;
|
|
102
|
-
};
|
|
103
|
-
/** 圆 ∩ 圆,返回交点列(0/1/2 个) */
|
|
104
|
-
var intersectCircleCircle = (a, b) => {
|
|
105
|
-
const dx = b.center[0] - a.center[0];
|
|
106
|
-
const dy = b.center[1] - a.center[1];
|
|
107
|
-
const d = Math.hypot(dx, dy);
|
|
108
|
-
if (d < EPSILON || d > a.radius + b.radius + EPSILON || d < Math.abs(a.radius - b.radius) - EPSILON) return [];
|
|
109
|
-
const aa = (a.radius * a.radius - b.radius * b.radius + d * d) / (2 * d);
|
|
110
|
-
const h2 = a.radius * a.radius - aa * aa;
|
|
111
|
-
const h = h2 > 0 ? Math.sqrt(h2) : 0;
|
|
112
|
-
const mx = a.center[0] + aa * dx / d;
|
|
113
|
-
const my = a.center[1] + aa * dy / d;
|
|
114
|
-
const rx = -dy * h / d;
|
|
115
|
-
const ry = dx * h / d;
|
|
116
|
-
return [[mx + rx, my + ry], [mx - rx, my - ry]];
|
|
117
|
-
};
|
|
118
78
|
/** 点到直线(无限延长)的有符号垂足点 */
|
|
119
79
|
var footOnLine = (p, base, dir) => {
|
|
120
80
|
const t = (p[0] - base[0]) * dir[0] + (p[1] - base[1]) * dir[1];
|
|
@@ -139,11 +99,11 @@ var solveFillet = (segA, segB, r) => {
|
|
|
139
99
|
const candidates = [];
|
|
140
100
|
const pushIntersections = (oa, ob) => {
|
|
141
101
|
if (oa.kind === "line" && ob.kind === "line") {
|
|
142
|
-
const p =
|
|
102
|
+
const p = intersect.lineLine(oa.point, [oa.point[0] + oa.dir[0], oa.point[1] + oa.dir[1]], ob.point, [ob.point[0] + ob.dir[0], ob.point[1] + ob.dir[1]]);
|
|
143
103
|
if (p) candidates.push(p);
|
|
144
|
-
} else if (oa.kind === "line" && ob.kind === "circle") candidates.push(...
|
|
145
|
-
else if (oa.kind === "circle" && ob.kind === "line") candidates.push(...
|
|
146
|
-
else if (oa.kind === "circle" && ob.kind === "circle") candidates.push(...
|
|
104
|
+
} else if (oa.kind === "line" && ob.kind === "circle") candidates.push(...intersect.lineCircle(oa.point, oa.dir, ob.center, ob.radius));
|
|
105
|
+
else if (oa.kind === "circle" && ob.kind === "line") candidates.push(...intersect.lineCircle(ob.point, ob.dir, oa.center, oa.radius));
|
|
106
|
+
else if (oa.kind === "circle" && ob.kind === "circle") candidates.push(...intersect.circleCircle(oa.center, oa.radius, ob.center, ob.radius));
|
|
147
107
|
};
|
|
148
108
|
pushIntersections(offA, offB);
|
|
149
109
|
if (segA.kind === "arc") pushIntersections(offsetSegmentAlt(segA, radius), offB);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Position } from './point';
|
|
2
|
+
export { lerp as lerpPoint } from '@retikz/math';
|
|
2
3
|
/** 边上比例点 `{ side, t }` 的四个 side(north/south/east/west) */
|
|
3
4
|
export type Side = 'north' | 'south' | 'east' | 'west';
|
|
4
5
|
/**
|
|
@@ -12,8 +13,6 @@ export declare const EDGE_ENDS: {
|
|
|
12
13
|
readonly east: readonly ["north-east", "south-east"];
|
|
13
14
|
readonly west: readonly ["north-west", "south-west"];
|
|
14
15
|
};
|
|
15
|
-
/** 线性插值 a + (b − a)·t */
|
|
16
|
-
export declare const lerpPoint: (a: Position, b: Position, t: number) => Position;
|
|
17
16
|
/**
|
|
18
17
|
* circle / ellipse 周长弧段:side 的局部参数角 θ(t),单位度
|
|
19
18
|
* @description 约定同 geometry 既有 `(cosθ, sinθ)` + y 轴向下 ⇒ east=0° / south=90° / west=180° / north=270°,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../../src/geometry/edge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../../src/geometry/edge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjD,0DAA0D;AAC1D,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;CAK8D,CAAC;AAErF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,EAAE,GAAG,MAAM,KAAG,MAWpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,IAAI,QAAQ,EACZ,QAAQ,QAAQ,EAChB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,QAAkF,CAAC"}
|
package/dist/es/geometry/edge.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lerp, lerp as lerpPoint } from "@retikz/math";
|
|
1
2
|
//#region src/geometry/edge.ts
|
|
2
3
|
/**
|
|
3
4
|
* rect 四直边 t=0 / t=1 端点对应的角 anchor
|
|
@@ -10,8 +11,6 @@ var EDGE_ENDS = {
|
|
|
10
11
|
east: ["north-east", "south-east"],
|
|
11
12
|
west: ["north-west", "south-west"]
|
|
12
13
|
};
|
|
13
|
-
/** 线性插值 a + (b − a)·t */
|
|
14
|
-
var lerpPoint = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
15
14
|
/**
|
|
16
15
|
* circle / ellipse 周长弧段:side 的局部参数角 θ(t),单位度
|
|
17
16
|
* @description 约定同 geometry 既有 `(cosθ, sinθ)` + y 轴向下 ⇒ east=0° / south=90° / west=180° / north=270°,
|
|
@@ -30,6 +29,6 @@ var edgeAngleDeg = (side, t) => {
|
|
|
30
29
|
* @description t∈[0,0.5] 走 p0→vertex、t∈[0.5,1] 走 vertex→p1;t=0.5 恰落 vertex。
|
|
31
30
|
* p0/p1 为相邻边中点 anchor、vertex 为 cardinal 顶点 anchor——全落真实斜边
|
|
32
31
|
*/
|
|
33
|
-
var polylineViaVertex = (p0, vertex, p1, t) => t <= .5 ?
|
|
32
|
+
var polylineViaVertex = (p0, vertex, p1, t) => t <= .5 ? lerp(p0, vertex, t * 2) : lerp(vertex, p1, (t - .5) * 2);
|
|
34
33
|
//#endregion
|
|
35
34
|
export { EDGE_ENDS, edgeAngleDeg, lerpPoint, polylineViaVertex };
|
|
@@ -6,7 +6,6 @@ export * from './ellipse';
|
|
|
6
6
|
export * from './diamond';
|
|
7
7
|
export * from './polar';
|
|
8
8
|
export * from './bend';
|
|
9
|
-
export * from './arc';
|
|
10
9
|
export * from './segment';
|
|
11
10
|
export * from './contour';
|
|
12
11
|
export { EDGE_ENDS, lerpPoint, edgeAngleDeg, polylineViaVertex } from './edge';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC/E,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** 笛卡尔坐标点 [x, y] */
|
|
3
|
-
export type Position = [number, number];
|
|
4
|
-
/** 二维向量 / 坐标的基础运算工具集 */
|
|
5
|
-
export declare const point: {
|
|
6
|
-
/** 向量加 a + b */
|
|
7
|
-
add: (a: Position, b: Position) => Position;
|
|
8
|
-
/** 向量减 a - b */
|
|
9
|
-
sub: (a: Position, b: Position) => Position;
|
|
10
|
-
/** 等比缩放 a * k */
|
|
11
|
-
scale: (a: Position, k: number) => Position;
|
|
12
|
-
/** 向量长度 */
|
|
13
|
-
length: (a: Position) => number;
|
|
14
|
-
/** 归一化向量;零长度 / 极短向量回退到 fallback */
|
|
15
|
-
normalize: (a: Position, fallback?: Position, epsilon?: number) => Position;
|
|
16
|
-
/** 把点 p 沿 target 方向移动 dist */
|
|
17
|
-
shiftToward: (p: Position, target: Position, dist: number) => Position;
|
|
18
|
-
/** 两点精确相等(不带容差) */
|
|
19
|
-
equal: (a: Position, b: Position) => boolean;
|
|
20
|
-
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
21
|
-
toPolar: (p: Position) => PolarPosition;
|
|
22
|
-
/**
|
|
23
|
-
* 跨坐标系两点相同判断(笛卡尔或 PolarPosition)
|
|
24
|
-
* @description 极坐标先转笛卡尔再按 precision 四舍五入比较;polar.equal 委托到本方法
|
|
25
|
-
* @param precision 小数点后位数;默认 2
|
|
26
|
-
* @throws 当 PolarPosition.origin 是节点 id 字符串时(需 Scene 上下文)
|
|
27
|
-
*/
|
|
28
|
-
equalPolar: (a: Position | PolarPosition, b: Position | PolarPosition, precision?: number) => boolean;
|
|
29
|
-
};
|
|
1
|
+
export { type Position, point, DEFAULT_EPSILON } from '@retikz/math';
|
|
30
2
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var RAD_TO_DEG = 180 / Math.PI;
|
|
4
|
-
var DEFAULT_EPSILON = 1e-9;
|
|
5
|
-
/** 二维向量 / 坐标的基础运算工具集 */
|
|
6
|
-
var point = {
|
|
7
|
-
/** 向量加 a + b */
|
|
8
|
-
add: (a, b) => [a[0] + b[0], a[1] + b[1]],
|
|
9
|
-
/** 向量减 a - b */
|
|
10
|
-
sub: (a, b) => [a[0] - b[0], a[1] - b[1]],
|
|
11
|
-
/** 等比缩放 a * k */
|
|
12
|
-
scale: (a, k) => [a[0] * k, a[1] * k],
|
|
13
|
-
/** 向量长度 */
|
|
14
|
-
length: (a) => Math.hypot(a[0], a[1]),
|
|
15
|
-
/** 归一化向量;零长度 / 极短向量回退到 fallback */
|
|
16
|
-
normalize: (a, fallback = [1, 0], epsilon = DEFAULT_EPSILON) => {
|
|
17
|
-
const len = Math.hypot(a[0], a[1]);
|
|
18
|
-
if (len < epsilon) return fallback;
|
|
19
|
-
return [a[0] / len, a[1] / len];
|
|
20
|
-
},
|
|
21
|
-
/** 把点 p 沿 target 方向移动 dist */
|
|
22
|
-
shiftToward: (p, target, dist) => {
|
|
23
|
-
if (dist === 0) return p;
|
|
24
|
-
const delta = [target[0] - p[0], target[1] - p[1]];
|
|
25
|
-
const dir = point.normalize(delta, [0, 0]);
|
|
26
|
-
if (point.equal(dir, [0, 0])) return p;
|
|
27
|
-
return [p[0] + dir[0] * dist, p[1] + dir[1] * dist];
|
|
28
|
-
},
|
|
29
|
-
/** 两点精确相等(不带容差) */
|
|
30
|
-
equal: (a, b) => a[0] === b[0] && a[1] === b[1],
|
|
31
|
-
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
32
|
-
toPolar: (p) => ({
|
|
33
|
-
angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
|
|
34
|
-
radius: Math.hypot(p[0], p[1])
|
|
35
|
-
}),
|
|
36
|
-
/**
|
|
37
|
-
* 跨坐标系两点相同判断(笛卡尔或 PolarPosition)
|
|
38
|
-
* @description 极坐标先转笛卡尔再按 precision 四舍五入比较;polar.equal 委托到本方法
|
|
39
|
-
* @param precision 小数点后位数;默认 2
|
|
40
|
-
* @throws 当 PolarPosition.origin 是节点 id 字符串时(需 Scene 上下文)
|
|
41
|
-
*/
|
|
42
|
-
equalPolar: (a, b, precision = 2) => {
|
|
43
|
-
const aCart = Array.isArray(a) ? a : polar.toPosition(a);
|
|
44
|
-
const bCart = Array.isArray(b) ? b : polar.toPosition(b);
|
|
45
|
-
const factor = 10 ** precision;
|
|
46
|
-
return Math.round(aCart[0] * factor) === Math.round(bCart[0] * factor) && Math.round(aCart[1] * factor) === Math.round(bCart[1] * factor);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
//#endregion
|
|
50
|
-
export { point };
|
|
1
|
+
import { point as point$1 } from "@retikz/math";
|
|
2
|
+
export { point$1 as point };
|
|
@@ -18,7 +18,7 @@ export declare const polar: {
|
|
|
18
18
|
* @description origin 为字符串(节点 id)时抛错——字符串解析依赖 Scene 编译器 nodeIndex
|
|
19
19
|
*/
|
|
20
20
|
toPosition: (p: PolarPosition) => Position;
|
|
21
|
-
/** 笛卡尔 → 极坐标(
|
|
21
|
+
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
22
22
|
fromPosition: (p: Position) => PolarPosition;
|
|
23
23
|
/** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
|
|
24
24
|
offsetFrom: (origin: Position, offset: {
|
|
@@ -26,7 +26,7 @@ export declare const polar: {
|
|
|
26
26
|
radius: number;
|
|
27
27
|
}) => Position;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* 跨坐标系两点相同判断
|
|
30
30
|
* @description 极坐标先转笛卡尔再按 precision 四舍五入比较
|
|
31
31
|
* @param precision 小数点后位数;默认 2
|
|
32
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polar.d.ts","sourceRoot":"","sources":["../../../src/geometry/polar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"polar.d.ts","sourceRoot":"","sources":["../../../src/geometry/polar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AASxC;;;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;AAKF,oDAAoD;AACpD,eAAO,MAAM,KAAK;IAChB;;;OAGG;oBACa,aAAa,KAAG,QAAQ;IAmBxC,oDAAoD;sBAClC,QAAQ,KAAG,aAAa;IAI1C,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;CASX,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { point } from "./point.js";
|
|
2
1
|
//#region src/geometry/polar.ts
|
|
3
2
|
var DEG_TO_RAD = Math.PI / 180;
|
|
3
|
+
var RAD_TO_DEG = 180 / Math.PI;
|
|
4
4
|
/** 极坐标 ↔ 笛卡尔转换工具集(polar 不参与几何计算,参与时先 toPosition) */
|
|
5
5
|
var polar = {
|
|
6
6
|
/**
|
|
@@ -16,19 +16,27 @@ var polar = {
|
|
|
16
16
|
const rad = p.angle * DEG_TO_RAD;
|
|
17
17
|
return [origin[0] + Math.cos(rad) * p.radius, origin[1] + Math.sin(rad) * p.radius];
|
|
18
18
|
},
|
|
19
|
-
/** 笛卡尔 → 极坐标(
|
|
20
|
-
fromPosition: (p) =>
|
|
19
|
+
/** 笛卡尔 → 极坐标(angle ∈ (-180,180],origin 默认 [0,0]) */
|
|
20
|
+
fromPosition: (p) => ({
|
|
21
|
+
angle: Math.atan2(p[1], p[0]) * RAD_TO_DEG,
|
|
22
|
+
radius: Math.hypot(p[0], p[1])
|
|
23
|
+
}),
|
|
21
24
|
/** 在原点附近按极坐标偏移,返回结果点的世界笛卡尔坐标 */
|
|
22
25
|
offsetFrom: (origin, offset) => {
|
|
23
26
|
const rad = offset.angle * DEG_TO_RAD;
|
|
24
27
|
return [origin[0] + Math.cos(rad) * offset.radius, origin[1] + Math.sin(rad) * offset.radius];
|
|
25
28
|
},
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
30
|
+
* 跨坐标系两点相同判断
|
|
28
31
|
* @description 极坐标先转笛卡尔再按 precision 四舍五入比较
|
|
29
32
|
* @param precision 小数点后位数;默认 2
|
|
30
33
|
*/
|
|
31
|
-
equal: (a, b, precision = 2) =>
|
|
34
|
+
equal: (a, b, precision = 2) => {
|
|
35
|
+
const aCart = Array.isArray(a) ? a : polar.toPosition(a);
|
|
36
|
+
const bCart = Array.isArray(b) ? b : polar.toPosition(b);
|
|
37
|
+
const factor = 10 ** precision;
|
|
38
|
+
return Math.round(aCart[0] * factor) === Math.round(bCart[0] * factor) && Math.round(aCart[1] * factor) === Math.round(bCart[1] * factor);
|
|
39
|
+
}
|
|
32
40
|
};
|
|
33
41
|
//#endregion
|
|
34
42
|
export { polar };
|
|
@@ -42,7 +42,7 @@ export type RectOutlineOp = {
|
|
|
42
42
|
* 矩形 outline:两对角 → 顺时针 path 算子序列
|
|
43
43
|
* @description from/to 任意顺序,归一化 (x0,y0)=min、(x1,y1)=max。直角 = 4 line + close(起点左上 (x0,y0));
|
|
44
44
|
* 圆角 = 4 line + 4 quarter-arc + close(起点 (x0+r, y0))。cornerRadius clamp 到 min(w,h)/2。
|
|
45
|
-
* 角度约定同
|
|
45
|
+
* 角度约定同 @retikz/math arc(y-down:0=+x, 90=+y/下, 180=-x, 270=-y/上)。
|
|
46
46
|
*/
|
|
47
47
|
export declare const rectOutline: (from: Position, to: Position, cornerRadius?: number) => Array<RectOutlineOp>;
|
|
48
48
|
//# sourceMappingURL=rect.d.ts.map
|
package/dist/es/geometry/rect.js
CHANGED
|
@@ -71,7 +71,7 @@ var rect = {
|
|
|
71
71
|
* 矩形 outline:两对角 → 顺时针 path 算子序列
|
|
72
72
|
* @description from/to 任意顺序,归一化 (x0,y0)=min、(x1,y1)=max。直角 = 4 line + close(起点左上 (x0,y0));
|
|
73
73
|
* 圆角 = 4 line + 4 quarter-arc + close(起点 (x0+r, y0))。cornerRadius clamp 到 min(w,h)/2。
|
|
74
|
-
* 角度约定同
|
|
74
|
+
* 角度约定同 @retikz/math arc(y-down:0=+x, 90=+y/下, 180=-x, 270=-y/上)。
|
|
75
75
|
*/
|
|
76
76
|
var rectOutline = (from, to, cornerRadius) => {
|
|
77
77
|
const x0 = Math.min(from[0], to[0]);
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
export { type CenteredShape, localToWorld, worldToLocal } from '@retikz/math';
|
|
21
2
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/geometry/transform.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/geometry/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
import { localToWorld, worldToLocal } from "@retikz/math";
|
|
27
2
|
export { localToWorld, worldToLocal };
|
package/dist/es/index.js
CHANGED
|
@@ -26,14 +26,13 @@ import { rect } from "./geometry/rect.js";
|
|
|
26
26
|
import { defineShape } from "./shapes/define.js";
|
|
27
27
|
import { ellipse } from "./geometry/ellipse.js";
|
|
28
28
|
import { CompassAnchor, WebAnchor, normalizeCompassAnchor } from "./geometry/anchor.js";
|
|
29
|
-
import { polar } from "./geometry/polar.js";
|
|
30
|
-
import { point } from "./geometry/point.js";
|
|
31
29
|
import { BUILTIN_SHAPES } from "./shapes/index.js";
|
|
32
30
|
import { defineArrow } from "./arrows/define.js";
|
|
33
31
|
import { BUILTIN_ARROWS } from "./arrows/index.js";
|
|
34
32
|
import { definePattern } from "./patterns/define.js";
|
|
35
33
|
import { BUILTIN_PATTERNS } from "./patterns/index.js";
|
|
36
34
|
import { CompileWarningCode, formatCompileWarning } from "./compile/constant.js";
|
|
35
|
+
import { point } from "./geometry/point.js";
|
|
37
36
|
import { fallbackMeasurer } from "./compile/text-metrics.js";
|
|
38
37
|
import { computeLayout } from "./compile/layout.js";
|
|
39
38
|
import { compileToScene } from "./compile/compile.js";
|
|
@@ -43,6 +42,7 @@ import { DrawWay, parseWay } from "./parsers/way.js";
|
|
|
43
42
|
import { blink, cameraTo, colorShift, drawOn, fadeIn, flash, grow, growUp, loop, pulse, scaleIn, slideIn, spin, stagger, wiggle } from "./presets/animation.js";
|
|
44
43
|
import { circle } from "./geometry/circle.js";
|
|
45
44
|
import { diamond } from "./geometry/diamond.js";
|
|
45
|
+
import { polar } from "./geometry/polar.js";
|
|
46
46
|
import { definePathGenerator } from "./path-generators/define.js";
|
|
47
47
|
import { defineComposite } from "./composites/define.js";
|
|
48
48
|
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, AbsoluteTargetSchema, AnchorRefSchema, AnimationDirection, AnimationEasing, AnimationFill, AnimationProperty, AnimationTrackSchema, AnimationTrigger, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, ArrowMarkSchema, ArrowShape, AtDirection, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, BetweenPositionSchema, Boundary, BoundarySchema, BuiltinShape, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ClipSpecSchema, CompassAnchor, CompileWarningCode, CompositeBaseSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EasingSchema, EllipsePathStepSchema, FoldStepSchema, FoldStepVia, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, KeyframeSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, NodeTextAlign, OffsetPositionSchema, OriginSchema, PaintSpecSchema, PathDefaultSchema, PathScaleSchema, PathSchema, PatternShape, PolarPositionSchema, PositionSchema, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, ShapeRefSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, TriggerSchema, ViewBoxSchema, WebAnchor, blink, cameraTo, circle, colorShift, compileToScene, computeLayout, defineArrow, defineComposite, definePathGenerator, definePattern, defineShape, diamond, drawOn, ellipse, fadeIn, fallbackMeasurer, flash, formatCompileWarning, grow, growUp, localToWorld, loop, normalizeCompassAnchor, parseNodeTarget, parseTargetSugar, parseWay, point, polar, pulse, rect, scaleIn, slideIn, spin, stagger, wiggle, worldToLocal };
|
package/dist/es/shapes/arc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { localToWorld, worldToLocal } from "../geometry/transform.js";
|
|
2
|
-
import { arcBoundingPoints, arcEndPoint } from "../geometry/arc.js";
|
|
3
2
|
import { defineShape } from "./define.js";
|
|
4
3
|
import { normalizeAngularRange } from "./shared.js";
|
|
5
4
|
import { z } from "zod";
|
|
5
|
+
import { arcBoundingPoints, arcEndPoint } from "@retikz/math";
|
|
6
6
|
//#region src/shapes/arc.ts
|
|
7
7
|
var RAD_TO_DEG = 180 / Math.PI;
|
|
8
8
|
/** arc 的派生几何:圆心局部系 AABB + 圆心相对 AABB 中心偏移 */
|
package/dist/es/shapes/shared.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_json = require("../ir/json.cjs");
|
|
2
|
-
const require_arc = require("../geometry/arc.cjs");
|
|
3
2
|
const require_anchor = require("../geometry/anchor.cjs");
|
|
4
3
|
const require_index = require("../shapes/index.cjs");
|
|
5
4
|
const require_direction = require("./direction.cjs");
|
|
6
5
|
const require_position = require("./position.cjs");
|
|
7
6
|
const require_text_baseline = require("./text-baseline.cjs");
|
|
8
7
|
const require_boundary = require("./boundary.cjs");
|
|
8
|
+
let _retikz_math = require("@retikz/math");
|
|
9
9
|
//#region src/compile/node.ts
|
|
10
10
|
var DEFAULT_FONT_SIZE = 14;
|
|
11
11
|
var DEFAULT_PADDING = 8;
|
|
@@ -194,7 +194,7 @@ var labelBorderPoint = (layout, label) => {
|
|
|
194
194
|
};
|
|
195
195
|
var labelCenter = (layout, label) => {
|
|
196
196
|
const [bx, by] = labelBorderPoint(layout, label);
|
|
197
|
-
if (typeof label.position === "number") return
|
|
197
|
+
if (typeof label.position === "number") return (0, _retikz_math.arcEndPoint)([bx, by], label.distance, label.position);
|
|
198
198
|
const vec = require_direction.DirectionVectorByAtDirection[label.position];
|
|
199
199
|
return [bx + vec[0] * label.distance, by + vec[1] * label.distance];
|
|
200
200
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const require_step = require("../../ir/path/step.cjs");
|
|
2
|
-
const require_edge = require("../../geometry/edge.cjs");
|
|
3
|
-
const require_point = require("../../geometry/point.cjs");
|
|
4
2
|
const require_scope = require("../scope.cjs");
|
|
5
3
|
const require_position = require("../position.cjs");
|
|
6
4
|
const require_node = require("../node.cjs");
|
|
7
5
|
const require_anchor_cache = require("../anchor-cache.cjs");
|
|
6
|
+
let _retikz_math = require("@retikz/math");
|
|
8
7
|
//#region src/compile/path/anchor.ts
|
|
9
8
|
/** target 是否对象形态 NodeTarget(`{ id, anchor?, offset? }`);与 Position(array) / Polar / Offset(of) / Relative 区分(独有 `id`) */
|
|
10
9
|
var isNodeTarget = (t) => typeof t === "object" && !Array.isArray(t) && "id" in t;
|
|
@@ -36,7 +35,7 @@ var refPointOfTarget = (target, nameStack, scopeChain = []) => {
|
|
|
36
35
|
const a = refPointOfTarget(target.between[0], nameStack, scopeChain);
|
|
37
36
|
const b = refPointOfTarget(target.between[1], nameStack, scopeChain);
|
|
38
37
|
if (!a || !b) return null;
|
|
39
|
-
const mid =
|
|
38
|
+
const mid = (0, _retikz_math.lerp)(a, b, target.t);
|
|
40
39
|
if (!Number.isFinite(mid[0]) || !Number.isFinite(mid[1])) return null;
|
|
41
40
|
return mid;
|
|
42
41
|
}
|
|
@@ -67,9 +66,9 @@ var clipForTarget = (target, toward, nameStack, scopeChain = []) => {
|
|
|
67
66
|
return scopeChain.length === 0 ? local : require_scope.applyTransformChain(local, scopeChain);
|
|
68
67
|
};
|
|
69
68
|
/** 两个 IRPosition 两分量精确相等(未 round) */
|
|
70
|
-
var samePoint = (a, b) => !!a && !!b &&
|
|
69
|
+
var samePoint = (a, b) => !!a && !!b && _retikz_math.point.equal(a, b);
|
|
71
70
|
/** 把 p 朝 target 方向移动 dist */
|
|
72
|
-
var shiftToward = (p, target, dist) =>
|
|
71
|
+
var shiftToward = (p, target, dist) => _retikz_math.point.shiftToward(p, target, dist);
|
|
73
72
|
//#endregion
|
|
74
73
|
exports.clipForTarget = clipForTarget;
|
|
75
74
|
exports.cornerOf = cornerOf;
|