@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.
@@ -1236,6 +1236,29 @@ function drawPhylogeny(
1236
1236
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1237
1237
  }
1238
1238
 
1239
+ // put this next to your other radial helpers (top of file or in your lib)
1240
+ function arcPathCCW(cx, cy, R, a0, a1) {
1241
+ const TAU = Math.PI * 2;
1242
+ const norm = (t) => ((t % TAU) + TAU) % TAU;
1243
+
1244
+ a0 = norm(a0);
1245
+ a1 = norm(a1);
1246
+
1247
+ const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1248
+ if (delta < 1e-9) return ""; // degenerate; draw nothing
1249
+
1250
+ // With your polarToCartesian using y = cy - r*sin(t),
1251
+ // sweepFlag=0 gives a visually CCW arc segment.
1252
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
1253
+ const sweepFlag = 0;
1254
+
1255
+ const p0 = polarToCartesian(cx, cy, R, a0);
1256
+ const p1 = polarToCartesian(cx, cy, R, a1);
1257
+
1258
+ return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1259
+ }
1260
+
1261
+
1239
1262
  // ===== SVG ROOT =====
1240
1263
  const svg = d3__namespace
1241
1264
  .create("svg")
@@ -1455,9 +1478,7 @@ function drawPhylogeny(
1455
1478
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1456
1479
  const a = arcByChild.get(cur.thisId);
1457
1480
  if (a) {
1458
- const pathD = (a.sweep == null)
1459
- ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1460
- : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1481
+ const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1461
1482
 
1462
1483
  arcLayer
1463
1484
  .append("path")