@euphrasiologist/lwphylo 1.2.6 → 1.2.7

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.cjs CHANGED
@@ -174,6 +174,18 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
174
174
  return `M ${p0.x} ${p0.y} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
175
175
  }
176
176
 
177
+ // describeArcSweep.js
178
+ function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
179
+ const TAU = Math.PI * 2;
180
+ const norm = (t) => ((t % TAU) + TAU) % TAU;
181
+ const delta = sweep === 0 ? norm(a1 - a0) : norm(a0 - a1); // magnitude on chosen sweep
182
+ if (delta < 1e-9 || r <= 0) return "";
183
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
184
+ const p0 = { x: cx + r * Math.cos(a0), y: cy - r * Math.sin(a0) };
185
+ const p1 = { x: cx + r * Math.cos(a1), y: cy - r * Math.sin(a1) };
186
+ return `M ${p0.x} ${p0.y} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${p1.x} ${p1.y}`;
187
+ }
188
+
177
189
  /**
178
190
  * Recursive function for pre-order traversal of tree (returns array)
179
191
  */
@@ -1764,6 +1776,7 @@ function drawPhylogeny(
1764
1776
  }
1765
1777
 
1766
1778
  exports.describeArc = describeArc;
1779
+ exports.describeArcSweep = describeArcSweep;
1767
1780
  exports.drawPhylogeny = drawPhylogeny;
1768
1781
  exports.parentFisheye = parentFisheye;
1769
1782
  exports.phisheye = phisheye;