MCPcopy Create free account
hub / github.com/breck7/scroll / arc

Function arc

external/.d3.js:17584–17775  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17582}
17583
17584function arc() {
17585 var innerRadius = arcInnerRadius,
17586 outerRadius = arcOuterRadius,
17587 cornerRadius = constant$1(0),
17588 padRadius = null,
17589 startAngle = arcStartAngle,
17590 endAngle = arcEndAngle,
17591 padAngle = arcPadAngle,
17592 context = null,
17593 path = withPath(arc);
17594
17595 function arc() {
17596 var buffer,
17597 r,
17598 r0 = +innerRadius.apply(this, arguments),
17599 r1 = +outerRadius.apply(this, arguments),
17600 a0 = startAngle.apply(this, arguments) - halfPi,
17601 a1 = endAngle.apply(this, arguments) - halfPi,
17602 da = abs(a1 - a0),
17603 cw = a1 > a0;
17604
17605 if (!context) context = buffer = path();
17606
17607 // Ensure that the outer radius is always larger than the inner radius.
17608 if (r1 < r0) r = r1, r1 = r0, r0 = r;
17609
17610 // Is it a point?
17611 if (!(r1 > epsilon)) context.moveTo(0, 0);
17612
17613 // Or is it a circle or annulus?
17614 else if (da > tau - epsilon) {
17615 context.moveTo(r1 * cos(a0), r1 * sin(a0));
17616 context.arc(0, 0, r1, a0, a1, !cw);
17617 if (r0 > epsilon) {
17618 context.moveTo(r0 * cos(a1), r0 * sin(a1));
17619 context.arc(0, 0, r0, a1, a0, cw);
17620 }
17621 }
17622
17623 // Or is it a circular or annular sector?
17624 else {
17625 var a01 = a0,
17626 a11 = a1,
17627 a00 = a0,
17628 a10 = a1,
17629 da0 = da,
17630 da1 = da,
17631 ap = padAngle.apply(this, arguments) / 2,
17632 rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)),
17633 rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
17634 rc0 = rc,
17635 rc1 = rc,
17636 t0,
17637 t1;
17638
17639 // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
17640 if (rp > epsilon) {
17641 var p0 = asin(rp / r0 * sin(ap)),

Callers

nothing calls this directly

Calls 11

constant$1Function · 0.85
withPathFunction · 0.85
pathFunction · 0.85
asinFunction · 0.85
intersectFunction · 0.85
acosFunction · 0.85
cornerTangentsFunction · 0.85
arcMethod · 0.80
moveToMethod · 0.45
lineToMethod · 0.45
closePathMethod · 0.45

Tested by

no test coverage detected