@skillpet/circuit 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/circuit.bundle.js +84 -64
- package/dist/circuit.bundle.min.js +20 -20
- package/dist/circuit.esm.js +84 -64
- package/dist/drawing-transition.d.ts +9 -9
- package/dist/index.cjs +84 -64
- package/package.json +1 -1
package/dist/circuit.esm.js
CHANGED
|
@@ -17345,51 +17345,55 @@ function resolveElementColor(el) {
|
|
|
17345
17345
|
const p = mergeParamsFirstWins(el.userParams, el.elmParams, el.defaults, el.dwgParams);
|
|
17346
17346
|
return p.color ?? "black";
|
|
17347
17347
|
}
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
17352
|
-
|
|
17353
|
-
|
|
17348
|
+
var EXCLUDED_ANCHORS = /* @__PURE__ */ new Set([
|
|
17349
|
+
"xy",
|
|
17350
|
+
"center",
|
|
17351
|
+
"istart",
|
|
17352
|
+
"iend",
|
|
17353
|
+
"mid",
|
|
17354
|
+
"label",
|
|
17355
|
+
"vd",
|
|
17356
|
+
"vs",
|
|
17357
|
+
"n1",
|
|
17358
|
+
"n2",
|
|
17359
|
+
"n1a",
|
|
17360
|
+
"n2a"
|
|
17361
|
+
]);
|
|
17362
|
+
function isConnectionAnchor(name) {
|
|
17363
|
+
return !EXCLUDED_ANCHORS.has(name);
|
|
17354
17364
|
}
|
|
17355
|
-
function
|
|
17365
|
+
function getConnectionAnchors(el) {
|
|
17356
17366
|
const pts = [];
|
|
17357
|
-
const
|
|
17358
|
-
|
|
17359
|
-
for (const [name, pt] of Object.entries(aa)) {
|
|
17360
|
-
if (name.startsWith("in") && /^in\d+$/.test(name)) {
|
|
17361
|
-
if (!aa.start || !pointsClose(pt, aa.start, 0.01)) pts.push(pt);
|
|
17362
|
-
}
|
|
17367
|
+
for (const [name, pt] of Object.entries(el.absanchors)) {
|
|
17368
|
+
if (isConnectionAnchor(name)) pts.push(pt);
|
|
17363
17369
|
}
|
|
17364
17370
|
return pts;
|
|
17365
17371
|
}
|
|
17366
|
-
function pointsClose(a, b, tol) {
|
|
17367
|
-
return Math.hypot(a.x - b.x, a.y - b.y) <= tol;
|
|
17368
|
-
}
|
|
17369
17372
|
function buildConnectionGraph(elements) {
|
|
17370
17373
|
const edges = [];
|
|
17371
17374
|
const seen = /* @__PURE__ */ new Set();
|
|
17372
17375
|
const tol = 0.5;
|
|
17373
17376
|
for (let i = 0; i < elements.length; i++) {
|
|
17374
|
-
const
|
|
17375
|
-
const
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
for (let j =
|
|
17379
|
-
|
|
17380
|
-
const
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
-
if (!pointsClose(fp, tp, tol)) continue;
|
|
17377
|
+
const elA = elements[i];
|
|
17378
|
+
const colorA = resolveElementColor(elA);
|
|
17379
|
+
const anchorsA = getConnectionAnchors(elA);
|
|
17380
|
+
if (anchorsA.length === 0) continue;
|
|
17381
|
+
for (let j = i + 1; j < elements.length; j++) {
|
|
17382
|
+
const elB = elements[j];
|
|
17383
|
+
const colorB = resolveElementColor(elB);
|
|
17384
|
+
if (colorsEqual(colorA, colorB)) continue;
|
|
17385
|
+
const anchorsB = getConnectionAnchors(elB);
|
|
17386
|
+
if (anchorsB.length === 0) continue;
|
|
17387
|
+
for (const pa of anchorsA) {
|
|
17388
|
+
for (const pb of anchorsB) {
|
|
17389
|
+
if (Math.hypot(pa.x - pb.x, pa.y - pb.y) > tol) continue;
|
|
17388
17390
|
const key = `${i}|${j}`;
|
|
17389
17391
|
if (seen.has(key)) continue;
|
|
17390
17392
|
seen.add(key);
|
|
17391
|
-
edges.push({
|
|
17393
|
+
edges.push({ elA, elB, colorA, colorB, junctionPt: pa });
|
|
17394
|
+
break;
|
|
17392
17395
|
}
|
|
17396
|
+
if (seen.has(`${i}|${j}`)) break;
|
|
17393
17397
|
}
|
|
17394
17398
|
}
|
|
17395
17399
|
}
|
|
@@ -17405,26 +17409,28 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17405
17409
|
const cleanups = [];
|
|
17406
17410
|
let n = 0;
|
|
17407
17411
|
for (const edge of edges) {
|
|
17408
|
-
const
|
|
17409
|
-
const
|
|
17410
|
-
if (!
|
|
17411
|
-
if (
|
|
17412
|
+
const segA = findSegAtJunction(edge.elA, edge.junctionPt);
|
|
17413
|
+
const segB = findSegAtJunction(edge.elB, edge.junctionPt);
|
|
17414
|
+
if (!segA && !segB) continue;
|
|
17415
|
+
if (segA?.gradientStrokeId && segB?.gradientStrokeId) continue;
|
|
17412
17416
|
let gx1, gy1, gx2, gy2;
|
|
17413
|
-
if (
|
|
17414
|
-
const
|
|
17415
|
-
const
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17417
|
+
if (segA && segB) {
|
|
17418
|
+
const a = segEndpointsSvg(edge.elA, segA, scale);
|
|
17419
|
+
const b = segEndpointsSvg(edge.elB, segB, scale);
|
|
17420
|
+
const aNear = nearFarSvg(edge.elA, segA, edge.junctionPt, scale);
|
|
17421
|
+
const bNear = nearFarSvg(edge.elB, segB, edge.junctionPt, scale);
|
|
17422
|
+
gx1 = aNear.farX;
|
|
17423
|
+
gy1 = aNear.farY;
|
|
17424
|
+
gx2 = bNear.farX;
|
|
17425
|
+
gy2 = bNear.farY;
|
|
17426
|
+
} else if (segA) {
|
|
17427
|
+
const c = segEndpointsSvg(edge.elA, segA, scale);
|
|
17422
17428
|
gx1 = c.x1;
|
|
17423
17429
|
gy1 = c.y1;
|
|
17424
17430
|
gx2 = c.x2;
|
|
17425
17431
|
gy2 = c.y2;
|
|
17426
17432
|
} else {
|
|
17427
|
-
const c = segEndpointsSvg(edge.
|
|
17433
|
+
const c = segEndpointsSvg(edge.elB, segB, scale);
|
|
17428
17434
|
gx1 = c.x1;
|
|
17429
17435
|
gy1 = c.y1;
|
|
17430
17436
|
gx2 = c.x2;
|
|
@@ -17432,17 +17438,17 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17432
17438
|
}
|
|
17433
17439
|
if (gradientVectorLength({ x1: gx1, y1: gy1, x2: gx2, y2: gy2 }) < 1e-6) continue;
|
|
17434
17440
|
const id = `sd-trans-${n++}`;
|
|
17435
|
-
parts.push(gradientXml(id, gx1, gy1, gx2, gy2, edge.
|
|
17436
|
-
if (
|
|
17437
|
-
|
|
17441
|
+
parts.push(gradientXml(id, gx1, gy1, gx2, gy2, edge.colorA, edge.colorB));
|
|
17442
|
+
if (segA && !segA.gradientStrokeId) {
|
|
17443
|
+
segA.gradientStrokeId = id;
|
|
17438
17444
|
cleanups.push(() => {
|
|
17439
|
-
|
|
17445
|
+
segA.gradientStrokeId = void 0;
|
|
17440
17446
|
});
|
|
17441
17447
|
}
|
|
17442
|
-
if (
|
|
17443
|
-
|
|
17448
|
+
if (segB && !segB.gradientStrokeId) {
|
|
17449
|
+
segB.gradientStrokeId = id;
|
|
17444
17450
|
cleanups.push(() => {
|
|
17445
|
-
|
|
17451
|
+
segB.gradientStrokeId = void 0;
|
|
17446
17452
|
});
|
|
17447
17453
|
}
|
|
17448
17454
|
}
|
|
@@ -17453,26 +17459,21 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17453
17459
|
}
|
|
17454
17460
|
};
|
|
17455
17461
|
}
|
|
17456
|
-
function
|
|
17457
|
-
const
|
|
17462
|
+
function findSegAtJunction(el, junctionPt) {
|
|
17463
|
+
const tol = 0.6;
|
|
17458
17464
|
for (const s of el.segments) {
|
|
17459
|
-
if (s instanceof Segment
|
|
17465
|
+
if (!(s instanceof Segment)) continue;
|
|
17466
|
+
if (s.role !== "lead1" && s.role !== "lead2") continue;
|
|
17467
|
+
if (segTouchesPoint(el, s, junctionPt, tol)) return s;
|
|
17460
17468
|
}
|
|
17461
|
-
return findSegmentNearPoint(el, junctionPt);
|
|
17462
|
-
}
|
|
17463
|
-
function findSegmentNearPoint(el, absPt) {
|
|
17464
17469
|
let best;
|
|
17465
17470
|
let bestDist = Infinity;
|
|
17466
|
-
const tol = 0.6;
|
|
17467
17471
|
for (const s of el.segments) {
|
|
17468
17472
|
if (!(s instanceof Segment)) continue;
|
|
17469
17473
|
if (s.path.length < 2) continue;
|
|
17470
17474
|
if (s.role === "body") continue;
|
|
17471
|
-
|
|
17472
|
-
const
|
|
17473
|
-
const d0 = Math.hypot(p0.x - absPt.x, p0.y - absPt.y);
|
|
17474
|
-
const dN = Math.hypot(pN.x - absPt.x, pN.y - absPt.y);
|
|
17475
|
-
const d = Math.min(d0, dN);
|
|
17475
|
+
if (s.path.length > 6) continue;
|
|
17476
|
+
const d = segDistToPoint(el, s, junctionPt);
|
|
17476
17477
|
if (d < bestDist && d < tol) {
|
|
17477
17478
|
bestDist = d;
|
|
17478
17479
|
best = s;
|
|
@@ -17480,6 +17481,25 @@ function findSegmentNearPoint(el, absPt) {
|
|
|
17480
17481
|
}
|
|
17481
17482
|
return best;
|
|
17482
17483
|
}
|
|
17484
|
+
function segTouchesPoint(el, seg, absPt, tol) {
|
|
17485
|
+
return segDistToPoint(el, seg, absPt) < tol;
|
|
17486
|
+
}
|
|
17487
|
+
function segDistToPoint(el, seg, absPt) {
|
|
17488
|
+
const p0 = el.transform.transform(seg.path[0]);
|
|
17489
|
+
const pN = el.transform.transform(seg.path[seg.path.length - 1]);
|
|
17490
|
+
return Math.min(
|
|
17491
|
+
Math.hypot(p0.x - absPt.x, p0.y - absPt.y),
|
|
17492
|
+
Math.hypot(pN.x - absPt.x, pN.y - absPt.y)
|
|
17493
|
+
);
|
|
17494
|
+
}
|
|
17495
|
+
function nearFarSvg(el, seg, junctionPt, scale) {
|
|
17496
|
+
const p0 = el.transform.transform(seg.path[0]);
|
|
17497
|
+
const pN = el.transform.transform(seg.path[seg.path.length - 1]);
|
|
17498
|
+
const d0 = Math.hypot(p0.x - junctionPt.x, p0.y - junctionPt.y);
|
|
17499
|
+
const dN = Math.hypot(pN.x - junctionPt.x, pN.y - junctionPt.y);
|
|
17500
|
+
const far = d0 > dN ? p0 : pN;
|
|
17501
|
+
return { farX: far.x * scale, farY: -far.y * scale };
|
|
17502
|
+
}
|
|
17483
17503
|
function segEndpointsSvg(el, seg, scale) {
|
|
17484
17504
|
const p0 = el.transform.transform(seg.path[0]);
|
|
17485
17505
|
const p1 = el.transform.transform(seg.path[seg.path.length - 1]);
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
import type { Element } from "./element.js";
|
|
9
9
|
import { Point } from "./geometry/point.js";
|
|
10
10
|
interface ConnectionEdge {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** The absolute point where the
|
|
11
|
+
elA: Element;
|
|
12
|
+
elB: Element;
|
|
13
|
+
colorA: string;
|
|
14
|
+
colorB: string;
|
|
15
|
+
/** The absolute point where the two elements meet. */
|
|
16
16
|
junctionPt: Point;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Find
|
|
20
|
-
*
|
|
19
|
+
* Find pairs of elements that share a connection point (any pin anchor within
|
|
20
|
+
* tolerance) and have different resolved colors.
|
|
21
21
|
*
|
|
22
|
-
* Checks end
|
|
23
|
-
*
|
|
22
|
+
* Checks pin-level anchors (start, end, out, in1, in2, base, collector, etc.)
|
|
23
|
+
* so connections via named pins on multi-terminal elements are detected.
|
|
24
24
|
*/
|
|
25
25
|
export declare function buildConnectionGraph(elements: readonly Element[]): ConnectionEdge[];
|
|
26
26
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -17732,51 +17732,55 @@ function resolveElementColor(el) {
|
|
|
17732
17732
|
const p = mergeParamsFirstWins(el.userParams, el.elmParams, el.defaults, el.dwgParams);
|
|
17733
17733
|
return p.color ?? "black";
|
|
17734
17734
|
}
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17735
|
+
var EXCLUDED_ANCHORS = /* @__PURE__ */ new Set([
|
|
17736
|
+
"xy",
|
|
17737
|
+
"center",
|
|
17738
|
+
"istart",
|
|
17739
|
+
"iend",
|
|
17740
|
+
"mid",
|
|
17741
|
+
"label",
|
|
17742
|
+
"vd",
|
|
17743
|
+
"vs",
|
|
17744
|
+
"n1",
|
|
17745
|
+
"n2",
|
|
17746
|
+
"n1a",
|
|
17747
|
+
"n2a"
|
|
17748
|
+
]);
|
|
17749
|
+
function isConnectionAnchor(name) {
|
|
17750
|
+
return !EXCLUDED_ANCHORS.has(name);
|
|
17741
17751
|
}
|
|
17742
|
-
function
|
|
17752
|
+
function getConnectionAnchors(el) {
|
|
17743
17753
|
const pts = [];
|
|
17744
|
-
const
|
|
17745
|
-
|
|
17746
|
-
for (const [name, pt] of Object.entries(aa)) {
|
|
17747
|
-
if (name.startsWith("in") && /^in\d+$/.test(name)) {
|
|
17748
|
-
if (!aa.start || !pointsClose(pt, aa.start, 0.01)) pts.push(pt);
|
|
17749
|
-
}
|
|
17754
|
+
for (const [name, pt] of Object.entries(el.absanchors)) {
|
|
17755
|
+
if (isConnectionAnchor(name)) pts.push(pt);
|
|
17750
17756
|
}
|
|
17751
17757
|
return pts;
|
|
17752
17758
|
}
|
|
17753
|
-
function pointsClose(a, b, tol) {
|
|
17754
|
-
return Math.hypot(a.x - b.x, a.y - b.y) <= tol;
|
|
17755
|
-
}
|
|
17756
17759
|
function buildConnectionGraph(elements) {
|
|
17757
17760
|
const edges = [];
|
|
17758
17761
|
const seen = /* @__PURE__ */ new Set();
|
|
17759
17762
|
const tol = 0.5;
|
|
17760
17763
|
for (let i = 0; i < elements.length; i++) {
|
|
17761
|
-
const
|
|
17762
|
-
const
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
for (let j =
|
|
17766
|
-
|
|
17767
|
-
const
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
if (!pointsClose(fp, tp, tol)) continue;
|
|
17764
|
+
const elA = elements[i];
|
|
17765
|
+
const colorA = resolveElementColor(elA);
|
|
17766
|
+
const anchorsA = getConnectionAnchors(elA);
|
|
17767
|
+
if (anchorsA.length === 0) continue;
|
|
17768
|
+
for (let j = i + 1; j < elements.length; j++) {
|
|
17769
|
+
const elB = elements[j];
|
|
17770
|
+
const colorB = resolveElementColor(elB);
|
|
17771
|
+
if (colorsEqual(colorA, colorB)) continue;
|
|
17772
|
+
const anchorsB = getConnectionAnchors(elB);
|
|
17773
|
+
if (anchorsB.length === 0) continue;
|
|
17774
|
+
for (const pa of anchorsA) {
|
|
17775
|
+
for (const pb of anchorsB) {
|
|
17776
|
+
if (Math.hypot(pa.x - pb.x, pa.y - pb.y) > tol) continue;
|
|
17775
17777
|
const key = `${i}|${j}`;
|
|
17776
17778
|
if (seen.has(key)) continue;
|
|
17777
17779
|
seen.add(key);
|
|
17778
|
-
edges.push({
|
|
17780
|
+
edges.push({ elA, elB, colorA, colorB, junctionPt: pa });
|
|
17781
|
+
break;
|
|
17779
17782
|
}
|
|
17783
|
+
if (seen.has(`${i}|${j}`)) break;
|
|
17780
17784
|
}
|
|
17781
17785
|
}
|
|
17782
17786
|
}
|
|
@@ -17792,26 +17796,28 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17792
17796
|
const cleanups = [];
|
|
17793
17797
|
let n = 0;
|
|
17794
17798
|
for (const edge of edges) {
|
|
17795
|
-
const
|
|
17796
|
-
const
|
|
17797
|
-
if (!
|
|
17798
|
-
if (
|
|
17799
|
+
const segA = findSegAtJunction(edge.elA, edge.junctionPt);
|
|
17800
|
+
const segB = findSegAtJunction(edge.elB, edge.junctionPt);
|
|
17801
|
+
if (!segA && !segB) continue;
|
|
17802
|
+
if (segA?.gradientStrokeId && segB?.gradientStrokeId) continue;
|
|
17799
17803
|
let gx1, gy1, gx2, gy2;
|
|
17800
|
-
if (
|
|
17801
|
-
const
|
|
17802
|
-
const
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17804
|
+
if (segA && segB) {
|
|
17805
|
+
const a = segEndpointsSvg(edge.elA, segA, scale);
|
|
17806
|
+
const b = segEndpointsSvg(edge.elB, segB, scale);
|
|
17807
|
+
const aNear = nearFarSvg(edge.elA, segA, edge.junctionPt, scale);
|
|
17808
|
+
const bNear = nearFarSvg(edge.elB, segB, edge.junctionPt, scale);
|
|
17809
|
+
gx1 = aNear.farX;
|
|
17810
|
+
gy1 = aNear.farY;
|
|
17811
|
+
gx2 = bNear.farX;
|
|
17812
|
+
gy2 = bNear.farY;
|
|
17813
|
+
} else if (segA) {
|
|
17814
|
+
const c = segEndpointsSvg(edge.elA, segA, scale);
|
|
17809
17815
|
gx1 = c.x1;
|
|
17810
17816
|
gy1 = c.y1;
|
|
17811
17817
|
gx2 = c.x2;
|
|
17812
17818
|
gy2 = c.y2;
|
|
17813
17819
|
} else {
|
|
17814
|
-
const c = segEndpointsSvg(edge.
|
|
17820
|
+
const c = segEndpointsSvg(edge.elB, segB, scale);
|
|
17815
17821
|
gx1 = c.x1;
|
|
17816
17822
|
gy1 = c.y1;
|
|
17817
17823
|
gx2 = c.x2;
|
|
@@ -17819,17 +17825,17 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17819
17825
|
}
|
|
17820
17826
|
if (gradientVectorLength({ x1: gx1, y1: gy1, x2: gx2, y2: gy2 }) < 1e-6) continue;
|
|
17821
17827
|
const id = `sd-trans-${n++}`;
|
|
17822
|
-
parts.push(gradientXml(id, gx1, gy1, gx2, gy2, edge.
|
|
17823
|
-
if (
|
|
17824
|
-
|
|
17828
|
+
parts.push(gradientXml(id, gx1, gy1, gx2, gy2, edge.colorA, edge.colorB));
|
|
17829
|
+
if (segA && !segA.gradientStrokeId) {
|
|
17830
|
+
segA.gradientStrokeId = id;
|
|
17825
17831
|
cleanups.push(() => {
|
|
17826
|
-
|
|
17832
|
+
segA.gradientStrokeId = void 0;
|
|
17827
17833
|
});
|
|
17828
17834
|
}
|
|
17829
|
-
if (
|
|
17830
|
-
|
|
17835
|
+
if (segB && !segB.gradientStrokeId) {
|
|
17836
|
+
segB.gradientStrokeId = id;
|
|
17831
17837
|
cleanups.push(() => {
|
|
17832
|
-
|
|
17838
|
+
segB.gradientStrokeId = void 0;
|
|
17833
17839
|
});
|
|
17834
17840
|
}
|
|
17835
17841
|
}
|
|
@@ -17840,26 +17846,21 @@ function assignLeadTransitionIds(elements, edges, scale) {
|
|
|
17840
17846
|
}
|
|
17841
17847
|
};
|
|
17842
17848
|
}
|
|
17843
|
-
function
|
|
17844
|
-
const
|
|
17849
|
+
function findSegAtJunction(el, junctionPt) {
|
|
17850
|
+
const tol = 0.6;
|
|
17845
17851
|
for (const s of el.segments) {
|
|
17846
|
-
if (s instanceof Segment
|
|
17852
|
+
if (!(s instanceof Segment)) continue;
|
|
17853
|
+
if (s.role !== "lead1" && s.role !== "lead2") continue;
|
|
17854
|
+
if (segTouchesPoint(el, s, junctionPt, tol)) return s;
|
|
17847
17855
|
}
|
|
17848
|
-
return findSegmentNearPoint(el, junctionPt);
|
|
17849
|
-
}
|
|
17850
|
-
function findSegmentNearPoint(el, absPt) {
|
|
17851
17856
|
let best;
|
|
17852
17857
|
let bestDist = Infinity;
|
|
17853
|
-
const tol = 0.6;
|
|
17854
17858
|
for (const s of el.segments) {
|
|
17855
17859
|
if (!(s instanceof Segment)) continue;
|
|
17856
17860
|
if (s.path.length < 2) continue;
|
|
17857
17861
|
if (s.role === "body") continue;
|
|
17858
|
-
|
|
17859
|
-
const
|
|
17860
|
-
const d0 = Math.hypot(p0.x - absPt.x, p0.y - absPt.y);
|
|
17861
|
-
const dN = Math.hypot(pN.x - absPt.x, pN.y - absPt.y);
|
|
17862
|
-
const d = Math.min(d0, dN);
|
|
17862
|
+
if (s.path.length > 6) continue;
|
|
17863
|
+
const d = segDistToPoint(el, s, junctionPt);
|
|
17863
17864
|
if (d < bestDist && d < tol) {
|
|
17864
17865
|
bestDist = d;
|
|
17865
17866
|
best = s;
|
|
@@ -17867,6 +17868,25 @@ function findSegmentNearPoint(el, absPt) {
|
|
|
17867
17868
|
}
|
|
17868
17869
|
return best;
|
|
17869
17870
|
}
|
|
17871
|
+
function segTouchesPoint(el, seg, absPt, tol) {
|
|
17872
|
+
return segDistToPoint(el, seg, absPt) < tol;
|
|
17873
|
+
}
|
|
17874
|
+
function segDistToPoint(el, seg, absPt) {
|
|
17875
|
+
const p0 = el.transform.transform(seg.path[0]);
|
|
17876
|
+
const pN = el.transform.transform(seg.path[seg.path.length - 1]);
|
|
17877
|
+
return Math.min(
|
|
17878
|
+
Math.hypot(p0.x - absPt.x, p0.y - absPt.y),
|
|
17879
|
+
Math.hypot(pN.x - absPt.x, pN.y - absPt.y)
|
|
17880
|
+
);
|
|
17881
|
+
}
|
|
17882
|
+
function nearFarSvg(el, seg, junctionPt, scale) {
|
|
17883
|
+
const p0 = el.transform.transform(seg.path[0]);
|
|
17884
|
+
const pN = el.transform.transform(seg.path[seg.path.length - 1]);
|
|
17885
|
+
const d0 = Math.hypot(p0.x - junctionPt.x, p0.y - junctionPt.y);
|
|
17886
|
+
const dN = Math.hypot(pN.x - junctionPt.x, pN.y - junctionPt.y);
|
|
17887
|
+
const far = d0 > dN ? p0 : pN;
|
|
17888
|
+
return { farX: far.x * scale, farY: -far.y * scale };
|
|
17889
|
+
}
|
|
17870
17890
|
function segEndpointsSvg(el, seg, scale) {
|
|
17871
17891
|
const p0 = el.transform.transform(seg.path[0]);
|
|
17872
17892
|
const p1 = el.transform.transform(seg.path[seg.path.length - 1]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillpet/circuit",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|