@euphrasiologist/lwphylo 1.2.23 → 1.2.24

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.
@@ -62,23 +62,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
62
62
  }
63
63
 
64
64
  // src/radial/describeArcSweep.js
65
- const TAU$1 = Math.PI * 2;
66
- const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
67
-
68
- function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
65
+ function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
69
66
  console.log("describeArcSweep input:", {
70
67
  cx, cy, r,
71
68
  a0Deg: (a0 * 180 / Math.PI).toFixed(2),
72
69
  a1Deg: (a1 * 180 / Math.PI).toFixed(2),
73
- sweep
70
+ sweep,
71
+ largeArcFlag
74
72
  });
75
73
 
76
- const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
77
- if (!(r > 0) || delta < 1e-9) return "";
78
- const largeArcFlag = delta > Math.PI ? 1 : 0;
74
+ if (!(r > 0)) return "";
79
75
 
80
- const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
81
- const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
76
+ const x0 = cx + r * Math.cos(a0);
77
+ const y0 = cy - r * Math.sin(a0);
78
+ const x1 = cx + r * Math.cos(a1);
79
+ const y1 = cy - r * Math.sin(a1);
82
80
 
83
81
  return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
84
82
  }
@@ -480,19 +478,16 @@ function getChildArcsFan(pd) {
480
478
  const TAU = Math.PI * 2;
481
479
  const norm = (t) => ((t % TAU) + TAU) % TAU;
482
480
 
483
- // Circular midpoint that travels CCW from a -> b by half the CCW span
484
481
  function midCCW(a, b) {
485
- const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
482
+ const d = (b - a + TAU) % TAU;
486
483
  return norm(a + d / 2);
487
484
  }
488
485
 
489
486
  const key = (x) => (typeof x === "string" ? +x : x);
490
-
491
487
  const byId = new Map(pd.map(d => [key(d.thisId), d]));
492
488
  const childrenByParent = new Map(
493
489
  pd.map(d => [
494
490
  key(d.thisId),
495
- // normalize children to numeric IDs; drop anything we can't resolve
496
491
  (d.children || [])
497
492
  .map(ch => (typeof ch === "object" ? ch.thisId : ch))
498
493
  .map(key)
@@ -507,7 +502,6 @@ function getChildArcsFan(pd) {
507
502
  const kids = childrenByParent.get(pid) || [];
508
503
  if (kids.length < 2) continue;
509
504
 
510
- // Sort children by angle (normalized) around the circle
511
505
  const A = kids
512
506
  .map(id => {
513
507
  const node = byId.get(id);
@@ -531,9 +525,9 @@ function getChildArcsFan(pd) {
531
525
  const start = midCCW(prev.a, cur.a);
532
526
  const end = midCCW(cur.a, next.a);
533
527
 
534
- // Use SVG-conforming sweep logic
528
+ const sweep = 1; // always clockwise
535
529
  const delta = (end - start + TAU) % TAU;
536
- const sweep = delta > Math.PI ? 0 : 1;
530
+ const largeArc = delta > Math.PI ? 1 : 0;
537
531
 
538
532
  child_arcs.push({
539
533
  parentId: pid,
@@ -541,10 +535,10 @@ function getChildArcsFan(pd) {
541
535
  radius,
542
536
  start,
543
537
  end,
544
- sweep
538
+ sweep,
539
+ largeArc
545
540
  });
546
541
  }
547
-
548
542
  }
549
543
 
550
544
  return child_arcs;
@@ -1305,7 +1299,8 @@ function drawPhylogeny(
1305
1299
  radiusPx(d.radius),
1306
1300
  d.start,
1307
1301
  d.end,
1308
- d.sweep
1302
+ d.sweep,
1303
+ d.largeArc,
1309
1304
  )
1310
1305
  )
1311
1306
  .attr("fill", "none")
@@ -1494,7 +1489,7 @@ function drawPhylogeny(
1494
1489
  const R = radiusPx(rec.radius);
1495
1490
  return rec.sweep == null
1496
1491
  ? describeArc(centerX, centerY, R, rec.start, rec.end)
1497
- : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1492
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
1498
1493
  }
1499
1494
 
1500
1495
  if (a) {