@euphrasiologist/lwphylo 1.2.15 → 1.2.16

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/index.cjs CHANGED
@@ -1403,6 +1403,29 @@ function drawPhylogeny(
1403
1403
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1404
1404
  }
1405
1405
 
1406
+ // put this next to your other radial helpers (top of file or in your lib)
1407
+ function arcPathCCW(cx, cy, R, a0, a1) {
1408
+ const TAU = Math.PI * 2;
1409
+ const norm = (t) => ((t % TAU) + TAU) % TAU;
1410
+
1411
+ a0 = norm(a0);
1412
+ a1 = norm(a1);
1413
+
1414
+ const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1415
+ if (delta < 1e-9) return ""; // degenerate; draw nothing
1416
+
1417
+ // With your polarToCartesian using y = cy - r*sin(t),
1418
+ // sweepFlag=0 gives a visually CCW arc segment.
1419
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
1420
+ const sweepFlag = 0;
1421
+
1422
+ const p0 = polarToCartesian(cx, cy, R, a0);
1423
+ const p1 = polarToCartesian(cx, cy, R, a1);
1424
+
1425
+ return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1426
+ }
1427
+
1428
+
1406
1429
  // ===== SVG ROOT =====
1407
1430
  const svg = d3__namespace
1408
1431
  .create("svg")
@@ -1622,9 +1645,7 @@ function drawPhylogeny(
1622
1645
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1623
1646
  const a = arcByChild.get(cur.thisId);
1624
1647
  if (a) {
1625
- const pathD = (a.sweep == null)
1626
- ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1627
- : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1648
+ const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1628
1649
 
1629
1650
  arcLayer
1630
1651
  .append("path")
@@ -1885,6 +1906,7 @@ exports.describeArcSweep = describeArcSweep;
1885
1906
  exports.drawPhylogeny = drawPhylogeny;
1886
1907
  exports.parentFisheye = parentFisheye;
1887
1908
  exports.phisheye = phisheye;
1909
+ exports.polarToCartesian = polarToCartesian;
1888
1910
  exports.radialLayout = radialLayout;
1889
1911
  exports.readTree = readTree;
1890
1912
  exports.rectangleLayout = rectangleLayout;