@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.js CHANGED
@@ -1382,6 +1382,29 @@ function drawPhylogeny(
1382
1382
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1383
1383
  }
1384
1384
 
1385
+ // put this next to your other radial helpers (top of file or in your lib)
1386
+ function arcPathCCW(cx, cy, R, a0, a1) {
1387
+ const TAU = Math.PI * 2;
1388
+ const norm = (t) => ((t % TAU) + TAU) % TAU;
1389
+
1390
+ a0 = norm(a0);
1391
+ a1 = norm(a1);
1392
+
1393
+ const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1394
+ if (delta < 1e-9) return ""; // degenerate; draw nothing
1395
+
1396
+ // With your polarToCartesian using y = cy - r*sin(t),
1397
+ // sweepFlag=0 gives a visually CCW arc segment.
1398
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
1399
+ const sweepFlag = 0;
1400
+
1401
+ const p0 = polarToCartesian(cx, cy, R, a0);
1402
+ const p1 = polarToCartesian(cx, cy, R, a1);
1403
+
1404
+ return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1405
+ }
1406
+
1407
+
1385
1408
  // ===== SVG ROOT =====
1386
1409
  const svg = d3
1387
1410
  .create("svg")
@@ -1601,9 +1624,7 @@ function drawPhylogeny(
1601
1624
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1602
1625
  const a = arcByChild.get(cur.thisId);
1603
1626
  if (a) {
1604
- const pathD = (a.sweep == null)
1605
- ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1606
- : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1627
+ const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1607
1628
 
1608
1629
  arcLayer
1609
1630
  .append("path")
@@ -1859,5 +1880,5 @@ function drawPhylogeny(
1859
1880
  }
1860
1881
  }
1861
1882
 
1862
- export { describeArc, describeArcSweep, drawPhylogeny, parentFisheye, phisheye, radialLayout, readTree, rectangleLayout, subTree, unrooted };
1883
+ export { describeArc, describeArcSweep, drawPhylogeny, parentFisheye, phisheye, polarToCartesian, radialLayout, readTree, rectangleLayout, subTree, unrooted };
1863
1884
  //# sourceMappingURL=index.js.map