@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.
@@ -1215,6 +1215,29 @@ function drawPhylogeny(
1215
1215
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1216
1216
  }
1217
1217
 
1218
+ // put this next to your other radial helpers (top of file or in your lib)
1219
+ function arcPathCCW(cx, cy, R, a0, a1) {
1220
+ const TAU = Math.PI * 2;
1221
+ const norm = (t) => ((t % TAU) + TAU) % TAU;
1222
+
1223
+ a0 = norm(a0);
1224
+ a1 = norm(a1);
1225
+
1226
+ const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1227
+ if (delta < 1e-9) return ""; // degenerate; draw nothing
1228
+
1229
+ // With your polarToCartesian using y = cy - r*sin(t),
1230
+ // sweepFlag=0 gives a visually CCW arc segment.
1231
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
1232
+ const sweepFlag = 0;
1233
+
1234
+ const p0 = polarToCartesian(cx, cy, R, a0);
1235
+ const p1 = polarToCartesian(cx, cy, R, a1);
1236
+
1237
+ return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1238
+ }
1239
+
1240
+
1218
1241
  // ===== SVG ROOT =====
1219
1242
  const svg = d3
1220
1243
  .create("svg")
@@ -1434,9 +1457,7 @@ function drawPhylogeny(
1434
1457
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1435
1458
  const a = arcByChild.get(cur.thisId);
1436
1459
  if (a) {
1437
- const pathD = (a.sweep == null)
1438
- ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1439
- : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1460
+ const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1440
1461
 
1441
1462
  arcLayer
1442
1463
  .append("path")