@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.
package/dist/index.js CHANGED
@@ -154,23 +154,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
154
154
  }
155
155
 
156
156
  // src/radial/describeArcSweep.js
157
- const TAU$1 = Math.PI * 2;
158
- const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
159
-
160
- function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
157
+ function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
161
158
  console.log("describeArcSweep input:", {
162
159
  cx, cy, r,
163
160
  a0Deg: (a0 * 180 / Math.PI).toFixed(2),
164
161
  a1Deg: (a1 * 180 / Math.PI).toFixed(2),
165
- sweep
162
+ sweep,
163
+ largeArcFlag
166
164
  });
167
165
 
168
- const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
169
- if (!(r > 0) || delta < 1e-9) return "";
170
- const largeArcFlag = delta > Math.PI ? 1 : 0;
166
+ if (!(r > 0)) return "";
171
167
 
172
- const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
173
- const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
168
+ const x0 = cx + r * Math.cos(a0);
169
+ const y0 = cy - r * Math.sin(a0);
170
+ const x1 = cx + r * Math.cos(a1);
171
+ const y1 = cy - r * Math.sin(a1);
174
172
 
175
173
  return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
176
174
  }
@@ -572,19 +570,16 @@ function getChildArcsFan(pd) {
572
570
  const TAU = Math.PI * 2;
573
571
  const norm = (t) => ((t % TAU) + TAU) % TAU;
574
572
 
575
- // Circular midpoint that travels CCW from a -> b by half the CCW span
576
573
  function midCCW(a, b) {
577
- const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
574
+ const d = (b - a + TAU) % TAU;
578
575
  return norm(a + d / 2);
579
576
  }
580
577
 
581
578
  const key = (x) => (typeof x === "string" ? +x : x);
582
-
583
579
  const byId = new Map(pd.map(d => [key(d.thisId), d]));
584
580
  const childrenByParent = new Map(
585
581
  pd.map(d => [
586
582
  key(d.thisId),
587
- // normalize children to numeric IDs; drop anything we can't resolve
588
583
  (d.children || [])
589
584
  .map(ch => (typeof ch === "object" ? ch.thisId : ch))
590
585
  .map(key)
@@ -599,7 +594,6 @@ function getChildArcsFan(pd) {
599
594
  const kids = childrenByParent.get(pid) || [];
600
595
  if (kids.length < 2) continue;
601
596
 
602
- // Sort children by angle (normalized) around the circle
603
597
  const A = kids
604
598
  .map(id => {
605
599
  const node = byId.get(id);
@@ -623,9 +617,9 @@ function getChildArcsFan(pd) {
623
617
  const start = midCCW(prev.a, cur.a);
624
618
  const end = midCCW(cur.a, next.a);
625
619
 
626
- // Use SVG-conforming sweep logic
620
+ const sweep = 1; // always clockwise
627
621
  const delta = (end - start + TAU) % TAU;
628
- const sweep = delta > Math.PI ? 0 : 1;
622
+ const largeArc = delta > Math.PI ? 1 : 0;
629
623
 
630
624
  child_arcs.push({
631
625
  parentId: pid,
@@ -633,10 +627,10 @@ function getChildArcsFan(pd) {
633
627
  radius,
634
628
  start,
635
629
  end,
636
- sweep
630
+ sweep,
631
+ largeArc
637
632
  });
638
633
  }
639
-
640
634
  }
641
635
 
642
636
  return child_arcs;
@@ -1451,7 +1445,8 @@ function drawPhylogeny(
1451
1445
  radiusPx(d.radius),
1452
1446
  d.start,
1453
1447
  d.end,
1454
- d.sweep
1448
+ d.sweep,
1449
+ d.largeArc,
1455
1450
  )
1456
1451
  )
1457
1452
  .attr("fill", "none")
@@ -1640,7 +1635,7 @@ function drawPhylogeny(
1640
1635
  const R = radiusPx(rec.radius);
1641
1636
  return rec.sweep == null
1642
1637
  ? describeArc(centerX, centerY, R, rec.start, rec.end)
1643
- : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1638
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
1644
1639
  }
1645
1640
 
1646
1641
  if (a) {